Ejemplo n.º 1
0
        /// <summary>
        /// Creates an extrinsic object type.
        /// </summary>
        /// <param name="mimeType">Type of the MIME.</param>
        /// <param name="name">The name.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="slots">The slots.</param>
        /// <param name="classifications">The classifications.</param>
        /// <param name="externalIds">The external ids.</param>
        /// <returns>Returns the created extrinsic object type.</returns>
        public static ExtrinsicObjectType CreateExtrinsicObject(string mimeType, string name, XdsGuidType objectType, SlotType1[] slots, ClassificationType[] classifications, ExternalIdentifierType[] externalIds)
        {
            var retVal = new ExtrinsicObjectType
            {
                id         = $"urn:uuid:{Guid.NewGuid().ToString()}",
                objectType = objectType.ToString(),
                mimeType   = mimeType
            };

            if (name != null)
            {
                retVal.Name = new InternationalStringType()
                {
                    LocalizedString = new LocalizedStringType[]
                    {
                        new LocalizedStringType()
                        {
                            value = name
                        }
                    }
                };
            }

            // Slots
            retVal.Slot               = slots;
            retVal.Classification     = classifications;
            retVal.ExternalIdentifier = externalIds;

            if (retVal.Classification != null)
            {
                foreach (var item in retVal.Classification)
                {
                    item.classifiedObject = retVal.id;
                }
            }

            if (retVal.ExternalIdentifier != null)
            {
                foreach (var item in retVal.ExternalIdentifier)
                {
                    item.registryObject = retVal.id;
                }
            }

            return(retVal);
        }
        /// <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
            });
        }
        /// <summary>
        /// Creates an ExtrinsicObjectType from a CDAPackageFile.
        /// </summary>
        /// <param name="packageFile">The CDAPackageFile instance.</param>
        /// <returns>The constructed ExtrinsicObjectType.</returns>
        internal ExtrinsicObjectType CreateExtrinsicObjectType()
        {
            var extrinsicObject     = new ExtrinsicObjectType();
            var classifications     = new List <ClassificationType>();
            var externalIdentifiers = new List <ExternalIdentifierType>();

            extrinsicObject.id         = DocumentId;
            extrinsicObject.mimeType   = "application/zip";
            extrinsicObject.objectType = XDS_DOCUMENT_ENTRY;
            extrinsicObject.status     = DocumentStatus.Approved.GetAttributeValue <CodedValueAttribute, string>(a => a.ConceptCode);

            // General slots
            var generalSlots = new List <SlotType1>();

            generalSlots.Add(CreateSlotType("creationTime", effectiveTime));
            generalSlots.Add(CreateSlotType("languageCode", languageCode));
            if (!string.IsNullOrEmpty(serviceStartTime))
            {
                generalSlots.Add(CreateSlotType("serviceStartTime", serviceStartTime));
            }
            if (!string.IsNullOrEmpty(serviceStopTime))
            {
                generalSlots.Add(CreateSlotType("serviceStopTime", serviceStopTime));
            }
            generalSlots.Add(CreateSlotType("sourcePatientId", cxFormattedPatientId));

            if (isUpdateMetadata)
            {
                generalSlots.Add(CreateSlotType("hash", hash));
                generalSlots.Add(CreateSlotType("size", size.ToString()));
                generalSlots.Add(CreateSlotType("repositoryUniqueId", repositoryId));
            }

            // Name
            extrinsicObject.Name = CreateInternationalStringType(documentTitle);
            if (!String.IsNullOrEmpty(Description))
            {
                extrinsicObject.Description = CreateInternationalStringType(Description);
            }

            // Author - 4 components - Only populate author institution, author person (not role and specialty)
            var authorSlots = new List <SlotType1>();

            authorSlots.Add(CreateSlotType("authorInstitution", xonFormattedOrganisation));
            authorSlots.Add(CreateSlotType("authorPerson", xcnFormattedAuthor));
            if (!String.IsNullOrEmpty(authorSpecialty))
            {
                authorSlots.Add(CreateSlotType("authorSpecialty", authorSpecialty));
            }
            ClassificationType authorClassification = CreateClassificationType(
                "cl01",
                XDS_DOCUMENT_ENTRY_AUTHOR,
                extrinsicObject.id,
                "",
                authorSlots,
                null);

            classifications.Add(authorClassification);

            // ClassCode
            classifications.Add(
                CreateCodedValueClassification(
                    "cl02",
                    extrinsicObject.id,
                    documentTypeCode,
                    documentClassCodeDisplayName,
                    documentTypeCodeSystemName,
                    XDS_DOCUMENT_ENTRY_CLASS_CODE
                    )
                );

            // ConfidentialityCode
            classifications.Add(
                CreateCodedValueClassification(
                    "cl03",
                    extrinsicObject.id,
                    "GENERAL",
                    "NA",
                    "PCEHR_DocAccessLevels",
                    XDS_DOCUMENT_ENTRY_CONFIDENTIALITY_CODE
                    )
                );

            // FormatCode
            classifications.Add(
                CreateCodedValueClassification(
                    "cl04",
                    extrinsicObject.id,
                    formatCode,
                    formatCodeName,
                    formatCodeCodingScheme,
                    XDS_DOCUMENT_ENTRY_FORMAT_CODE
                    )
                );

            // HealthcareFacilityTypeCode
            classifications.Add(
                CreateCodedValueClassification(
                    "cl05",
                    extrinsicObject.id,
                    healthcareFacilityTypeCode,
                    XDS_DOCUMENT_ENTRY_HEALTHCARE_FACILITY_TYPE_CODE
                    )
                );

            // PracticeSettingCode
            classifications.Add(
                CreateCodedValueClassification(
                    "cl06",
                    extrinsicObject.id,
                    practiceSetting,
                    XDS_DOCUMENT_ENTRY_PRACTICE_SETTING_CODE
                    )
                );

            // TypeCode
            classifications.Add(
                CreateCodedValueClassification(
                    "cl07",
                    extrinsicObject.id,
                    documentTypeCode_cl07,
                    documentTypeDisplayName_cl07,
                    documentTypeCodeSystemName_cl07,
                    XDS_DOCUMENT_ENTRY_TYPE_CODE
                    )
                );

            // PatientId
            externalIdentifiers.Add(
                CreateExternalIdentifierType(
                    "ei01",
                    XDS_DOCUMENT_ENTRY_PATIENT_ID,
                    cxFormattedPatientId,
                    extrinsicObject.id,
                    "XDSDocumentEntry.patientId"
                    )
                );

            // UniqueId
            externalIdentifiers.Add(
                CreateExternalIdentifierType(
                    "ei02",
                    XDS_DOCUMENT_ENTRY_UNIQUE_ID,
                    cdaDocumentIdOid,
                    extrinsicObject.id,
                    "XDSDocumentEntry.uniqueId"
                    )
                );

            extrinsicObject.Slot               = generalSlots.ToArray();
            extrinsicObject.Classification     = classifications.ToArray();
            extrinsicObject.ExternalIdentifier = externalIdentifiers.ToArray();

            return(extrinsicObject);
        }
Ejemplo n.º 4
0
        public static ExtrinsicObjectType CreateDocumentEntry(DocumentMetadata document, string documentId)
        {
            ExtrinsicObjectType eo = new ExtrinsicObjectType();

            eo.Id         = documentId;
            eo.ObjectType = GlobalValues.XDSDocumentEntryUUID; //ClassificationNode?
            eo.MimeType   = document.MediaType;

            eo.Name = new InternationalStringType();
            eo.Name.LocalizedString          = new LocalizedStringType[1];
            eo.Name.LocalizedString[0]       = new LocalizedStringType();
            eo.Name.LocalizedString[0].Value = document.Title;

            SlotType[] slots = new SlotType[6];

            string[] values = new string[1];
            values[0] = Extensions.ToHL7Date(document.CreatedOn);

            slots[0] = new SlotType(SlotNameType.creationTime, values);

            values    = new string[1];
            values[0] = document.LanguageCode;
            slots[1]  = new SlotType(SlotNameType.languageCode, values);

            values    = new string[1];
            values[0] = document.SourcePtId.ToCx();
            slots[2]  = new SlotType(SlotNameType.sourcePatientId, values);

            //values = new string[5];
            //values[0] = "PID-3|" + _patID
            //values[1] = "PID-5|" + _patName;
            //values[2] = "PID-7|" + _patDOB;
            //values[3] = "PID-8|" + _patSex;
            //values[4] = "PID-11|" + _patAddress;
            values   = (string[])document.Patient.ToSourcePatientInfoValues(document.SourcePtId);
            slots[3] = new SlotType(SlotNameType.sourcePatientInfo, values);

            values    = new string[1];
            values[0] = document.Size.ToString();
            slots[4]  = new SlotType(SlotNameType.size, values);

            values    = new string[1];
            values[0] = document.Hash.ToString();
            slots[5]  = new SlotType(SlotNameType.hash, values);

            eo.Slot = slots;

            string[] eiScheme       = new string[2];
            string[] eiValue        = new string[2];
            string[] eiName         = new string[2];
            string[] eiId           = new string[2];
            string[] registryObject = new string[2];
            eiScheme[0]       = GlobalValues.XDSDocumentEntry_patientIdUUID;
            eiScheme[1]       = GlobalValues.XDSDocumentEntry_uniqueIdUUID;
            eiValue[0]        = document.PatientID.ToCx();
            eiValue[1]        = document.UniqueId;
            eiName[0]         = "XDSDocumentEntry.patientId";
            eiName[1]         = "XDSDocumentEntry.uniqueId";
            eiId[0]           = documentId + "ei01";
            eiId[1]           = documentId + "ei02";
            registryObject[0] = eo.Id;
            registryObject[1] = eo.Id;

            eo.ExternalIdentifier = CreateEIDs(eiScheme, eiValue, eiName, eiId, registryObject);

            //Create Classifications for authorInstitution/authorPerson, class code, and type code
            eo.Classification = new ClassificationType[7];

            //Author Institution and Author Person
            //<rim:Classification id="cl01" classificationScheme="urn:uuid:93606bcf-9494-43ec-9b4e-a7748d1a838d" classifiedObject="Document01">
            //    <rim:Slot name="authorPerson">
            //        <rim:ValueList>
            //            <rim:Value>Gerald Smitty</rim:Value>
            //        </rim:ValueList>
            //    </rim:Slot>
            //    <rim:Slot name="authorInstitution">
            //        <rim:ValueList>
            //            <rim:Value>Cleveland Clinic</rim:Value>
            //            <rim:Value>Parma Community</rim:Value>
            //        </rim:ValueList>
            //    </rim:Slot>
            //</rim:Classification>
            slots  = new SlotType[3];
            values = new string[document.Author.Institutions.Count];
            for (int i = 0; i < document.Author.Institutions.Count; i++)
            {
                values[i] = document.Author.Institutions[i].ToXON();
            }
            slots[0] = new SlotType(SlotNameType.authorInstitution, values);

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

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

            eo.Classification[0] = new ClassificationType(GlobalValues.XDSDocumentEntry_authorDescriptionUUID,
                                                          eo.Id, null, null, documentId + "cl01", null, slots);

            //Class Code
            slots                = new SlotType[1];
            values               = new string[1];
            values[0]            = document.Class.Scheme;
            slots[0]             = new SlotType(SlotNameType.codingScheme, values);
            eo.Classification[1] = new ClassificationType(GlobalValues.XDSDocumentEntry_classCodeUUID,
                                                          eo.Id, null, document.Class.Code, documentId + "cl02", document.Class.Label, slots);

            //Confidentiality Code
            slots                = new SlotType[1];
            values               = new string[1];
            values[0]            = document.Confidentiality.Scheme;
            slots[0]             = new SlotType(SlotNameType.codingScheme, values);
            eo.Classification[2] = new ClassificationType(GlobalValues.XDSDocumentEntry_confidentialityCodeUUID,
                                                          eo.Id, null, document.Confidentiality.Code, documentId + "cl03", document.Confidentiality.Label, slots);

            //Format Code
            slots                = new SlotType[1];
            values               = new string[1];
            values[0]            = document.FormatCode.Scheme;
            slots[0]             = new SlotType(SlotNameType.codingScheme, values);
            eo.Classification[3] = new ClassificationType(GlobalValues.XDSDocumentEntry_formatCodeUUID,
                                                          eo.Id, null, document.FormatCode.Code, documentId + "cl04",
                                                          document.FormatCode.Label, slots);

            //HealthCare Facility type code
            slots                = new SlotType[1];
            values               = new string[1];
            values[0]            = document.FacilityCode.Scheme;
            slots[0]             = new SlotType(SlotNameType.codingScheme, values);
            eo.Classification[4] = new ClassificationType(GlobalValues.XDSDocumentEntry_healthCareFacilityTypeCodeUUID,
                                                          eo.Id, null, document.FacilityCode.Code, documentId + "cl05",
                                                          document.FacilityCode.Label, slots);

            //Practice Setting Code
            slots                = new SlotType[1];
            values               = new string[1];
            values[0]            = document.PracticeSetting.Scheme;
            slots[0]             = new SlotType(SlotNameType.codingScheme, values);
            eo.Classification[5] = new ClassificationType(GlobalValues.XDSDocumentEntry_practiceSettingCodeUUID,
                                                          eo.Id, null, document.PracticeSetting.Code, documentId + "cl06",
                                                          document.PracticeSetting.Label, slots);

            //Type Code
            slots                = new SlotType[1];
            values               = new string[1];
            values[0]            = document.Type.Scheme;
            slots[0]             = new SlotType(SlotNameType.codingScheme, values);
            eo.Classification[6] = new ClassificationType(GlobalValues.XDSDocumentEntry_typeCodeUUID,
                                                          eo.Id, null, document.Type.Code, documentId + "cl07",
                                                          document.Type.Label, slots);

            return(eo);
        }