/// <summary>
        /// Creates and Hydrates an Subject Of Care demonstrating its usage with multiple CDA Libraries
        ///
        /// Note: the data used within this method is intended as a guide and should be replaced.
        /// </summary>
        /// <returns>A Hydrated SubjectOfCare</returns>
        public IParticipationSubjectOfCare PopulateSubjectOfCare()
        {
            IParticipationSubjectOfCare genericSubjectOfCare = BaseCDAModel.CreateSubjectOfCare();

            HydrateSubjectofCare(genericSubjectOfCare, false);

            //The requirement to instantiate the objects with the factory ensures that the correct implementations
            //of each interface are instantiated; e.g. that the correct content and context are created.
            var specialistLetter = new SpecialistLetter(DocumentStatus.Interim)
            {
                SCSContext = SpecialistLetter.CreateSCSContext()
            };

            specialistLetter.SCSContext.SubjectOfCare = genericSubjectOfCare;

            //The requirement to instantiate the objects with the factory ensures that the correct implementations
            //of each interface are instantiated; e.g. that the correct content and context are created.
            var dischargeSummary = new EDischargeSummary(DocumentStatus.Interim)
            {
                SCSContext = EDischargeSummary.CreateSCSContext()
            };

            dischargeSummary.SCSContext.SubjectOfCare = genericSubjectOfCare;

            return(genericSubjectOfCare);
        }
        /// <summary>
        /// Creates and Hydrates an SubjectofCare
        /// Note: the data used within this method is intended as a guide and should be replaced.
        /// </summary>
        /// <returns>A Hydrated SubjectofCare</returns>
        public static void HydrateSubjectofCare(IParticipationSubjectOfCare subjectOfCare, bool mandatoryOnly)
        {
            var participant = BaseCDAModel.CreateParticipantForSubjectOfCare();

            // Subject of Care > Participant > Person or Organisation or Device > Person
            var person = BaseCDAModel.CreatePersonForSubjectOfCare();

            participant.UniqueIdentifier = Guid.NewGuid();

            // Subject of Care > Participant > Person or Organisation or Device > Person > Person Name
            var name1 = BaseCDAModel.CreatePersonName();

            name1.FamilyName = "Grant";
            name1.GivenNames = new List <string> {
                "Sally", "Wally"
            };
            name1.Titles = new List <string> {
                "Miss"
            };
            name1.NameUsages = new List <NameUsage> {
                NameUsage.Legal
            };

            person.PersonNames = new List <IPersonName> {
                name1
            };

            // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Sex
            person.Gender = Gender.Female;

            // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Date of Birth Detail >
            // Date of Birth
            person.DateOfBirth = new ISO8601DateTime(DateTime.Now.AddYears(-57));

            // Subject of Care > Participant > Entity Identifier
            person.Identifiers = new List <Identifier>
            {
                BaseCDAModel.CreateHealthIdentifier(HealthIdentifierType.IHI, "8003604444567894")
            };

            var address1 = BaseCDAModel.CreateAddress();

            address1.AddressPurpose    = AddressPurpose.Residential;
            address1.AustralianAddress = BaseCDAModel.CreateAustralianAddress();

            address1.AustralianAddress.UnstructuredAddressLines = new List <string> {
                "1 Clinician Street"
            };
            address1.AustralianAddress.SuburbTownLocality = "Nehtaville";
            address1.AustralianAddress.State           = AustralianState.NSW;
            address1.AustralianAddress.PostCode        = "5555";
            address1.AustralianAddress.DeliveryPointId = 32568931;

            participant.Addresses = new List <IAddress> {
                address1
            };

            person.IndigenousStatus = IndigenousStatus.NeitherAboriginalNorTorresStraitIslanderOrigin;

            if (!mandatoryOnly)
            {
                // Subject of Care > Participant > Address


                // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Indigenous Status


                // Subject of Care > Participant > Electronic Communication Detail
                var coms1 = BaseCDAModel.CreateElectronicCommunicationDetail(
                    "0345754566",
                    ElectronicCommunicationMedium.Telephone,
                    ElectronicCommunicationUsage.WorkPlace);
                var coms2 = BaseCDAModel.CreateElectronicCommunicationDetail(
                    "*****@*****.**",
                    ElectronicCommunicationMedium.Email,
                    ElectronicCommunicationUsage.WorkPlace);

                participant.ElectronicCommunicationDetails = new List <ElectronicCommunicationDetail> {
                    coms1, coms2
                };



                person.DateOfBirthCalculatedFromAge = true;
                person.DateOfBirthAccuracyIndicator = new DateAccuracyIndicator(true, true, true);
                person.Age = 54;
                person.AgeUnitOfMeasure = AgeUnitOfMeasure.Year;

                person.AgeAccuracyIndicator = true;
                person.BirthPlurality       = 3;
                person.BirthOrder           = 2;

                // Subject of Care > Participant > Entitlement
                var entitlement1 = BaseCDAModel.CreateEntitlement();
                entitlement1.Id               = BaseCDAModel.CreateMedicareNumber(MedicareNumberType.MedicareCardNumber, "1234567881");
                entitlement1.Type             = EntitlementType.MedicareBenefits;
                entitlement1.ValidityDuration = BaseCDAModel.CreateInterval("1", TimeUnitOfMeasure.Year);

                var entitlement2 = BaseCDAModel.CreateEntitlement();
                entitlement2.Id               = BaseCDAModel.CreateMedicareNumber(MedicareNumberType.MedicareCardNumber, "1234567881");
                entitlement2.Type             = EntitlementType.MedicareBenefits;
                entitlement2.ValidityDuration = BaseCDAModel.CreateInterval("1", TimeUnitOfMeasure.Year);

                participant.Entitlements = new List <Entitlement> {
                    entitlement1, entitlement2
                };
            }

            participant.Person        = person;
            subjectOfCare.Participant = participant;
        }
        /// <summary>
        /// Creates and Hydrates an SubjectofCare
        /// Note: the data used within this method is intended as a guide and should be replaced.
        /// </summary>
        /// <returns>A Hydrated SubjectofCare</returns>
        public static void HydrateSubjectofCare(IParticipationSubjectOfCare subjectOfCare, bool mandatoryOnly)
        {
            var participant = BaseCDAModel.CreateParticipantForSubjectOfCare();

            // Subject of Care > Participant > Person or Organisation or Device > Person
            var person = BaseCDAModel.CreatePersonForSubjectOfCare();

            // Subject of Care > Participant > Address
            var address = BaseCDAModel.CreateAddress();

            address.AustralianAddress = BaseCDAModel.CreateAustralianAddress();
            participant.Addresses     = new List <IAddress> {
                address, address
            };
            //address.AddressAbsentIndicator = AddressAbsentIndicator.NotIndicated;
            //participant.Addresses = new List<IAddress> { address };

            // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Sex
            person.Gender = Gender.Male;

            // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Date of Birth Detail >
            // Date of Birth
            person.DateOfBirth = new ISO8601DateTime(DateTime.Now.AddYears(-57));

            // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Indigenous Status
            person.IndigenousStatus = IndigenousStatus.NeitherAboriginalNorTorresStraitIslanderOrigin;

            // Subject of Care > Participant > Entity Identifier
            person.Identifiers = new List <Identifier>
            {
                BaseCDAModel.CreateHealthIdentifier(HealthIdentifierType.IHI, "8003608666701594"),
                BaseCDAModel.CreateMedicalRecordNumber("123456", "1.2.3.4", "Croydon GP Centre"),

                // NOTE : ONLY 11 digit Individual Medicare Card Number's is permitted in the Entity Identifier
                BaseCDAModel.CreateIndividualMedicareNumber("59501704511"),
            };

            // Subject of Care > Participant > Person or Organisation or Device > Person > Person Name
            var name1 = BaseCDAModel.CreatePersonName();

            name1.FamilyName = "Harding";

            var name2 = BaseCDAModel.CreatePersonName();

            name2.FamilyName = "Harding";

            person.PersonNames = new List <IPersonName> {
                name1, name2
            };

            if (!mandatoryOnly)
            {
                address.AddressPurpose = AddressPurpose.Residential;

                name1.GivenNames = new List <string> {
                    "Frank", "Troy"
                };
                name1.Titles = new List <string> {
                    "Mr"
                };
                name1.NameUsages = new List <NameUsage> {
                    NameUsage.Legal
                };

                name2.GivenNames = new List <string> {
                    "Frank", "Tobie"
                };
                name2.Titles = new List <string> {
                    "Mr"
                };
                name2.NameUsages = new List <NameUsage> {
                    NameUsage.Legal
                };

                // Subject of Care > Participant > Electronic Communication Detail
                var coms1 = BaseCDAModel.CreateElectronicCommunicationDetail(
                    "0345754566",
                    ElectronicCommunicationMedium.Telephone,
                    ElectronicCommunicationUsage.WorkPlace);

                var coms2 = BaseCDAModel.CreateElectronicCommunicationDetail(
                    "*****@*****.**",
                    ElectronicCommunicationMedium.Email,
                    ElectronicCommunicationUsage.WorkPlace);

                participant.ElectronicCommunicationDetails = new List <ElectronicCommunicationDetail> {
                    coms1, coms2
                };

                address.AustralianAddress.UnstructuredAddressLines = new List <string> {
                    "1 Clinician Street"
                };
                address.AustralianAddress.SuburbTownLocality = "Nehtaville";
                address.AustralianAddress.State    = AustralianState.NSW;
                address.AustralianAddress.PostCode = "5555";

                person.DateOfBirthCalculatedFromAge = true;
                person.DateOfBirthAccuracyIndicator = new DateAccuracyIndicator(true, true, true);
                person.Age = 54;
                person.AgeUnitOfMeasure = AgeUnitOfMeasure.Year;

                person.AgeAccuracyIndicator = true;
                person.BirthPlurality       = 3;
                person.BirthOrder           = 2;

                // DateOfDeath & DateOfDeathAccuracyIndicator is not permitted in ACI so set to null in AdvanceCareInformationSample.cs.
                person.DateOfDeath = new ISO8601DateTime(DateTime.Now, ISO8601DateTime.Precision.Day);
                person.DateOfDeathAccuracyIndicator = new DateAccuracyIndicator(true, true, true);
                person.SourceOfDeathNotification    = SourceOfDeathNotification.Relative;

                person.CountryOfBirth = Country.Australia;
                person.StateOfBirth   = AustralianState.QLD;

                var mothersOriginalFamilyName = BaseCDAModel.CreatePersonName();
                mothersOriginalFamilyName.FamilyName = "Jones";

                // Subject of Care > Participant > Person or Organisation or Device > Person > Mothers Original Family Name
                person.MothersOriginalFamilyName = mothersOriginalFamilyName;

                // Subject of Care > Participant > Entitlement
                var entitlement1 = BaseCDAModel.CreateEntitlement();
                entitlement1.Id               = BaseCDAModel.CreateMedicareNumber(MedicareNumberType.MedicareCardNumber, "1234567881");
                entitlement1.Type             = EntitlementType.MedicareBenefits;
                entitlement1.ValidityDuration = BaseCDAModel.CreateHigh(new ISO8601DateTime(DateTime.Now.AddMonths(15), ISO8601DateTime.Precision.Day));

                var entitlement2 = BaseCDAModel.CreateEntitlement();
                entitlement2.Id               = BaseCDAModel.CreateMedicareNumber(MedicareNumberType.MedicareCardNumber, "1234567881");
                entitlement2.Type             = EntitlementType.MedicareBenefits;
                entitlement2.ValidityDuration = BaseCDAModel.CreateHigh(new ISO8601DateTime(DateTime.Now.AddMonths(15), ISO8601DateTime.Precision.Day));

                participant.Entitlements = new List <Entitlement> {
                    entitlement1, entitlement2
                };
            }
            else
            {
                address.AddressAbsentIndicator = AddressAbsentIndicator.NoFixedAddressIndicator;
            }

            participant.Person        = person;
            subjectOfCare.Participant = participant;
        }
Esempio n. 4
0
        /// <summary>
        /// Create the subject of care from information in the HL7 V2 message.
        /// </summary>
        /// <param name="message">The HL7 V2 message.</param>
        /// <returns></returns>
        internal static IParticipationSubjectOfCare CreateSubjectOfCare(HL7GenericMessage message)
        {
            IParticipationSubjectOfCare subjectOfCare = BaseCDAModel.CreateSubjectOfCare();

            var pid = message.PatientIdentification;

            var participant = BaseCDAModel.CreateParticipantForSubjectOfCare();

            // Subject of Care > Participant > Person or Organisation or Device > Person
            var person = BaseCDAModel.CreatePersonForSubjectOfCare();

            // Subject of Care > Participant > Address
            var hl7Addresses = pid.PatientAddress;

            if (hl7Addresses != null && hl7Addresses.Length > 0)
            {
                participant.Addresses = new List <IAddress>();

                for (int x = 0; x < hl7Addresses.Length; x++)
                {
                    participant.Addresses.Add(GetAustralianAddress(hl7Addresses[x]));
                }
            }

            // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Sex
            if (pid.Sex?.identifier != null)
            {
                person.Gender = GetGender(pid.Sex.identifier);
            }

            // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Date of Birth Detail >
            // Date of Birth
            if (pid.DateTimeOfBirth != null && pid.DateTimeOfBirth.TimestampValue.HasValue)
            {
                person.DateOfBirth = new ISO8601DateTime(pid.DateTimeOfBirth.TimestampValue.Value);
            }

            // Subject of Care > Participant > Person or Organisation or Device > Person > Demographic Data > Indigenous Status
            if (pid.Race != null && pid.Race.Length > 0)
            {
                IndigenousStatus indigenousStatus;
                if (!EnumHelper.TryGetEnumValue <IndigenousStatus, NameAttribute>(a => a.Code == pid.Race[0].identifier,
                                                                                  out indigenousStatus))
                {
                    throw new ArgumentException("No matching IndigenousStatus value found");
                }

                person.IndigenousStatus = indigenousStatus;
            }
            else
            {
                person.IndigenousStatus = IndigenousStatus.NotStatedOrInadequatelyDescribed;
            }

            // Subject of Care > Participant > Person or Organisation or Device > Person > Person Name
            if (pid.PatientName != null && pid.PatientName.Length > 0)
            {
                person.PersonNames = new List <IPersonName>();

                for (int x = 0; x < pid.PatientName.Length; x++)
                {
                    person.PersonNames.Add(GetPersonName(pid.PatientName[x]));
                }
            }

            // Identifier
            if (pid.PatientIdentifierList != null && pid.PatientIdentifierList.Length > 0)
            {
                foreach (var identifier in pid.PatientIdentifierList)
                {
                    if (identifier.assigningauthority.namespaceID == "AUSHIC" && identifier.identifiertypecode == "NI")
                    {
                        person.Identifiers = new List <Identifier>
                        {
                            BaseCDAModel.CreateHealthIdentifier(HealthIdentifierType.IHI, identifier.ID)
                        };
                    }
                }
            }

            participant.Person        = person;
            subjectOfCare.Participant = participant;

            return(subjectOfCare);
        }