Ejemplo n.º 1
0
        public override POCD_MT000040Component3 ToPocdComponent()
        {
            POCD_MT000040Component3 returnVal = base.ToPocdComponent();

            if (this.Observations.Count == 0)
            {
                this.Narrative = "(No Data)";
            }

            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            foreach (CdaSimpleObservation obs in this.Observations)
            {
                // *** Create an entry ***
                POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                // *** Create observation ***
                newEntry.Item = obs.ToPocd();

                entryList.Add(newEntry);
            }

            returnVal.section.entry = entryList.ToArray();

            return(returnVal);
        }
        /// <summary>
        /// This example demonstrates how CDA XML can be manipulated programmatically as part of the CDA extensibility feature.
        /// This example shows the inclusion of an attachment in "Requested Service" section of an eReferral, which is not possible within the normal structure
        /// of the eReferral IG. This example demonstrates an additional ED element in an entry, which is then referenced by a custom narrative to render
        /// the attachment.
        ///
        /// The additional ED element can be referenced/rendered from a custom narrative through markup such as:
        /// <renderMultiMedia referencedObject="ID_OF_ATTACHMENT_ELEMENT">
        ///     <caption>Structured Body File</caption>
        /// </renderMultiMedia>
        /// </summary>
        public void AddingAnAttachmentSample()
        {
            // Load original document generated by CDA library
            var xmlDoc = new XmlDocument();

            xmlDoc.Load("CdaExtensionsSample\\CdaExtensions.xml");

            // Example attachment file
            var attachmentFileName = "CdaExtensionsSample\\attachmentFileName.pdf";

            // Create additional entry to describe ED data type containing attachment
            var entry = new POCD_MT000040Entry()
            {
                observationMedia = new POCD_MT000040ObservationMedia()
                {
                    ID = "ID_OF_ATTACHMENT_ELEMENT",
                    id = new[] { new II()
                                 {
                                     root = Guid.NewGuid().ToString()
                                 } },
                    classCode = ActClassObservation.OBS,
                    moodCode  = ActMood.EVN,
                    value     = new ED()
                    {
                        mediaType      = "application/pdf",
                        integrityCheck = CalculateSHA1(File.ReadAllBytes(attachmentFileName)),
                        reference      = new TEL()
                        {
                            value = attachmentFileName
                        }
                    }
                }
            };

            // Serialize data type to XML
            var entryXml = SerializeToXml(entry, "entry");

            // Find location in original CDA document to include extension element
            var nm = new XmlNamespaceManager(xmlDoc.NameTable);

            nm.AddNamespace("cda", "urn:hl7-org:v3");
            var positionToInsert = xmlDoc.SelectSingleNode(
                "cda:ClinicalDocument/cda:component[1]/cda:structuredBody[1]/cda:component[5]/cda:section[1]/cda:component[3]/cda:section[1]/cda:entry[1]",
                nm);

            // Import and include extension element into original CDA document
            var importedNode = xmlDoc.ImportNode(entryXml.DocumentElement, true);

            positionToInsert.ParentNode.InsertAfter(importedNode, positionToInsert);

            // Save extended CDA document
            xmlDoc.Save("CdaExtensionsSample\\CdaExtensionsOutput.xml");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates an entry containing the organizer
        /// </summary>
        /// <returns>A CDA entry object</returns>
        public virtual POCD_MT000040Entry ToPocdOrganizerEntry()
        {
            // *** Create an entry ***
            POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

            // *** Create organizer ***
            POCD_MT000040Organizer organizer = this.ToPocdOrganizer();

            // ***  Add it to entry ***
            if (organizer != null)
            {
                newEntry.Item = organizer;
            }

            return(newEntry);
        }
        //<section classCode="DOCSECT">
        //  <templateId root="1.3.6.1.4.1.19376.1.3.3.2.1"/>
        //  <!-- Example Specialty Section that holds Report Items directly as a Laboratory Report Data Processing Entry-->
        //  <code code="18719-5" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="CHEMISTRY STUDIES"/>
        //  <title>Laboratory Chemistry Results</title>
        //  <text><table>...</table></text>
        //  <entry typeCode="DRIV">
        //      <templateId root="1.3.6.1.4.1.19376.1.3"/>
        //      <act classCode="ACT" moodCode="EVN">
        //          ...
        //      </act>
        //  </entry>
        //</section>

        public virtual POCD_MT000040Component3 ToPocdComponent()
        {
            // *** Creates the basic section ***

            POCD_MT000040Component3 returnVal = new POCD_MT000040Component3();

            returnVal.section = new POCD_MT000040Section();

            // *** Template ID ***
            returnVal.section.templateId = this.TemplateIds.ToPocd();

            // *** Make sure section has an unique ID ***
            returnVal.section.id = new II {
                root = Guid.NewGuid().ToString()
            };

            // *** Code ***
            returnVal.section.code = this.Code.ToCE();

            // *** Title ***
            returnVal.section.title = new ST()
            {
                Text = new string[] { this.SectionTitle }
            };

            // *** Then add the text ***
            returnVal.section.text = this.GetSectionText();

            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            // *** Entries ***
            foreach (var item in this.LabObservations)
            {
                // *** Create an entry ***
                POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                // *** Create observation ***
                newEntry.Item = item.ToPocd();

                entryList.Add(newEntry);
            }

            returnVal.section.entry = entryList.ToArray();

            return(returnVal);
        }
        public override POCD_MT000040Component3 ToPocdComponent()
        {
            POCD_MT000040Component3 returnVal = base.ToPocdComponent();

            //if (this.Observations.Count == 0)
            //    this.Narrative = "(No Data)";

            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            if (this.PrepregnancyWeight != null)
            {
                // *** Create an entry ***
                POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                // *** Create observation ***
                newEntry.Item = this.PrepregnancyWeight.ToPocd();

                entryList.Add(newEntry);
            }

            // *** Create battery ***

            //foreach (CdaBoolObservation obs in this.Observations)
            //{
            //    // *** Create an entry ***
            //    POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

            //    // *** Create observation ***
            //    newEntry.Item = obs.ToPocd();

            //    entryList.Add(newEntry);
            //}

            POCD_MT000040Entry orgEntry = this.Organizer.ToPocdOrganizerEntry();

            if (orgEntry != null)
            {
                entryList.Add(orgEntry);
            }

            returnVal.section.entry = entryList.ToArray();

            return(returnVal);
        }
Ejemplo n.º 6
0
 /// MDHT operation: returns the clinical statement of the given entry
 public Object getClinicalStatement(POCD_MT000040Entry entry)
 {
     if (entry.act != null)
     {
         return(entry.act);
     }
     if (entry.encounter != null)
     {
         return(entry.encounter);
     }
     if (entry.observation != null)
     {
         return(entry.observation);
     }
     if (entry.observationMedia != null)
     {
         return(entry.observationMedia);
     }
     if (entry.organizer != null)
     {
         return(entry.organizer);
     }
     if (entry.procedure != null)
     {
         return(entry.procedure);
     }
     if (entry.regionOfInterest != null)
     {
         return(entry.regionOfInterest);
     }
     if (entry.substanceAdministration != null)
     {
         return(entry.substanceAdministration);
     }
     if (entry.supply != null)
     {
         return(entry.supply);
     }
     return(null);
 }
        // *** Some sample data ***

        //<!-- Social History -->
        //<component>
        //    <section>
        //        <templateId root="2.16.840.1.113883.10.20.1.15"/>
        //        <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.16"/>
        //        <code code="29762-2" displayName="SOCIAL HISTORY"
        //            codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
        //        <title>Social History</title>
        //        <text>Social History </text>
        //    </section>
        //</component>

        //<component>
        //    <section>
        //        <templateId root='11.3.6.1.4.1.19376.1.5.3.1.3.16'/>
        //        <templateId root='11.3.6.1.4.1.19376.1.5.3.1.3.16.1'/>
        //        <id root=' ' extension=' '/> 1805
        //        <code code='29762-2’ displayName='SOCIAL HISTORY'
        //            codeSystem='2.16.840.1.113883.6.1' codeSystemName='LOINC'/>
        //        <text>
        //            Text as described above
        //        </text> 1810
        //    </section>
        //</component>

        public override POCD_MT000040Component3 ToPocdComponent()
        {
            // *** Creates the component data ***

            POCD_MT000040Component3 returnVal;

            if ((string.IsNullOrWhiteSpace(this.Narrative)) && (this.Observations.Count == 0))
            {
                this.Narrative = "(No Data)";
            }

            // *** First create base ***
            returnVal = base.ToPocdComponent();

            // *** Add the text ***
            //returnVal.section.text = this.GetSectionText();

            // *** Create a list of entries ***
            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            // *** Loop through observations ***
            foreach (CdaSimpleObservation observation in this.Observations)
            {
                // *** Create an entry ***
                POCD_MT000040Entry tempEntry = new POCD_MT000040Entry();

                // *** Add a single social observation ***
                tempEntry.Item = observation.ToPocd();

                // *** Add entry to list ***
                entryList.Add(tempEntry);
            }

            // *** Add entry list as array ***
            returnVal.section.entry = entryList.ToArray();

            return(returnVal);
        }
Ejemplo n.º 8
0
        public override POCD_MT000040Component5 ToPocdComponent5()
        {
            POCD_MT000040Component5 returnVal = base.ToPocdComponent5();

            if (this.Observations.Count > 0)
            {
                List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

                foreach (var obs in this.Observations)
                {
                    // *** Create an entry ***
                    POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                    newEntry.Item = obs.ToPocd();

                    entryList.Add(newEntry);
                }

                returnVal.section.entry = entryList.ToArray();
            }

            return(returnVal);
        }
Ejemplo n.º 9
0
        public POCD_MT000040Entry ToPocdEntry()
        {
            // *** Create allergy section ***
            POCD_MT000040Entry entry = new POCD_MT000040Entry();

            // *** Required Allergies and Intolerances Concern element ***
            //entry.templateId = new II[] {
            //    new II { root = "1.3.6.1.4.1.19376.1.5.3.1.4.5.3" },
            //    new II { root = "2.16.840.1.113883.10.20.1.27" },
            //    new II { root = "1.3.6.1.4.1.19376.1.5.3.1.4.5.1" },
            //};

            POCD_MT000040Act act = new POCD_MT000040Act();

            act.id = new II[] { new II {
                                    root = Guid.NewGuid().ToString()
                                } };

            act.classCode = x_ActClassDocumentEntryAct.ACT;
            act.moodCode  = x_DocumentActMood.EVN;

            act.templateId = new II[] {
                new II {
                    root = "2.16.840.1.113883.10.20.1.27"
                },
                new II {
                    root = "1.3.6.1.4.1.19376.1.5.3.1.4.5.1"
                },
                new II {
                    root = "1.3.6.1.4.1.19376.1.5.3.1.4.5.3"
                }
            };

            act.code = new CD()
            {
                nullFlavor = "NA"
            };

            act.statusCode = GetStatusCode();

            List <POCD_MT000040EntryRelationship> entryRelationships = new List <POCD_MT000040EntryRelationship>();


            POCD_MT000040EntryRelationship entryRel = new POCD_MT000040EntryRelationship();

            entryRel.typeCode = x_ActRelationshipEntryRelationship.SUBJ;

            entryRel.inversionInd          = false;
            entryRel.inversionIndSpecified = true;

            POCD_MT000040Observation obs = new POCD_MT000040Observation();

            obs.id = new II[] { new II {
                                    root = Guid.NewGuid().ToString()
                                } };

            obs.classCode  = "OBS";
            obs.moodCode   = x_ActMoodDocumentObservation.EVN;
            obs.templateId = new II[] {
                new II()
                {
                    root = "1.3.6.1.4.1.19376.1.5.3.1.4.5"
                },
                new II()
                {
                    root = "1.3.6.1.4.1.19376.1.5.3.1.4.6"
                },
                new II()
                {
                    root = "2.16.840.1.113883.10.20.1.28"
                }
            };

            obs.negationInd          = this.NegationIndicator;
            obs.negationIndSpecified = true;

            string intoleranceTypeCode = GetIntoleranceType();

            obs.code = new CD()
            {
                code           = intoleranceTypeCode,
                codeSystem     = "2.16.840.1.113883.5.4",
                codeSystemName = "ObservationIntoleranceType"
            };

            obs.text = new ED()
            {
                Text = new string[] { this.Id }
            };

            if (this.Value == null)
            {
                obs.value = new ANY[] { new CD()
                                        {
                                            originalText = new ED()
                                            {
                                                Text = new string[] { this.AllergyText }
                                            }
                                        } }
            }
            ;
            else
            {
                obs.value = new ANY[] { this.Value.ToCD() }
            };

            obs.participant = new POCD_MT000040Participant2[] {
                new POCD_MT000040Participant2()
                {
                    typeCode        = "CSM",
                    participantRole = new POCD_MT000040ParticipantRole()
                    {
                        classCode = "MANU",
                        Item      = new POCD_MT000040PlayingEntity()
                        {
                            classCode = "MMAT",
                            code      = new CE()
                            {
                                code           = this.Id,
                                codeSystemName = CdaCode.VhaSystemName,
                                codeSystem     = CdaCode.VhaSystemId,
                                originalText   = new ED()
                                {
                                    reference = new TEL()
                                    {
                                        value = this.Substance
                                    }
                                }
                            }
                        }
                    }
                }
            };

            if (this.EffectiveTime != null)
            {
                act.effectiveTime = this.EffectiveTime.ToIvlTs();
                obs.effectiveTime = act.effectiveTime;
            }

            obs.statusCode = new CS()
            {
                code = "completed"
            };

            // TODO: Optional entry relationships for reactions
            // TODO: Optional entry relationships for severity

            entryRel.Item = obs;

            entryRelationships.Add(entryRel);

            // *** Add entry relationships ***
            act.entryRelationship = entryRelationships.ToArray();

            // ** Add act ***
            entry.Item = act;

            return(entry);
        }
        /// <summary>
        /// Creates a CDA component containing all required data
        /// </summary>
        /// <returns>A CDA component</returns>
        public override POCD_MT000040Component3 ToPocdComponent()
        {
            // *** Converts this item to raw component ***

            POCD_MT000040Component3 returnVal = base.ToPocdComponent();

            // *** Create a list of entries ***
            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            // *** Loop through observations ***
            foreach (CdaSimpleObservation observation in this.Observations)
            {
                // *** Create an entry ***
                POCD_MT000040Entry tempEntry = new POCD_MT000040Entry();

                // *** Add a single pregnancy observation ***
                tempEntry.Item = observation.ToPocd();

                // *** Add entry to list ***
                entryList.Add(tempEntry);
            }

            // *** Add pregnancy status observation ***
            POCD_MT000040Entry pregEntry = new POCD_MT000040Entry();

            pregEntry.Item = this.PregnancyStatusObservation.ToPocd();
            entryList.Add(pregEntry);

            // *** Add bold to pregnancy status ***
            if (returnVal.section.text.Items != null)
            {
                if (returnVal.section.text.Items.Length > 0)
                {
                    if (returnVal.section.text.Items[0] is StrucDocParagraph)
                    {
                        StrucDocParagraph para = new StrucDocParagraph();

                        StrucDocContent cont = new StrucDocContent()
                        {
                            Text = new string[] { this.Narrative }
                        };
                        cont.styleCode = "Bold";

                        para.Items = new object[] { cont };

                        returnVal.section.text.Items[0] = para;
                    }
                }
            }

            // *** Add pregnancy organizers ***
            foreach (var pregOrg in this.PregnancyOrganizers.Values)
            {
                POCD_MT000040Entry pocdOrgEntry = pregOrg.ToPocdOrganizerEntry();
                if (pocdOrgEntry != null)
                {
                    entryList.Add(pocdOrgEntry);
                }
            }

            // *** Add entry list as array ***
            returnVal.section.entry = entryList.ToArray();

            return(returnVal);
        }
        // *** Sample code from IHE PCC TF ***

        //<entry>
        //    <organizer classCode='CLUSTER' moodCode='EVN'>
        //        <templateId root='2.16.840.1.113883.10.20.1.23'/>
        //        <templateId root='1.3.6.1.4.1.19376.1.5.3.1.4.15'/>
        //        <subject typeCode='SBJ'>
        //            <relatedSubject classCode='PRS'>
        //            <code code='' displayName='' codeSystem='2.16.840.1.113883.5.111' codeSystemName='RoleCode'/>
        //            <subject>
        //                <sdtc:id root='' extension=''/>
        //                <administrativeGenderCode code='' displayName='' codeSystem='' codeSystemName=''/>
        //            </subject>
        //            </relatedSubject>
        //        </subject>
        //        <!-- zero or more participants linking to other relations -->
        //        <participant typeCode='IND'>
        //            <participantRole classCode='PRS'>
        //                <code code='' displayName='' codeSystem='2.16.840.1.113883.5.111' codeSystemName='RoleCode'/>
        //                <playingEntity classCode='PSN'>
        //                    <sdtc:id root='' extension=''/>
        //                </playingEntity>
        //            </participantRole>
        //        </participant>
        //        <!-- one or more entry relationships for family history observations -->
        //        <component typeCode='COMP'>
        //            <observation classCode='OBS' moodCode='EVN'>
        //                <templateId root='2.16.840.1.113883.10.20.1.22'/>
        //            </observation>
        //        </component>
        //    </organizer>
        //</entry>

        public override POCD_MT000040Component3 ToPocdComponent()
        {
            if (this.Observations.Count == 0)
            {
                this.Narrative = "(No Data)";
            }

            // *** Create the component ***
            POCD_MT000040Component3 returnVal = base.ToPocdComponent();

            // *** There is one "organizer" per family member ***

            // *** Add the text ***
            //returnVal.section.text = this.GetSectionText();

            // *** Create list of entries ***
            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            // *** If we don't have anything ***
            if (this.UnknownObservation != null)
            {
                // *** Create an entry ***
                POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                // *** Each entry has one organizer ***
                POCD_MT000040Organizer organizer = new POCD_MT000040Organizer();

                // *** Set the organizer attributes ***
                organizer.classCode = x_ActClassDocumentEntryOrganizer.CLUSTER;
                organizer.moodCode  = "EVN";

                // *** Create the template ids ***
                CdaTemplateIdList ids = new CdaTemplateIdList("2.16.840.1.113883.10.20.1.23", "1.3.6.1.4.1.19376.1.5.3.1.4.15");
                organizer.templateId = ids.ToPocd();

                organizer.statusCode = new CS()
                {
                    code = "completed"
                };

                CdaSubject cdaSubject = new CdaSubject()
                {
                    FamilyMember = Hl7FamilyMember.FamilyMember
                };

                // *** Add the subject to the organizer ***
                organizer.subject = cdaSubject.ToPocdSubject();

                // *** Create a list of components for the observations for this family member ***
                List <POCD_MT000040Component4> componentList = new List <POCD_MT000040Component4>();

                // *** Create a component ***
                POCD_MT000040Component4 component = new POCD_MT000040Component4();

                // *** Add observation to component ***
                component.Item = this.UnknownObservation.ToPocd();

                // *** Add component to list ***
                componentList.Add(component);

                // *** Add component array to organizer ***
                organizer.component = componentList.ToArray();

                // *** Add organizer to entry ***
                newEntry.Item = organizer;

                // *** Add entry to the list ***
                entryList.Add(newEntry);
            }
            else
            {
                // *** Loop through family members ***
                foreach (Hl7FamilyMember key in this.Observations.Keys)
                {
                    // *** Create an entry ***
                    POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                    // *** Each entry has one organizer ***
                    POCD_MT000040Organizer organizer = new POCD_MT000040Organizer();

                    // *** Set the organizer attributes ***
                    organizer.classCode = x_ActClassDocumentEntryOrganizer.CLUSTER;
                    organizer.moodCode  = "EVN";

                    // *** Create the template ids ***
                    CdaTemplateIdList ids = new CdaTemplateIdList("2.16.840.1.113883.10.20.1.23", "1.3.6.1.4.1.19376.1.5.3.1.4.15");
                    organizer.templateId = ids.ToPocd();

                    organizer.statusCode = new CS()
                    {
                        code = "completed"
                    };

                    //// *** Create the subject ***
                    //POCD_MT000040Subject subject = new POCD_MT000040Subject() { typeCode = ParticipationTargetSubject.SBJ, typeCodeSpecified = true };

                    //// *** Create the related subject ***
                    //POCD_MT000040RelatedSubject relatedSubject = new POCD_MT000040RelatedSubject() { classCode = x_DocumentSubject.PRS };

                    //// *** Create the role and add as code ***
                    //CdaRoleCode roleCode = new CdaRoleCode() { FamilyMember = key };
                    //relatedSubject.code = roleCode.ToCe();

                    //// *** Add the related subject to the subject ***
                    //subject.relatedSubject = relatedSubject;

                    CdaSubject cdaSubject = new CdaSubject()
                    {
                        FamilyMember = key
                    };

                    // *** Add the subject to the organizer ***
                    organizer.subject = cdaSubject.ToPocdSubject();

                    // *** Create a list of components for the observations for this family member ***
                    List <POCD_MT000040Component4> componentList = new List <POCD_MT000040Component4>();

                    // *** Loop through all observations for this family member ***
                    foreach (CdaCodeObservation obs in this.Observations[key])
                    {
                        // *** Create a component ***
                        POCD_MT000040Component4 component = new POCD_MT000040Component4();

                        // *** Add observation to component ***
                        component.Item = obs.ToPocd();

                        // *** Add component to list ***
                        componentList.Add(component);
                    }

                    // *** Add component array to organizer ***
                    organizer.component = componentList.ToArray();

                    // *** Add organizer to entry ***
                    newEntry.Item = organizer;

                    // *** Add entry to the list ***
                    entryList.Add(newEntry);
                }
            }

            // *** Add entry list to section ***
            returnVal.section.entry = entryList.ToArray();

            return(returnVal);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Create the component to add to the document
        /// </summary>
        /// <returns></returns>
        public override POCD_MT000040Component3 ToPocdComponent()
        {
            if ((string.IsNullOrWhiteSpace(this.Narrative)) && (this.MenstrualHistoryObservations.Count == 0))
            {
                this.Narrative = "(No Data)";
            }

            POCD_MT000040Component3 returnVal = base.ToPocdComponent();

            // *** And entries ***
            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            // *** Create an entry ***
            POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

            // *** Create menstrual history organizer ***
            POCD_MT000040Organizer organizer = new POCD_MT000040Organizer();

            // *** Set the organizer attributes ***
            //organizer.classCode = x_ActClassDocumentEntryOrganizer.CLUSTER;
            organizer.moodCode   = "EVN";
            organizer.statusCode = new CS()
            {
                code = "active"
            };

            // *** Menstrual History Organizer Code ***
            CdaCode orgCode = new CdaCode()
            {
                Code = "49033-4", CodeSystem = CodingSystem.Loinc, DisplayName = "Menstrual History"
            };

            organizer.code = orgCode.ToCD();

            // *** Create a list of components for the observations ***
            List <POCD_MT000040Component4> componentList = new List <POCD_MT000040Component4>();

            foreach (var item in this.MenstrualHistoryObservations)
            {
                // *** Create a component ***
                POCD_MT000040Component4 component = new POCD_MT000040Component4();

                // *** Add observation to component ***
                component.Item = item.ToPocd();

                // *** Add component to list ***
                componentList.Add(component);
            }

            // *** Add component array to organizer ***
            organizer.component = componentList.ToArray();

            // *** Add organizer to entry ***
            newEntry.Item = organizer;

            // *** Add entry to the list ***
            entryList.Add(newEntry);

            // *** Add entry list to section ***
            returnVal.section.entry = entryList.ToArray();

            return(returnVal);
        }
Ejemplo n.º 13
0
        public List <POCD_MT000040Entry> ToPocdEntryList()
        {
            List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

            if (this.Observations != null)
            {
                foreach (CdaCodeObservation cdaObservation in this.Observations)
                {
                    // *** Create the entry ***
                    POCD_MT000040Entry tempEntry = new POCD_MT000040Entry();

                    // *** Create an act ***
                    POCD_MT000040Act act = new POCD_MT000040Act();

                    act.id = new II[] { new II {
                                            root = Guid.NewGuid().ToString()
                                        } };

                    act.classCode = x_ActClassDocumentEntryAct.ACT;
                    act.moodCode  = x_DocumentActMood.EVN;

                    // *** Add template ids for this act ***
                    CdaTemplateIdList templateIdList =
                        new CdaTemplateIdList(
                            "1.3.6.1.4.1.19376.1.5.3.1.4.5.2",
                            "1.3.6.1.4.1.19376.1.5.3.1.4.5.1",
                            "2.16.840.1.113883.10.20.1.27");

                    act.templateId = templateIdList.ToPocd();

                    // *** No code here ***
                    act.code = new CD()
                    {
                        nullFlavor = "NA"
                    };

                    // *** The concern is active, even though the problem itself may be resolved or inactive ***
                    act.statusCode = new CS()
                    {
                        code = "active"
                    };

                    // *** This concern uses the observation date/time ***
                    //CdaEffectiveTime effTime = new CdaEffectiveTime() { Low = cdaObservation.EffectiveTime };
                    //act.effectiveTime = effTime.ToIvlTs();
                    act.effectiveTime = cdaObservation.EffectiveTime.ToIvlTs();

                    // *** Create entry relationship ***
                    List <POCD_MT000040EntryRelationship> entryRelationships = new List <POCD_MT000040EntryRelationship>();

                    POCD_MT000040EntryRelationship tempEntryRelationship = new POCD_MT000040EntryRelationship();

                    tempEntryRelationship.typeCode              = x_ActRelationshipEntryRelationship.SUBJ;
                    tempEntryRelationship.inversionInd          = false;
                    tempEntryRelationship.inversionIndSpecified = true;

                    // *** Create pocd observation ***
                    POCD_MT000040Observation observation = cdaObservation.ToPocd();

                    // *** Add the observation to the entry relationship ***
                    tempEntryRelationship.Item = observation;

                    // *** Add the entry relationship to the list ***
                    entryRelationships.Add(tempEntryRelationship);

                    // *** Add entry relationships to the act ***
                    act.entryRelationship = entryRelationships.ToArray();

                    // *** Add act to entry ***
                    tempEntry.Item = act;

                    // *** Add entry to list ***
                    entryList.Add(tempEntry);
                }
            }

            return(entryList);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Create the component to add to the document
        /// </summary>
        /// <returns></returns>
        public override POCD_MT000040Component5 ToPocdComponent5()
        {
            if (this.Observations.Count == 0)
            {
                this.Narrative = "(No Data)";
            }

            POCD_MT000040Component5 returnVal = base.ToPocdComponent5();

            // *** Check if we have entries ***
            if (this.Observations.Count > 0)
            {
                // *** And entries ***
                List <POCD_MT000040Entry> entryList = new List <POCD_MT000040Entry>();

                // *** Create an entry ***
                POCD_MT000040Entry newEntry = new POCD_MT000040Entry();

                // *** Create vital signs organizer ***
                POCD_MT000040Organizer organizer = new POCD_MT000040Organizer();

                // *** Set the organizer attributes ***
                organizer.classCode = x_ActClassDocumentEntryOrganizer.CLUSTER;
                organizer.moodCode  = "EVN";

                // *** Template Id's ***
                CdaTemplateIdList orgIds = new CdaTemplateIdList("2.16.840.1.113883.10.20.1.32", "2.16.840.1.113883.10.20.1.35", "1.3.6.1.4.1.19376.1.5.3.1.4.13.1");
                organizer.templateId = orgIds.ToPocd();

                // *** Vital Signs Organizer Code ***
                CdaCode orgCode = new CdaCode()
                {
                    Code = "46680005", CodeSystem = CodingSystem.SnomedCT, DisplayName = "Vital Signs"
                };
                organizer.code = orgCode.ToCD();

                // *** Organizer shall have id ***
                organizer.id = new II[] { new II()
                                          {
                                              root = Guid.NewGuid().ToString()
                                          } };

                organizer.statusCode = new CS()
                {
                    code = "completed"
                };

                // *** Note: Using first observation's date/time ***

                // *** Effective Time of observations ***
                organizer.effectiveTime = this.Observations[0].EffectiveTime.ToIvlTs();

                // *** Create a list of components for the observations ***
                List <POCD_MT000040Component4> componentList = new List <POCD_MT000040Component4>();

                foreach (var item in this.Observations)
                {
                    // *** Create a component ***
                    POCD_MT000040Component4 component = new POCD_MT000040Component4();

                    // *** Add observation to component ***
                    component.Item = item.ToPocd();

                    // *** Add component to list ***
                    componentList.Add(component);
                }

                // *** Add component array to organizer ***
                organizer.component = componentList.ToArray();

                // *** Add organizer to entry ***
                newEntry.Item = organizer;

                // *** Add entry to the list ***
                entryList.Add(newEntry);

                // *** Add entry list to section ***
                returnVal.section.entry = entryList.ToArray();
            }

            return(returnVal);
        }