public SubmitObjectsRequest CreateSubmitObjectsRequest()
        {
            var request = new SubmitObjectsRequest();

            var identifiables = new List <IdentifiableType>();

            // Create metadata for root
            var extrinsicObject = CreateExtrinsicObjectType();

            // Create metadata for submission set / package
            var registryPackage = CreateRegistryPackageType();

            // Create classification for submission set / package
            var classification = CreateClassificationType(
                "cl10",
                XDS_SUBMISSION_SET,
                SubmissionSetId);

            var associations = new List <AssociationType1>();

            // Add associations of files to submission set
            var association = CreateAssociationType(
                "as01",
                XDS_ASSOCIATION_TYPE_HAS_MEMBER,
                SubmissionSetId,
                DocumentId,
                new SlotType1[]
            {
                CreateSlotType("SubmissionSetStatus", "Original")
            },
                null
                );

            associations.Add(association);

            // If replacement document UUID is set, then create replacement association;
            if (!string.IsNullOrEmpty(uuidOfDocumentToReplace))
            {
                association = CreateAssociationType(
                    "as02",
                    XDS_ASSOCIATION_TYPE_RPLC,
                    DocumentId,
                    uuidOfDocumentToReplace,
                    null,
                    "Replace Document"
                    );
                associations.Add(association);
            }

            request.RegistryObjectList                 = new RegistryObjectListType();
            request.RegistryObjectList.Association     = associations.ToArray();
            request.RegistryObjectList.Classification  = new ClassificationType[] { classification };
            request.RegistryObjectList.ExtrinsicObject = new ExtrinsicObjectType[] { extrinsicObject };
            request.RegistryObjectList.RegistryPackage = new RegistryPackageType[] { registryPackage };

            var requestXml = request.SerializeToXml();

            return(request);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a submit objects request.
        /// </summary>
        /// <param name="objects">The objects.</param>
        /// <returns>Returns the created submit objects request.</returns>
        public static SubmitObjectsRequest CreateSubmitObjectsRequest(params IdentifiableType[] objects)
        {
            var retVal = new SubmitObjectsRequest
            {
                RegistryObjectList = objects
            };

            return(retVal);
        }
 public ProvideAndRegisterDocumentSetRequest(SubmissionSet submission)
 {
     SubmitObjectsRequest = new SubmitObjectsRequest
     {
         RegistryObjects = BuildMetadata(submission)
     };
     Documents = submission.Documents.Select(d => new XdsDocument
     {
         Id      = d.EntryUuid,
         Content = d.Content
     }).ToList();
 }
        public void Sample()
        {
            // Obtain the certificate for use with TLS and signing
            X509Certificate2 cert = X509CertificateUtil.GetCertificate(
                "Serial Number",
                X509FindType.FindBySerialNumber,
                StoreName.My,
                StoreLocation.CurrentUser,
                true
                );

            // Create PCEHR header
            CommonPcehrHeader header = PcehrHeaderHelper.CreateHeader();

            // Override this value to the current patient's IHI.
            header.IhiNumber = "IHI";

            // Create the client
            UploadDocumentMetadataClient uploadDocumentMetadataClient = new UploadDocumentMetadataClient(
                new Uri("https://UploadDocumentEndpoint"), cert, cert);

            // Add server certificate validation callback
            ServicePointManager.ServerCertificateValidationCallback += ValidateServiceCertificate;

            byte[] packageBytes = File.ReadAllBytes("CdaPackage.zip"); // Create a package

            // Create a request from an existing package
            // Format codes and format code names are not fixed, and it is recommended for them to be configurable.
            SubmitObjectsRequest request = uploadDocumentMetadataClient.CreateRequestForNewDocument(
                packageBytes,
                "unique repository ID",
                "formatCode",
                "formatCodeName",
                HealthcareFacilityTypeCodes.GeneralPractice,
                PracticeSettingTypes.GeneralPracticeMedicalClinicService
                );



            try
            {
                // Invoke the service
                RegistryResponseType registryResponse = uploadDocumentMetadataClient.UploadDocumentMetadata(header, request);

                // Get the soap request and response
                string soapRequest  = uploadDocumentMetadataClient.SoapMessages.SoapRequest;
                string soapResponse = uploadDocumentMetadataClient.SoapMessages.SoapResponse;
            }
            catch (FaultException fex)
            {
                // Handle any errors
            }
        }
Esempio n. 5
0
        private CommonPcehrHeader CreateCommonPcehrHeader(SubmitObjectsRequest submitObjectsRequest)
        {
            // Extract the header data from the XDS data
            PcehrHeaderData pcehrHeaderData = XdsUtils.ExtractPcehrHeaderData(submitObjectsRequest);

            // Create the common header using the data from the XDS metadata
            var commonPcehrHeader = new CommonPcehrHeader
            {
                IhiNumber        = pcehrHeaderData.Ihi,
                UserId           = pcehrHeaderData.ProviderId,
                UserIdType       = pcehrHeaderData.IsProviderIdLocal ? CommonPcehrHeaderUserIDType.HPII : CommonPcehrHeaderUserIDType.LocalSystemIdentifier,
                UserName         = pcehrHeaderData.ProviderName,
                OrganisationName = pcehrHeaderData.OrganisationName,
                OrganisationId   = pcehrHeaderData.Hpio,
                ClientSystemType = _clientSystem,

                ProductPlatform = _productInfo.Platform,
                ProductName     = _productInfo.Name,
                ProductVersion  = _productInfo.Version,
                ProductVendor   = _productInfo.Vendor
            };

            return(commonPcehrHeader);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="submitObjectsRequest"></param>
        /// <returns></returns>
        public static PcehrHeaderData ExtractPcehrHeaderData(SubmitObjectsRequest submitObjectsRequest)
        {
            ExtrinsicObjectType extrinsicObject = submitObjectsRequest.RegistryObjectList.ExtrinsicObject.Single();

            ClassificationType classification = extrinsicObject.Classification.Single(
                a => a.classificationScheme == "urn:uuid:93606bcf-9494-43ec-9b4e-a7748d1a838d");

            // Organisation
            SlotType1 authorInstitutionSlot  = classification.Slot.Single(s => s.name == "authorInstitution");
            string    authorInstitutionValue = authorInstitutionSlot.ValueList.Value.Single();

            string[] authorInstitutionValues = authorInstitutionValue.Split('^');
            string   hpioOid          = authorInstitutionValues.Last();
            string   hpio             = hpioOid.Split('.').Last();
            string   organisationName = authorInstitutionValues.First();

            // Provider
            SlotType1 authorPersonSlot = classification.Slot.Single(s => s.name == "authorPerson");

            string[] authorPersonValues = authorPersonSlot.ValueList.Value.First().Split('^');

            // Last name (mandatory)
            string fullName = authorPersonValues[1];

            // Check if first name has been specified
            if (!string.IsNullOrEmpty(authorPersonValues[2]))
            {
                fullName = $"{authorPersonValues[2]} {fullName}";
            }

            // Provider ID
            string[] idValues = authorPersonValues.Last().Split('&');
            string   id;
            bool     isLocalId;

            if (string.IsNullOrEmpty(idValues[0]))
            {
                isLocalId = false;
                id        = idValues[1].Split('.').Last();
            }
            else
            {
                isLocalId = true;
                id        = idValues[1];
            }

            // IHI
            ExternalIdentifierType externalIdentifier = extrinsicObject.ExternalIdentifier.Single(
                e => e.identificationScheme == "urn:uuid:58a6f841-87b3-4a3e-92fd-a8ffeff98427");
            string ihi = externalIdentifier.value.Split('^').First();

            return(new PcehrHeaderData
            {
                Ihi = ihi,
                ProviderName = fullName,
                IsProviderIdLocal = isLocalId,
                ProviderId = id,
                Hpio = hpio,
                OrganisationName = organisationName
            });
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a provide and register request.
        /// </summary>
        /// <param name="registryRequest">The registry request.</param>
        /// <param name="document">The document.</param>
        /// <returns>Returns the created provide and registry document set request type.</returns>
        public static ProvideAndRegisterDocumentSetRequestType CreateProvideAndRegisterRequest(SubmitObjectsRequest registryRequest, params ProvideAndRegisterDocumentSetRequestTypeDocument[] document)
        {
            var retVal = new ProvideAndRegisterDocumentSetRequestType
            {
                SubmitObjectsRequest = registryRequest,
                Document             = document
            };

            return(retVal);
        }
        private SubmitObjectsRequest Build_Test01()
        {
            var request = new SubmitObjectsRequest
            {
                Id              = "urn:xdskit:com:c7ptmx37tfbcwy8ky7a",
                Comment         = "This is a comment",
                RegistryObjects = new RegistryObjectList
                {
                    ExtrinsicObjects = new List <ExtrinsicObject>
                    {
                        new ExtrinsicObject
                        {
                            Id         = "urn:xdskit:com:Document:c7ptmx37tfbcwy8ky7b",
                            MimeType   = "text/xml",
                            ObjectType = "urn:xdskit:com:c7ptmx37tfbcwy8ky7c",
                            Slots      = new List <Slot>
                            {
                                new Slot
                                {
                                    Name   = "creationTime",
                                    Values = new List <string> {
                                        "20051224"
                                    }
                                },
                                new Slot
                                {
                                    Name   = "languageCode",
                                    Values = new List <string> {
                                        "en-us"
                                    }
                                },
                                new Slot
                                {
                                    Name   = "serviceStartTime",
                                    Values = new List <string> {
                                        "200412230800"
                                    }
                                },
                                new Slot
                                {
                                    Name   = "serviceStopTime",
                                    Values = new List <string> {
                                        "200412230801"
                                    }
                                }
                            }
                        }
                    },
                    RegistryPackages = new List <RegistryPackage>
                    {
                        new RegistryPackage
                        {
                            Id          = "urn:xdskit:com:SubmissionSet:c7ptmx37tfbcwy8ky7d",
                            Name        = XmlUtil.LocalString("Progress Note"),
                            Description = XmlUtil.LocalString("Progress Note for 8/1/2015"),
                            Slots       = new List <Slot>
                            {
                                new Slot
                                {
                                    Name   = "submissionTime",
                                    Values = new List <string> {
                                        "20041225235050"
                                    }
                                }
                            },
                            ExternalIdentifiers = new List <ExternalIdentifier>
                            {
                                new ExternalIdentifier
                                {
                                    Id                   = "urn:xdskit:com:c7ptmx37tfbcwy8ky7e",
                                    RegistryObject       = "urn:xdskit:com:SubmissionSet:c7ptmx37tfbcwy8ky7d",
                                    IdentificationScheme = "urn:xdskit:com:c7ptmx37tfbcwy8ky7f",
                                    Value                = "T-77012382",
                                    Name                 = XmlUtil.LocalString("XDSSubmissionSet.patientId")
                                }
                            }
                        },
                        new RegistryPackage
                        {
                            Id   = "urn:xdskit:com:Folder:c7ptmx37tfbcwy8ky7g",
                            Name = XmlUtil.LocalString("Progress Notes")
                        }
                    },
                    Associations = new List <Association>
                    {
                        new Association
                        {
                            Id = "urn:xdskit:com:c7ptmx37tfbcwy8ky7h",
                            AssociationType = AssociationType.HasMember,
                            Source          = "urn:xdskit:com:SubmissionSet:c7ptmx37tfbcwy8ky7d",
                            Target          = "urn:xdskit:com:Folder:c7ptmx37tfbcwy8ky7g"
                        },
                        new Association
                        {
                            Id = "urn:xdskit:com:c7ptmx37tfbcwy8ky7i",
                            AssociationType = AssociationType.HasMember,
                            Source          = "urn:xdskit:com:Folder:c7ptmx37tfbcwy8ky7g",
                            Target          = "urn:xdskit:com:Document:c7ptmx37tfbcwy8ky7b"
                        },
                        new Association
                        {
                            Id = "urn:xdskit:com:c7ptmx37tfbcwy8ky7j",
                            AssociationType = AssociationType.HasMember,
                            Source          = "urn:xdskit:com:SubmissionSet:c7ptmx37tfbcwy8ky7d",
                            Target          = "urn:xdskit:com:Document:c7ptmx37tfbcwy8ky7b",
                            Slots           = new List <Slot>
                            {
                                new Slot
                                {
                                    Name   = "SubmissionSetStatus",
                                    Values = new List <string> {
                                        "Original"
                                    }
                                }
                            }
                        }
                    }
                }
            };

            return(request);
        }
 /// <summary>
 /// Upload metadata for a document.
 /// </summary>
 /// <param name="pcehrHeader">PCEHR header.</param>
 /// <param name="submitObjectsRequest">Metadata.</param>
 /// <returns>Response.</returns>
 public RegistryResponseType UploadDocumentMetadata(CommonPcehrHeader pcehrHeader, SubmitObjectsRequest submitObjectsRequest)
 {
     return(documentRegistryClient.UploadDocumentMetadata(pcehrHeader.GetHeader <PCEHRHeader>(), submitObjectsRequest));
 }
        /// <summary>
        /// Builds the serializable Document Set Submission Request.
        /// </summary>
        /// <returns>Nothing</returns>
        public void BuildMetaData(string submissionSetId, DocumentPackage package)
        {
            // Add the set of document to the list of documents in this set.
            _documents = new List <Document>(package.Documents.Count);
            foreach (DocumentMetadata doc in package.Documents)
            {
                // Add each document to the list of documents in this set.
                _documents.Add(new Document(XD_PANDR_DEFAULT_DOCUMENTID + (package.Documents.IndexOf(doc) + 1), doc.DocumentBytes));
            }

            _submitObjectsRequest = new SubmitObjectsRequest();
            //Add ExtrinsicObject for each document
            foreach (DocumentMetadata doc in package.Documents)
            {
                _submitObjectsRequest.RegistryObjectList.ExtrinsicObjects.Add(StaticHelpers.CreateDocumentEntry(doc, XD_PANDR_DEFAULT_DOCUMENTID + (package.Documents.IndexOf(doc) + 1)));
            }


            //Add SubmissionSet Registry Package
            StaticHelpers.AddSubmissionSet(_submitObjectsRequest, package, submissionSetId);
            _submitObjectsRequest.RegistryObjectList.Classifications.Add(
                new ClassificationType(null, XD_PANDR_DEFAULT_SUBMISSIONSETID,
                                       GlobalValues.XDSSubmissionSetUUID, null, "class01", null, null));

            SlotType[] slots    = null;
            string[]   slotVals = null;
            // Associate Documens and Submission Set
            foreach (Document doc in _documents)
            {
                slots       = new SlotType[1];
                slotVals    = new string[1];
                slotVals[0] = "Original";
                slots[0]    = new SlotType(SlotNameType.SubmissionSetStatus, slotVals);

                _submitObjectsRequest.RegistryObjectList.Associations.Add(new AssociationType(AssociationKind.HasMember,
                                                                                              XD_PANDR_DEFAULT_SUBMISSIONSETID, doc.Id, "assoc" + doc.Id, slots));
            }

            /*
             *
             * try
             * {
             *      XmlSerializer ser = new XmlSerializer(typeof(SubmitObjectsRequest));
             *      MemoryStream ms = new MemoryStream();
             *      ser.Serialize(ms, _submitObjectsRequest);
             *      ms.Position = 0;
             *      StreamReader requestReader = new StreamReader(ms);
             *      string requestString = requestReader.ReadToEnd();
             *      ms.Close();
             *
             *      // This removes <?xml version="1.0"?> from the top of the requestString
             *      if (requestString.StartsWith("<?")) requestString = requestString.Substring(requestString.IndexOf("?>") + 2).Trim();
             *
             *      this.XmlMessage.LoadXml(requestString);
             * }
             * catch (Exception ex)
             * {
             *      Console.WriteLine("Exception caught while serializing XML: " + ex.Message);
             * }
             */
        }
Esempio n. 11
0
        /// <summary>
        /// Uploads document metadata.
        /// </summary>
        /// <param name="pcehrHeader">PCEHR header.</param>
        /// <param name="submitObjectsRequest">Metadata.</param>
        /// <returns>Response.</returns>
        internal RegistryResponseType UploadDocumentMetadata(PCEHRHeader pcehrHeader, SubmitObjectsRequest submitObjectsRequest)
        {
            var timestamp = new timestampType()
            {
                created = DateTime.Now
            };

            var signatureContainer = new signatureContainerType();

            return(documentRegistryClient.DocumentRegistry_RegisterDocumentSetb(timestamp, ref signatureContainer, pcehrHeader, submitObjectsRequest));
        }
Esempio n. 12
0
        /// <summary>
        /// creates a submission set containing a document.
        /// The metadata consists of
        ///   (O) Description
        ///   Slots
        ///     (R2)authorInstitution
        ///     (O) authorPerson
        ///     (R2)authorRole
        ///     (R2)authorSpecialty
        ///     (R) submissionTime
        ///   ExternalIdentifiers
        ///     (R) patientId
        ///     (R) sourceId
        ///     (R) uniqueId
        ///   Classifications
        ///     (R) contentTypeCode
        /// </summary>
        /// <param name="sor">SubmitObjectsRequest corresponding to the new document submission</param>
        public static void AddSubmissionSet(SubmitObjectsRequest sor, DocumentPackage package, string submissionSetId)
        {
            string[] eiScheme         = new string[3];
            string[] eiValue          = new string[3];
            string[] eiName           = new string[3];
            string[] eiId             = new string[3];
            string[] eiRegistryObject = new string[3];
            eiScheme[0] = GlobalValues.XDSSubmissionSet_patientIdUUID;
            eiScheme[1] = GlobalValues.XDSSubmissionSet_sourceIdUUID;
            eiScheme[2] = GlobalValues.XDSSubmissionSet_uniqueIdUUID;
            eiValue[0]  = package.PatientId.ToCx(); //patID  //TODO change these OIDS
            eiValue[1]  = package.SourceId;         // "1.3.6.1.4.1.21367.2005.3.11";
            eiValue[2]  = package.UniqueId;         // "1.3.6.1.4.1.21367.2005.3.11.14"

            eiName[0] = "XDSSubmissionSet.patientId";
            eiName[1] = "XDSSubmissionSet.sourceId";
            eiName[2] = "XDSSubmissionSet.uniqueId";

            eiId[0] = "eiId101";
            eiId[1] = "eiId102";
            eiId[2] = "eiId103";

            eiRegistryObject[0] = submissionSetId;
            eiRegistryObject[1] = submissionSetId;
            eiRegistryObject[2] = submissionSetId;

            SlotType[] slots  = new SlotType[2];
            string[]   values = new string[1];
            values[0] = Extensions.ToHL7Date(DateTime.Now);
            //HL7Time(XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Utc));
            slots[0] = new SlotType(SlotNameType.submissionTime, values);

            values = new string[package.IntendedRecipients.Count];
            for (int i = 0; i < package.IntendedRecipients.Count; i++)
            {
                values[i] = package.IntendedRecipients[i].ToXONXCNXTN();
            }
            slots[0] = new SlotType(SlotNameType.intendedRecipient, values);

            // Create Classification for authorPerson and authorInstitution:
            // <rim:Classification id="cl08" classificationScheme="urn:uuid:a7058bb9-b4e4-4307-ba5b-e3f0ab85e12d" classifiedObject="SubmissionSet01">
            //    <rim:Slot name="authorPerson">
            //        <rim:ValueList>
            //            <rim:Value>Sherry Dopplemeyer</rim:Value>
            //        </rim:ValueList>
            //    </rim:Slot>
            //    <rim:Slot name="authorInstitution">
            //        <rim:ValueList>
            //            <rim:Value>Cleveland Clinic</rim:Value>
            //            <rim:Value>Berea Community</rim:Value>
            //        </rim:ValueList>
            //    </rim:Slot>
            // </rim:Classification>

            ClassificationType[] classifications = new ClassificationType[2];
            SlotType[]           cSlots          = new SlotType[3];
            values = new string[package.Author.Institutions.Count];
            for (int i = 0; i < package.Author.Institutions.Count; i++)
            {
                values[i] = package.Author.Institutions[i].ToXON();
            }
            cSlots[0] = new SlotType(SlotNameType.authorInstitution, values);

            values    = new string[1];
            values[0] = package.Author.Person.ToXCN();
            cSlots[1] = new SlotType(SlotNameType.authorPerson, values);

            values    = new string[1];
            values[0] = package.Author.TelecomAddress.ToXTN();
            cSlots[2] = new SlotType(SlotNameType.authorTelecom, values);

            classifications[0] = new ClassificationType(GlobalValues.XDSSubmissionSet_authorDescriptionUUID,
                                                        submissionSetId, null, null, "cl01", null, cSlots);

            cSlots             = new SlotType[1];
            values             = new string[1];
            values[0]          = package.ContentTypeCode.Scheme;
            cSlots[0]          = new SlotType(SlotNameType.codingScheme, values);
            classifications[1] = new ClassificationType(GlobalValues.XDSSubmissionSet_contentTypeCodeUUID,
                                                        submissionSetId, null, package.ContentTypeCode.Code, "cl02",
                                                        package.ContentTypeCode.Label, cSlots);

            sor.RegistryObjectList.RegistryPackages.Add(
                new RegistryPackageType(submissionSetId, "Submission Set",
                                        eiScheme, eiValue, eiId, eiRegistryObject, eiName, slots, classifications, RegistryEntryStatus.Submitted));
        }