예제 #1
0
        protected virtual StrucDocText GetSectionText()
        {
            // *** Create the section text ***

            // **** Narrative + Entries Table ***

            StrucDocText returnVal = new StrucDocText();

            // *** Create list of items ***
            List <object> textItems = new List <object>();

            if (!string.IsNullOrWhiteSpace(this.Narrative))
            {
                // *** Add narrative ***
                StrucDocParagraph narrativeParagraph = new StrucDocParagraph();
                narrativeParagraph.Text = new string[] { this.Narrative };

                textItems.Add(narrativeParagraph);
            }

            // *** Add entries ***
            StrucDocTable entriesTable = this.GetEntriesTable();

            if (entriesTable != null)
            {
                textItems.Add(entriesTable);
            }

            // *** Add any additional text needed ***
            List <object> additionalText = this.GetAdditionalText();

            if (additionalText != null)
            {
                if (additionalText.Count > 0)
                {
                    textItems.AddRange(additionalText);
                }
            }

            returnVal.Items = textItems.ToArray();

            return(returnVal);
        }
예제 #2
0
        private StrucDocText GetObservationTable(List <CdaAllergy> allergies)
        {
            // *** Creates a structured document text object from a list of allergies ***

            StrucDocText returnVal = new StrucDocText();

            // *** Create the table ***
            StrucDocTable tbl = new StrucDocTable();

            // *** Create Header information ***
            tbl.thead             = new StrucDocThead();
            tbl.thead.tr          = new StrucDocTr[] { new StrucDocTr() };
            tbl.thead.tr[0].Items = new StrucDocTh[] {
                new StrucDocTh()
                {
                    Text = new string[] { "Date/Time" }
                },
                new StrucDocTh()
                {
                    Text = new string[] { "Description" }
                },
                new StrucDocTh()
                {
                    Text = new string[] { "Status" }
                }
            };

            // *** Create Body Information ***
            tbl.tbody = new StrucDocTbody[] { new StrucDocTbody() };
            List <StrucDocTr> trList = new List <StrucDocTr>();

            // *** Create a Row for each observation ***
            foreach (CdaAllergy allergy in allergies)
            {
                // *** Create the row ***
                StrucDocTr tr = new StrucDocTr()
                {
                    ID = allergy.ReferenceId
                };

                // *** Create a list of TD ***
                List <StrucDocTd> tdList = new List <StrucDocTd>();

                // *** Add TD's ***
                string allergyDateTime = "";
                if (allergy.EffectiveTime != null)
                {
                    if (allergy.Status == Common.CdaConcernStatus.Actve)
                    {
                        if (allergy.EffectiveTime.Low != null)
                        {
                            if (allergy.EffectiveTime.Low != DateTime.MinValue)
                            {
                                allergyDateTime = allergy.EffectiveTime.Low.ToString();
                            }
                        }
                    }
                    else if (allergy.EffectiveTime.High != null)
                    {
                        if (allergy.EffectiveTime.High != DateTime.MinValue)
                        {
                            allergyDateTime = allergy.EffectiveTime.High.ToString();
                        }
                    }
                }

                tdList.Add(new StrucDocTd()
                {
                    Text = new string[] { allergyDateTime }
                });
                tdList.Add(new StrucDocTd()
                {
                    Text = new string[] { allergy.AllergyText }
                });
                tdList.Add(new StrucDocTd()
                {
                    Text = new string[] { allergy.StatusText }
                });

                tr.Items = tdList.ToArray();

                trList.Add(tr);
            }

            // *** Add rows to body ***
            tbl.tbody[0].tr = trList.ToArray();

            // *** Add a table caption ***
            StrucDocCaption caption = new StrucDocCaption()
            {
                Text = new string[] { "Allergies & Intolerances" }
            };

            tbl.caption = caption;

            // *** Add list of items ***
            List <object> textItems = new List <object>();

            textItems.Add(tbl);

            returnVal.Items = textItems.ToArray();

            return(returnVal);
        }
        /// <summary>
        /// This method creates the narrative for the medications section
        /// </summary>
        /// <param name="medications">IMedicationsSpecialistLetter</param>
        /// <returns>StrucDocText</returns>
        public StrucDocText CreateNarrativeLegacy(IMedicationsSpecialistLetter medications)
        {
            List <List <String> > narrative;
            var strucDocTableList  = new List <StrucDocTable>();
            var narrativeParagraph = new List <StrucDocParagraph>();

            if (medications != null)
            {
                if (medications.MedicationsList != null)
                {
                    var narativeHeader = new List <string>
                    {
                        "Medication",
                        "Directions",
                        "Clinical Indication",
                        "Change Status",
                        "Change Description",
                        "Change Reason",
                        "Comment"
                    };

                    narrative = new List <List <String> >();

                    foreach (var medication in medications.MedicationsList)
                    {
                        string changeStatus;
                        if (medication.ChangeType != null && medication.ChangeType.NullFlavour != null) // because if there is no change status, the fact of whether this is a recommendation or change is irrelevant
                        {
                            changeStatus = "No change";
                        }
                        else
                        {
                            changeStatus = medication.ChangeType != null ? medication.ChangeType.NarrativeText : string.Empty;
                            // if there's no change, or recommendation or change value, we don't say anything about it
                            if (medication.ChangeType != null && (medication.ChangeType.Code != ChangeTypeNctis.Unchanged.GetAttributeValue <NameAttribute, string>(x => x.Code)))
                            {
                                if (!(medication.ChangeStatus != null && medication.ChangeStatus.Code == RecomendationOrChange.TheChangeHasBeenMade.GetAttributeValue <NameAttribute, string>(x => x.Code)))
                                {
                                    changeStatus = "Recommendation: " + changeStatus;
                                }
                            }
                        }

                        var medicationList = new List <String>
                        {
                            medication.Medicine != null ? medication.Medicine.NarrativeText : null,
                            medication.Directions != null ? medication.Directions.NarrativeText : null,
                            medication.ClinicalIndication,
                            changeStatus,
                            !medication.ChangeDescription.IsNullOrEmptyWhitespace() ? medication.ChangeDescription : null,
                            medication.ChangeReason != null ? medication.ChangeReason.NarrativeText : null,
                            !medication.Comment.IsNullOrEmptyWhitespace() ? medication.Comment : null
                        };

                        narrative.Add(medicationList);
                    }

                    StripEmptyColoums(ref narativeHeader, ref narrative, new List <int> {
                        3, 4, 5, 6
                    });

                    strucDocTableList.Add
                    (
                        PopulateTable
                        (
                            "Medications",
                            null,
                            narativeHeader.ToArray(),
                            new string[0],
                            narrative
                        )
                    );
                }

                // Exclusions
                if (medications.ExclusionStatement != null)
                {
                    narrativeParagraph.Add(CreateExclusionStatementNarrative("Medications", medications.ExclusionStatement));
                }
            }

            var strucDocText = new StrucDocText();

            // Structured Tables
            if (strucDocTableList.Any())
            {
                strucDocText.table = strucDocTableList.ToArray();
            }

            // Narrative Paragraph
            if (narrativeParagraph.Any())
            {
                strucDocText.paragraph = narrativeParagraph.ToArray();
            }

            return(strucDocText);
        }
예제 #4
0
        /// <summary>
        /// This method populates an PCML model with either the mandatory sections only, or both
        /// the mandatory and optional sections
        /// </summary>
        /// <param name="mandatorySectionsOnly">mandatorySectionsOnly</param>
        /// <returns>PCML</returns>
        public static Nehta.VendorLibrary.CDA.Common.PCML PopulatePSML_1B(Boolean mandatorySectionsOnly)
        {
            var pharmacySharedMedsList = Nehta.VendorLibrary.CDA.Common.PCML.CreatePCML();

            // Include Logo
            pharmacySharedMedsList.IncludeLogo = true;
            pharmacySharedMedsList.LogoPath    = OutputFolderPath;

            // Set Creation Time
            pharmacySharedMedsList.DocumentCreationTime = new ISO8601DateTime(DateTime.Now);

            #region Setup and populate the CDA context model

            // Setup and populate the CDA context model
            var cdaContext = Nehta.VendorLibrary.CDA.Common.PCML.CreateCDAContext();

            // Document Id
            cdaContext.DocumentId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateOid(), null);

            // Custodian
            cdaContext.Custodian = BaseCDAModel.CreateCustodian();
            GenericObjectReuseSample.HydrateCustodian(cdaContext.Custodian, mandatorySectionsOnly);

            //Optional sections
            if (!mandatorySectionsOnly)
            {
                // Set Id
                cdaContext.SetId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateOid(), null);
                // CDA Context Version
                cdaContext.Version = "1";

                // Legal authenticator
                cdaContext.LegalAuthenticator = BaseCDAModel.CreateLegalAuthenticator();
                GenericObjectReuseSample.HydrateAuthenticator(cdaContext.LegalAuthenticator, mandatorySectionsOnly);

                // Information Recipients
                cdaContext.InformationRecipients = new List <IParticipationInformationRecipient>();

                var recipient1 = BaseCDAModel.CreateInformationRecipient();
                GenericObjectReuseSample.HydrateRecipient(recipient1, RecipientType.Primary, mandatorySectionsOnly);

                var recipient2 = BaseCDAModel.CreateInformationRecipient();
                GenericObjectReuseSample.HydrateRecipient(recipient2, RecipientType.Secondary, mandatorySectionsOnly);

                cdaContext.InformationRecipients.AddRange(new[] { recipient1, recipient2 });
            }

            pharmacySharedMedsList.CDAContext = cdaContext;
            #endregion

            #region Setup and Populate the SCS Context model
            // Setup and Populate the SCS Context model

            pharmacySharedMedsList.SCSContext = Nehta.VendorLibrary.CDA.Common.PCML.CreateSCSContext();

            var authorHealthcareProvider = BaseCDAModel.CreateAuthorHealthcareProvider();
            GenericObjectReuseSample.HydrateAuthorHealthcareProvider(authorHealthcareProvider, mandatorySectionsOnly);
            pharmacySharedMedsList.SCSContext.Author = authorHealthcareProvider;

            //Cannot use as a device : prohibited by CORE Level One
            //pharmacyCuratedMedsList.SCSContext.Author = GenericObjectReuseSample.CreateAuthorDevice();

            if (!mandatorySectionsOnly)
            {
                // Context>Encounter>HEALTHCARE FACILITY
                pharmacySharedMedsList.SCSContext.Encounter = new Encounter
                {
                    HealthcareFacility = PopulateHealthcareFacility(mandatorySectionsOnly)
                };
            }

            pharmacySharedMedsList.SCSContext.SubjectOfCare = BaseCDAModel.CreateSubjectOfCare();
            GenericObjectReuseSample.HydrateSubjectofCare(pharmacySharedMedsList.SCSContext.SubjectOfCare, mandatorySectionsOnly);


            IParticipationPersonOrOrganisation person = Nehta.VendorLibrary.CDA.Common.PCML.CreateParticipationPersonOrOrganisation();
            person.Participant        = Nehta.VendorLibrary.CDA.Common.PCML.CreateParticipantPersonOrOrganisation();
            person.Role               = BaseCDAModel.CreateRole(HealthcareFacilityTypeCodes.AgedCareResidentialServices);
            person.Participant.Person = BaseCDAModel.CreatePersonWithOrganisation();


            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.Participant.Person.PersonNames = new List <IPersonName> {
                name1
            };

            // Subject of Care > Participant > Person or Organisation or Device > Person > Identifier
            person.Participant.Person.Identifiers = new List <Identifier>
            {
                BaseCDAModel.CreateHealthIdentifier(HealthIdentifierType.HPII, "8003615833334118")
            };

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

            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;

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

            person.Participant.Person.Organisation = BaseCDAModel.CreateEmploymentOrganisation();

            person.Participant.Person.Organisation           = BaseCDAModel.CreateEmploymentOrganisation();
            person.Participant.Person.Organisation.Name      = "Hay Bill Hospital";
            person.Participant.Person.Organisation.NameUsage = OrganisationNameUsage.Other;

            // New requirement to make address mandatory
            person.Participant.Person.Organisation.Addresses = new List <IAddress> {
                address1
            };

            person.Participant.Person.Organisation.Identifiers = new List <Identifier> {
                BaseCDAModel.CreateHealthIdentifier(HealthIdentifierType.HPIO, "8003620833333789"),
                //BaseCDAModel.CreateIdentifier("SampleAuthority", null, null, "1.2.3.4.5.66666", null)
            };

            if (!mandatorySectionsOnly)
            {
                //populate with full person details

                // 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);

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


                // 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);

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

                // Optional Participants
                pharmacySharedMedsList.SCSContext.Participant = new List <IParticipationPersonOrOrganisation>();
                pharmacySharedMedsList.SCSContext.Participant.Add(person);
            }

            #endregion

            #region Setup and populate the SCS Content model

            // Setup and populate the SCS Content model
            pharmacySharedMedsList.SCSContent = Nehta.VendorLibrary.CDA.Common.PCML.CreateSCSContent();

            //Use Custom Narrative instead of Attachment - 1B
            //pharmacyCuratedMedsList.SCSContent.EncapsulatedData = BaseCDAModel.CreateEncapsulatedData();
            pharmacySharedMedsList.ShowAdministrativeObservationsSection           = false;
            pharmacySharedMedsList.ShowAdministrativeObservationsNarrativeAndTitle = false;

            // Build Narrative
            var sdt = new StrucDocText();

            sdt.table = new[]
            {
                new StrucDocTable
                {
                    caption = new StrucDocCaption {
                        Text = new [] { "Patient History" }
                    },
                    tbody = new [] { new StrucDocTbody
                                     {
                                         tr = new [] { new StrucDocTr {
                                                           td = new [] { AddTd("Allergies"), AddTd("Nil Known") }
                                                       },
                                                       new StrucDocTr {
                                                           td = new [] { AddTd("Diagnosis"), AddTd("CVA, TIA, Hypertension") }
                                                       } }
                                     } }
                },
                new StrucDocTable
                {
                    caption = new StrucDocCaption {
                        Text = new [] { "Medications" }
                    },
                    thead = new StrucDocThead {
                        tr = new [] { new StrucDocTr {
                                          td = new [] { AddTd("Drug", "BoldxColWidthPx200"), AddTd("Direction", "BoldxColWidthPx200"), AddTd("B'fast", "BoldxColWidthPx20"), AddTd("Lunch", "BoldxColWidthPx20"), AddTd("Dinner", "BoldxColWidthPx20"), AddTd("B'time", "BoldxColWidthPx20"), AddTd("Indication", "BoldxColWidthPx200"), AddTd("Special Instructions", "BoldxColWidthPx220") }
                                      } }
                    },
                    tbody = new [] { new StrucDocTbody {
                                         tr = new []
                                         {
                                             new StrucDocTr {
                                                 td = new [] { AddTd("LanoxnPG62.5mcgTb"), AddTd("One on alternate morning"), AddTd("1"), AddTd(""), AddTd(""), AddTd(""), AddTd("Heart rate"), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("Paralgin500mgTb"), AddTd("One four times daily"), AddTd("1"), AddTd("1"), AddTd("1"), AddTd("1"), AddTd("Pain"), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("CandesartanSZ16mg"), AddTd("One in the morning"), AddTd("1"), AddTd(""), AddTd(""), AddTd(""), AddTd("High Blood Pressume"), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("Rispa 0.5mg Tab"), AddTd("One at bedtime"), AddTd(""), AddTd(""), AddTd(""), AddTd("1"), AddTd("Behavioural Disorder"), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("Apo-Rabeprzle20mgTb"), AddTd("One in the morning"), AddTd("1"), AddTd(""), AddTd(""), AddTd(""), AddTd("Barrett's Oesaphagus"), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("Sorbolene Cream"), AddTd("Apply twice daily for dry skin after bath"), AddTd("Ap"), AddTd(""), AddTd("Ap"), AddTd(""), AddTd("Dry Skin"), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("Liquifilm TearsEyDrp"), AddTd("Instill one drop four times daily into both eyes"), AddTd("1"), AddTd("1"), AddTd("1"), AddTd(""), AddTd("Dry Eyes"), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("Keflex 500mg Cap"), AddTd("One three times daily for seven days"), AddTd("1"), AddTd("1"), AddTd("1"), AddTd(""), AddTd(""), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("Coloxyl/SennaTab"), AddTd("One at dinner when necessary if BNO 3/7"), AddTd("1"), AddTd("1"), AddTd("1"), AddTd("1"), AddTd("Constipation"), AddTd("") }
                                             },
                                             new StrucDocTr {
                                                 td = new [] { AddTd("Fosamax70mgTab"), AddTd("One on Thursday morning half an hour before food"), AddTd("1"), AddTd(""), AddTd(""), AddTd(""), AddTd("Asteoporosis"), AddTd("") }
                                             },
                                         }
                                     } }
                }
            };


            // Save Custom Text
            var narrativeOnlyDocument = BaseCDAModel.CreateNarrativeOnlyDocument();
            narrativeOnlyDocument.Title     = "Patient Medication Record";
            narrativeOnlyDocument.Narrative = sdt;

            pharmacySharedMedsList.SCSContent.CustomNarrativePcmlRecord = new List <NarrativeOnlyDocument>();
            pharmacySharedMedsList.SCSContent.CustomNarrativePcmlRecord.Add(narrativeOnlyDocument);

            #endregion


            return(pharmacySharedMedsList);
        }