Esempio n. 1
0
        public static AphpDocument CreateAphpDocument(CdaSource source)
        {
            // *** Creates the APHP document ***

            AphpDocument aphp = new AphpDocument();

            // *** Set id ***
            Guid tempGuid = new Guid(source.DocumentId);

            aphp.DocumentId = tempGuid.ToString();

            // *** Create Record Target Section ***
            aphp.RecordTarget = CdaSectionFactory.CreateRecordTarget(source.VprData.Demographics);

            // *** Add provider organization to record target ***
            aphp.RecordTarget.ProviderOrganization = CdaSectionFactory.CreateProviderOrganization(source.VprData.Demographics, source.ProviderOrganizationPhone);

            // *** Create Device Author ***
            // TODO: Skip device author...?
            //aphp.DeviceAuthor = new CdaDeviceAuthor();
            //aphp.DeviceAuthor.AssignedAuthoringDevice.ManufacturerModelName = source.ManufacturerModelName;
            //aphp.DeviceAuthor.AssignedAuthoringDevice.SoftwareName = source.SoftwareName;

            // *** Create Author ***
            aphp.Author = CdaSectionFactory.CreateAuthor(source.VprData);

            // *** Information Recipient ***
            aphp.Recipient              = new CdaRecipient();
            aphp.Recipient.FirstName    = source.Options.IntendedRecipientFirstName;
            aphp.Recipient.LastName     = source.Options.IntendedRecipientLastName;
            aphp.Recipient.Organization = source.Options.IntendedRecipientOrganization;

            // *** Participants ***
            aphp.Participants = CdaSectionFactory.CreateParticipants(source.VprData);

            // *** Custodian ***
            aphp.Custodian = CdaSectionFactory.CreateCustodian(aphp.RecordTarget.ProviderOrganization);

            // *** Documentation Of ***
            aphp.DocumentationOf = CdaSectionFactory.CreateDocumentationOf();

            // *** Chief Complaint ***
            aphp.ChiefComplaint = CdaSectionFactory.CreateChiefComplaintSection(source.Observations);

            // *** History of Present Illness ***
            aphp.HistoryOfPresentIllness = CdaSectionFactory.CreatePresentIllnessSection(source.Observations);

            // *** History of Past Illness ***
            ValueSet vs;

            if (source.ValueSets.TryGetValue(ValueSetType.HistoryOfPastIllness, out vs))
            {
                aphp.HistoryOfPastIllness = CdaSectionFactory.CreatePastIllnessSection(source.Observations, (HistoryOfPastIllnessValueSet)vs);
            }

            // *** Coded History of Infection ***
            if (source.ValueSets.TryGetValue(ValueSetType.HistoryOfInfection, out vs))
            {
                aphp.CodedHistoryOfInfection = CdaSectionFactory.CreateHistoryOfInfectionSection(source.Observations, (HistoryOfInfectionValueSet)vs);
            }

            // *** Allergies ***
            aphp.Allergies = CdaSectionFactory.CreateAllergiesSection(source.VprData.Reactions);

            CdaAllergy latexAllergy = CdaObservationFactory.CreateLatexAllergy(source.Observations);

            if (latexAllergy != null)
            {
                aphp.Allergies.Allergies.Add(latexAllergy);
            }

            // *** Pregnancy History ***
            aphp.PregnancyHistorySection = CdaSectionFactory.CreatePregnancyHistorySection(source.Observations, source.Patient.Pregnant, source.Pregnancies);

            // *** Coded Social History ***
            aphp.SocialHistory = CdaSectionFactory.CreateSocialHistorySection(source.Observations);

            // *** Coded Family Medical History ***
            if (source.ValueSets.TryGetValue(ValueSetType.AntepartumFamilyHistory, out vs))
            {
                aphp.FamilyMedicalHistory = CdaSectionFactory.CreateFamilyHistorySection(source.Observations, vs);
            }

            // *** Review of Systems (+ Menstrual History) ***
            if (source.ValueSets.TryGetValue(ValueSetType.MenstrualHistory, out vs))
            {
                aphp.ReviewOfSystems = CdaSectionFactory.CreateReviewOfSystemsSection(source.Observations, vs);
            }

            // *** Coded Physical Exam ***
            aphp.PhysicalExam = CdaSectionFactory.CreatePhysicalExamSection(source.Observations);

            aphp.PhysicalExam.VitalSigns = CdaSectionFactory.CreateVitalsSubSection(source.VprData);

            return(aphp);
        }