Parse XML doc (Clinical Document Architecture-CDA,HL7 standard) using Everest Framework
Asked Answered
Q

3

12

I am trying to parse some clinical information from XML file that is standardized to HL7 V3 CDA standard .

Xml file :

 <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
<document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://www.accessdata.fda.gov/spl/schema/spl.xsd">
   <id root="9bcbe9e4-a541-4ee7-856d-1aacf7f7298f"/>
   <code code="34391-3" codeSystem="2.16.840.1.113883.6.1" displayName="HUMAN PRESCRIPTION DRUG LABEL"/>
   <title>Amlodipine Besylate 5 mg</title>
   <effectiveTime value="20101104"/>
   <setId root="9abf41f1-66f9-4be4-a6d7-6c9aa0d5d387"/>
   <versionNumber value="448"/>
   <author>
      <time/>
      <assignedEntity>
         <representedOrganization>
            <id extension="831276758" root="1.3.6.1.4.1.519.1"/>
            <name>Lake Erie Medical DBA Quality Care Products LLC</name>
            <assignedEntity>
               <assignedOrganization>
                  <assignedEntity>
                     <assignedOrganization>
                        <id extension="831276758" root="1.3.6.1.4.1.519.1"/>
                        <name>Lake Erie Medical DBA Quality Care Products LLC</name>
                     </assignedOrganization>
                     <performance>
                        <actDefinition>
                           <code code="C73607" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="relabel"/>
                        </actDefinition>
                     </performance>
                  </assignedEntity>
                  <assignedEntity>
                     <assignedOrganization>
                        <id extension="915628612" root="1.3.6.1.4.1.519.1"/>
                        <name>Alkem Laboratories Limited</name>
                     </assignedOrganization>
                     <performance>
                        <actDefinition>
                           <code code="C43360" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="manufacture"/>
                        </actDefinition>
                     </performance>
                  </assignedEntity>
               </assignedOrganization>
            </assignedEntity>
         </representedOrganization>
      </assignedEntity>
   </author>
   <component>
      <structuredBody>
         <component>
            <section>
               <id root="5e90ce61-5d11-4acf-8a5b-f99cb10b60f4"/>
               <code code="48780-1" codeSystem="2.16.840.1.113883.6.1" displayName="SPL listing data elements section"/>
               <effectiveTime value="20101103"/>
               <subject>
                  <manufacturedProduct>
                     <manufacturedProduct>
                        <code code="35356-059" codeSystem="2.16.840.1.113883.6.69"/>
                        <name>Amlodipine Besylate <suffix/>
                        </name>
                        <formCode code="C42998" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="TABLET"/>
                        <asEntityWithGeneric>
                           <genericMedicine>
                              <name>Amlodipine Besylate </name>
                           </genericMedicine>
                        </asEntityWithGeneric>
                        <asEquivalentEntity classCode="EQUIV">
                           <code code="C64637" codeSystem="2.16.840.1.113883.3.26.1.1"/>
                           <definingMaterialKind>
                              <code code="51991-667" codeSystem="2.16.840.1.113883.6.69"/>
                           </definingMaterialKind>
                        </asEquivalentEntity>
                        <ingredient classCode="ACTIB">
                           <quantity>
                              <numerator value="5" unit="mg"/>
                              <denominator value="1" unit="1"/>
                           </quantity>
                           <ingredientSubstance>
                              <code code="864V2Q084H" codeSystem="2.16.840.1.113883.4.9"/>
                              <name>AMLODIPINE BESYLATE</name>
                              <activeMoiety>
                                 <activeMoiety>
                                    <code code="1J444QC288" codeSystem="2.16.840.1.113883.4.9"/>
                                    <name>AMLODIPINE</name>
                                 </activeMoiety>
                              </activeMoiety>
                           </ingredientSubstance>
                        </ingredient>
                        <ingredient classCode="IACT">
                           <ingredientSubstance>
                              <code code="OP1R32D61U" codeSystem="2.16.840.1.113883.4.9"/>
                              <name>CELLULOSE, MICROCRYSTALLINE</name>
                           </ingredientSubstance>
                        </ingredient>
                        <ingredient classCode="IACT">
                           <ingredientSubstance>
                              <code code="L11K75P92J" codeSystem="2.16.840.1.113883.4.9"/>
                              <name>ANHYDROUS DIBASIC CALCIUM PHOSPHATE</name>
                           </ingredientSubstance>
                        </ingredient>
                        <ingredient classCode="IACT">
                           <ingredientSubstance>
                              <code code="5856J3G2A2" codeSystem="2.16.840.1.113883.4.9"/>
                              <name>SODIUM STARCH GLYCOLATE TYPE A POTATO</name>
                           </ingredientSubstance>
                        </ingredient>
                        <ingredient classCode="IACT">
                           <ingredientSubstance>
                              <code code="ETJ7Z6XBU4" codeSystem="2.16.840.1.113883.4.9"/>
                              <name>SILICON DIOXIDE</name>
                           </ingredientSubstance>
                        </ingredient>
                        <ingredient classCode="IACT">
                           <ingredientSubstance>
                              <code code="70097M6I30" codeSystem="2.16.840.1.113883.4.9"/>
                              <name>MAGNESIUM STEARATE</name>
                           </ingredientSubstance>
                        </ingredient>
                        <asContent>
                           <quantity>
                              <numerator value="90" unit="1">
                                 <translation code="C48477" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="BOTTLE"/>
                              </numerator>
                              <denominator value="1"/>
                           </quantity>
                           <containerPackagedProduct>
                              <code code="35356-059-90" codeSystem="2.16.840.1.113883.6.69"/>
                              <formCode code="C43173" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="BOTTLE, PLASTIC"/>
                           </containerPackagedProduct>
                        </asContent>
                     </manufacturedProduct>
                     <subjectOf>
                        <marketingAct>
                           <code code="C53292" codeSystem="2.16.840.1.113883.3.26.1.1"/>
                           <statusCode code="active"/>
                           <effectiveTime>
                              <low value="20101104"/>
                           </effectiveTime>
                        </marketingAct>
                     </subjectOf>
                     <subjectOf>
                        <approval>
                           <id extension="ANDA078925" root="2.16.840.1.113883.3.150"/>
                           <code code="C73584" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="ANDA"/>
                           <author>
                              <territorialAuthority>
                                 <territory>
                                    <code code="USA" codeSystem="2.16.840.1.113883.5.28"/>
                                 </territory>
                              </territorialAuthority>
                           </author>
                        </approval>
                     </subjectOf>
                     <subjectOf>
                        <characteristic classCode="OBS">
                           <code code="SPLCOLOR" codeSystem="2.16.840.1.113883.1.11.19255"/>
                           <value code="C48325" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="white" xsi:type="CE">
                              <originalText>off whit</originalText>
                           </value>
                        </characteristic>
                     </subjectOf>
                     <subjectOf>
                        <characteristic classCode="OBS">
                           <code code="SPLSCORE" codeSystem="2.16.840.1.113883.1.11.19255"/>
                           <value value="1" xsi:type="INT"/>
                        </characteristic>
                     </subjectOf>
                     <subjectOf>
                        <characteristic classCode="OBS">
                           <code code="SPLSHAPE" codeSystem="2.16.840.1.113883.1.11.19255"/>
                           <value code="C48348" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="ROUND" xsi:type="CE">
                              <originalText>flat faced beveled edge</originalText>
                           </value>
                        </characteristic>
                     </subjectOf>
                     <subjectOf>
                        <characteristic classCode="OBS">
                           <code code="SPLIMPRINT" codeSystem="2.16.840.1.113883.1.11.19255"/>
                           <value xsi:type="ST">210</value>
                        </characteristic>
                     </subjectOf>
                     <subjectOf>
                        <characteristic classCode="OBS">
                           <code code="SPLSIZE" codeSystem="2.16.840.1.113883.1.11.19255"/>
                           <value unit="mm" value="8" xsi:type="PQ"/>
                        </characteristic>
                     </subjectOf>
                     <consumedIn>
                        <substanceAdministration>
                           <routeCode code="C38288" codeSystem="2.16.840.1.113883.3.26.1.1" displayName="ORAL"/>
                        </substanceAdministration>
                     </consumedIn>
                  </manufacturedProduct>
               </subject>
            </section>
         </component>
         <component>
            <section>
               <id root="7a474776-2650-40ff-9a8e-22710ed363e4"/>
               <code code="34089-3" codeSystem="2.16.840.1.113883.6.1" displayName="DESCRIPTION SECTION"/>
               <text>
                  <linkHtml href=""/>11 DESCRIPTION<br/>Amlodipine besylate is the besylate salt of amlodipine, a long-acting calcium 
channel blocker.<br/>Amlodipine besylate is chemically described as 
3-Ethyl-5-methyl(±)-2- [(2-aminoethoxy)methyl]-4-(2-chlorophenyl)-1,4-dihydro-6- 
methyl-3,5-pyridinedicarboxylate, monobenzenesulphonate. Its empirical formula 
is C<sub>20</sub>H<sub>25</sub>ClN<sub>2</sub>O<sub>5</sub>•C<sub>6</sub>H<sub>6</sub>O<sub>3</sub>S, and its structural formula is<br/>
                  <br/>.<br/>
               </text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="82d89368-0995-45fd-85a1-e8cdc0edab97"/>
               <code code="34090-1" codeSystem="2.16.840.1.113883.6.1" displayName="CLINICAL PHARMACOLOGY SECTION"/>
               <text>
                  <linkHtml href=""/>12 CLINICAL PHARMACOLOGY<br/>
                  <linkHtml href=""/>12.1 Mechanism of Action<br/>Amlodipine is a dihydropyridine calcium antagonist (calcium ion antagonist or 
slow-channel blocker)

                  <br/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>
                  <br/>
                  <linkHtml href=""/>12.2 Pharmacodynamics<br/>
                  <br/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>
                  <br/>
                  <linkHtml href=""/>12.3 .<br/>
                  <br/>

                  <linkHtml href=""/>12.4 Pediatric Patients<br/>Sixty-two hypertensive patients aged 6 to 17 years received doses of amlodipine 
between 1.25 mg and 20 mg. Weight-adjusted clearance and volume of distribution 
were similar to values in adults.<linkHtml href=""/>
                  <linkHtml href=""/>
                  <br/>
               </text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="09519e8a-96a2-405a-bae4-e9a4857c7d43"/>
               <code code="34067-9" codeSystem="2.16.840.1.113883.6.1" displayName="INDICATIONS &amp; USAGE SECTION"/>
               <text>
                  <linkHtml href="#section-"/>
                  <linkHtml href="#section-"/>
                  <linkHtml href="#section-"/>
                  <linkHtml href="#section-"/>
                  <linkHtml href="#section-"/>
                  <linkHtml href=""/>
                  <br/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>agents.<linkHtml href=""/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>1.2 Coronary Artery Disease (CAD)<br/>
                  <content styleCode="underline">Chronic Stable Angina</content>
                  <br/>Amlodipine besylate tablets are 
indicated for the symptomatic treatment of chronic stable angina. Amlodipine 
besylate tablets may be used alone or in combination with other antianginal 
agents.<br/>
                  <br/>
                  <content styleCode="underline">Vasospastic Angina (Prinzmetal's or Variant 
Angina)</content>
                  <br/>Amlodipine besylate tablets are indicated for the treatment 
of confirmed or suspected vasospastic angina. Amlodipine besylate tablets may be 
used as monotherapy or in combination with other antianginal 
agents.<br/>
                  <br/>
                  <content styleCode="underline">Angiographically Documented CAD</content>
                  <br/>e<br/>
                  <content styleCode="underline"/>
                  <br/>
                  <br/>
               </text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="82dcdac1-1a49-4c95-b33d-593a0d7588ae"/>
               <code code="34070-3" codeSystem="2.16.840.1.113883.6.1" displayName="CONTRAINDICATIONS SECTION"/>
               <text>
                  <linkHtml href=""/>4 CONTRAINDICATIONS<br/>Amlodipine besylate 
tablets are contraindicated in patients with known sensitivity to amlodipine.<linkHtml href=""/>
                  <linkHtml href=""/>
               </text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="d30aa4d2-e468-4ced-9774-7cacb077bbff"/>
               <code code="34084-4" codeSystem="2.16.840.1.113883.6.1" displayName="ADVERSE REACTIONS SECTION"/>
               <text>
                  <linkHtml href=""/>6 ADVERSE REACTIONS<linkHtml href=""/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>6.1 
are headache and edema.</text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="1d54e787-afa3-4931-b9e7-bc3bb021ef15"/>
               <code code="34088-5" codeSystem="2.16.840.1.113883.6.1" displayName="OVERDOSAGE SECTION"/>
               <text>
                  <linkHtml href=""/>10 OVERDOSAGE<br/>Overdosage might be expected to cause excessive peripheral vasodilation with 
marked hypotension and possibly a reflex tachycardia. In humans, experience with 
intentional overdosage of amlodipine is limited.<br/>
                 <sup>2 </sup>basis) caused a marked peripheral vasodilation and 
hypotension.<br/>
                  <br/>If.<linkHtml href=""/>
                  <linkHtml href=""/>
                  <br/>
               </text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="706986ac-49d5-4b07-a2b0-d5f75ef311bb"/>
               <code code="34068-7" codeSystem="2.16.840.1.113883.6.1" displayName="DOSAGE &amp; ADMINISTRATION SECTION"/>
               <text>
                  <linkHtml href="#section-"/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>2.1 Adults<br/>
<content styleCode="italics">[see <linkHtml href="#Section_6">Adverse Reactions (6)</linkHtml>].</content>
                  <br/>
                  <content styleCode="italics"/>
                  <br/>The recommended dose range for patients with 
coronary artery disease is 5–10 mg once daily. In clinical studies, the majority 
of patients required 10 mg <content styleCode="italics">[see <linkHtml href="#Section_14.4">Clinical Studies (14.4)</linkHtml>]</content>. <br/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>
                  <linkHtml href=""/>2.2 Children<br/>The effective antihypertensive 
oral dose in pediatric patients ages 6–17 years is 2.5 mg to 5 mg once daily. 
Doses in excess of 5 mg daily have not been studied in pediatric patients <content styleCode="italics">[see <linkHtml href="#Section_12.4">Clinical Pharmacology (12.4)</linkHtml>, <linkHtml href="#Section_14.1">Clinical Studies (14.1)</linkHtml>]</content>.</text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="39f80cec-5fea-490c-a8e9-e4acf96649a4"/>
               <code code="34069-5" codeSystem="2.16.840.1.113883.6.1" displayName="HOW SUPPLIED SECTION"/>
               <text>
                  <linkHtml href=""/>16 HOW SUPPLIED/STORAGE AND HANDLING<br/>
                  <linkHtml href=""/><linkHtml href=""/>
                  <linkHtml href=""/>
                  <br/>
                  <br/>
                  <linkHtml href=""/>
of 90<linkHtml href=""/>
                  <linkHtml href=""/>
                  <br/>
                  <br/>
                  <linkHtml href=""/>16.3 10 mg Tablets<br/>Amlodipine besylate 
tablets 10 mg (amlodipine besylate equivalent to 10 mg of amlodipine per tablet) 
are white to off white, round, flat-faced, beveled edge tablets ‘209’ debossed 
on one side and plain on the other side and supplied as follows:<br/>NDC 
51991-668-90 Bottle of 90<br/>
                  <br/>
                  <br/>
               </text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="3211934b-8588-4bca-bc0d-16d89c2152a1"/>
               <code code="42230-3" codeSystem="2.16.840.1.113883.6.1" displayName="SPL PATIENT PACKAGE INSERT SECTION"/>
               <text>
                  <linkHtml href=""/>PATIENT PACKAGE INSERT<br/>
                  <content styleCode="bold">
                     <content styleCode="bold">AMLODIPINE BESYLATE TABLETS 2.5 mg, 5 mg, and 
10 mg</content>
                  </content>
                  <br/>
                  <br/>
                  <content styleCode="bold">What is amlodipine besylate?</content>
                  <br/>
                  <br/>
                  <content styleCode="bold">High Blood Pressure (hypertension)</content>
                  <br/>
                  <br/>
                  <content styleCode="bold">Angina</content>
                  <br/>Angina is a pain or discomfort that keeps 
coming back when part of your heart does not get enough blood. Angina feels like 
a pressing or squeezing pain, usually in your chest under the breastbone. 
Sometimes you can feel it in your shoulders, arms, neck, jaws, or back. 
Amlodipine besylate <content styleCode="bold"/>can relieve this pain.<br/>
                  <br/>
                  <content styleCode="bold">Who should not use amlodipine besylate?</content>
                  <br/>Do not use 
amlodipine besylate if you are allergic to amlodipine (the active ingredient in 
amlodipine besylate tablets), or to the inactive ingredients. Your doctor or 
pharmacist can give you a list of these ingredients.<br/>
                  <br/>
                  <content styleCode="bold">What should I tell my doctor before taking amlodipine besylate? 
</content>
                  <br/>Tell your doctor about any prescription and non-prescription 
medicines you are taking, including natural or herbal remedies.<br/>Tell your 
doctor if you: 
<list listType="unordered" ID="ie2a63721-85e3-4273-8fd9-48d010179dd1">
                     <item>ever had heart disease</item>
                     <item>ever had liver problems</item>
                     <item>are pregnant, or plan to become pregnant. Your doctor will decide if 
amlodipine besylate is the best treatment for you.</item>
                     <item>are breast-feeding. Do not breast-feed while taking amlodipine besylate. You 
can stop breast-feeding or take a different medicine.</item>
                  </list>
                  <br/>
                  <content styleCode="bold">How should I take amlodipine besylate?</content>
                  <list listType="unordered" ID="i1c95c31f-953d-4661-8c5a-317bbc09c96a">
                     <item></item>
                     <item>It may be easier to take your dose if you do it at the same time every day, 
such as with breakfast or dinner, or at bedtime. Do not take more than one dose 
of amlodipine besylate at a time.</item>
                     <item>If you miss a dose, take it as soon as you remember. Do not take amlodipine 
besylate if it has been more than 12 hours since you missed your last dose. Wait 
and take the next dose at your regular time.</item>
                     <item>
                        <content styleCode="bold">Other medicines:</content> You can use nitroglycerin and 
amlodipine besylate together. If you take nitroglycerin for angina, don't stop 
taking it while you are taking amlodipine besylate.</item>
                     <item>While you are taking amlodipine besylate, do not stop taking your other 
prescription medicines, including any other blood pressure medicines, without 
talking to your doctor.</item>
                     <item>If you took too much amlodipine besylate, call your doctor or Poison Control 
Center, or go to the nearest hospital emergency room right away.</item>
                  </list>
                  <br/>
                  <content styleCode="bold">What should I avoid while taking amlodipine besylate?</content>
                  <br/>
                  <list listType="unordered" ID="i7c271fb0-d554-40ae-8bcd-752af260043b">
                     <item>
                        <content styleCode="bold">Do not</content> breast-feed. It is not known if amlodipine 
besylate will pass through your milk.</item>
                     <item>
                        <content styleCode="bold">Do not</content> start any new prescription or 
non-prescription medicines or supplements, unless you check with your doctor 
first.</item>
                  </list>
                  <br/>
                  <content styleCode="bold">What are the possible side effects of amlodipine 
besylate?</content>
                  <br/>Amlodipine besylate may cause the following side effects. 
Most side effects are mild or moderate:
<list listType="unordered" ID="i83cb3d3a-99ac-4f4f-8d0b-3bfcb5e29f15">
                     <item>headache</item>
                     <item>swelling of your legs or ankles</item>
                     <item>tiredness, extreme sleepiness</item>
                     <item>stomach pain, nausea</item>
                     <item>dizziness</item>
                     <item>flushing (hot or warm feeling in your face)</item>
                     <item>arrhythmia (irregular heartbeat)</item>
                     <item>heart palpitations (very fast heartbeat)</item>
                  </list>
                  <br/>It is rare, but when you first start taking amlodipine besylate or increase your 
dose, you may have a heart attack or your angina may get worse. If that happens, 
call your doctor right away or go directly to a hospital emergency room.<br/>
                  <br/>Tell your doctor if you are concerned about any side effects you experience. 
These are not all the possible side effects of amlodipine besylate. For a 
complete list, ask your doctor or pharmacist.<br/>
                  <br/>
                  <content styleCode="bold">How do I store amlodipine besylate tablets?</content>
                  <br/>
                  <br/>
                  <content styleCode="bold">General advice about amlodipine besylate</content>
                  <br/><br/>
                  <br/>You can ask your pharmacist or doctor for information about amlodipine 
besylate.<br/>
                  <br/>
                  <br/>
               </text>
               <effectiveTime value="20101104"/>
            </section>
         </component>
         <component>
            <section>
               <id root="3c8a283d-3b42-41e7-aacb-ea355b5d948e"/>
               <code code="51945-4" codeSystem="2.16.840.1.113883.6.1" displayName="PACKAGE LABEL.PRINCIPAL DISPLAY PANEL"/>
               <text>
                  <paragraph>Image of label<renderMultiMedia referencedObject="MM554"/>
                  </paragraph>
               </text>
               <effectiveTime value="20101104"/>
               <component>
                  <observationMedia classCode="OBS" moodCode="EVN" ID="MM554">
                     <text>Image of label</text>
                     <value xsi:type="ED" mediaType="image/jpeg">
                        <reference value="amlodipine besylate 5 mg alkem laboratories limited.jpg"/>
                     </value>
                  </observationMedia>
               </component>
            </section>
         </component>
      </structuredBody>
   </component>
</document>

What is the best library to do this? I have found that Everest Framework (http://everest.codeplex.com/) is grate for such kind of work but I did not find any examples how to achieve this. Does anybody used this framework before?I am looking for an example where I can deserialize this xml file into ClinicalDocument class. Thanks

Queue answered 24/6, 2015 at 17:24 Comment(6)
Well speaking about simple XMl parsing using C# it's simple , but speaking about standardized XML data it's different.There might be some libraries that can help me to parse such data.Queue
LINQ to XML is one such library. There's nothing particularly challenging about the XML fragments you posted. Are you confusing XML with HTML? They are related but separate things. I'm not sure what you mean by "simple XML" vs "standardized XML" - XML is standardized.Pharaoh
You should be able to parse with XPath notation as long as you know the structure of the CDA model, also need to keep in mind the schema of the CDA and whether the CDA conforms to an on the wire or off the wire schemaDeferment
@tim I mean that I need simple text with <p> instead of <paragraph>, as a result I need <img> tag instead of renderMultiMedia and so on.Queue
Then your looking at using an XSLT transform, you can use an XSLT to apply a transformation of the HL7/CDA/XML to output HTMLDeferment
@gunner2607 Thanks, I am going to take a look to XSLT transform, any live examples ?Queue
C
5

To do this you can use the following code:

using(XmlStateReader xr = new XmlStateReader(XmlReader.Create(@"C:\path-to-file.xml")))
{
    var fmtr = new XmlIts1Formatter();
    fmtr.ValidateConformance = false;
    fmtr.GraphAides.Add(new ClinicalDocumentDatatypeFormatter());
    var parseResult = fmtr.Parse(xr, typeof(ClinicalDocument));
    // There is a variable called structure which will contain your
    var cda = parseResult.Structure as ClinicalDocument;
} 

Not sure if that will help you transform, but that will read a CDA into a ClinicalDocument class.

Chemosphere answered 1/7, 2015 at 15:58 Comment(4)
I am getting warning that objects are not supported.And cda becoming nullQueue
It looks like your XML file doesn't have a correct root element. I imagine the error you're getting is something along the lines of "element 'document' not supported". I think a CDA is supposed to start with <ClinicalDocument. You can do one of two things, either change the root element of your instance to ClinicalDocument or, you can adapt example 86 from the developer's guide to read a different root element (see ParseString as an example of how to do this in R2SerializationHelper.cs in test project)Chemosphere
Can you please provide a link of guide?I can't find it on google.Thanks a lot.Queue
The guide is available through Lulu here : lulu.com/shop/justin-fyfe/… , it is an e-book and mostly covers HL7v3 messaging, not an abundance on CDA per se (though the datatypes and overriding RMIM stuff are very good references and very applicable). Were you able to solve the "element not supported" exception?Chemosphere
T
12

I am assuming you're using visual studios. If so this is the easiest solution in my opinion: 1.Create a c# class. 2.Then Copy all of your XML (from one of your CDA's). 3.Then go to that class you created before and go to Edit>paste special>Paste XML as Classes.

This will create a class for you based off that XML. Then all you have to do to parse any xml (CDA) like one you copied, is deserialize it into that class type and it will create an object which you can pull all the information out of. I hope that helps!

EDIT: http://blog.codeinside.eu/2014/09/08/Visual-Studio-2013-Paste-Special-JSON-And-Xml/

enter image description here

Deserialize example: (presuming the class you created is called CDA)

string path = "The Path of the XML file";

XmlSerializer superCereal = new XmlSerializer(typeof(CDA));
StreamReader sr = new StreamReader(path);
CDA doc= (CDA)superCereal.Deserialize(sr);
sr.Close();

Now the object doc will have all the information of the xml inside of it.

Topper answered 24/6, 2015 at 17:44 Comment(7)
hmm, sounds so great, yes I am using visual studio but it's first time when I hear about such tool , can you please provide some link about this functionality , or how I can find this on google?Queue
It this what you mean msdn.microsoft.com/en-us/library/hh371548(v=vs.110).aspx ?Queue
I added a link with a picture.Topper
Thanks I will try to use this tool to see what happens.Queue
This is a really nice tip, been using VS2013 for 2 years now and never noticed this feature. One thing to be wary of, if you're using this for anything more than quick and dirty: your sample data is not guaranteed to cover the entire possible schema of your source data.Lammers
Wow, I was thinking of using xsd.exe to for this but it is so simple. I never noticed this feature till today. Thanks a lot.Midinette
I added a Deserialize example as well.Topper
C
5

To do this you can use the following code:

using(XmlStateReader xr = new XmlStateReader(XmlReader.Create(@"C:\path-to-file.xml")))
{
    var fmtr = new XmlIts1Formatter();
    fmtr.ValidateConformance = false;
    fmtr.GraphAides.Add(new ClinicalDocumentDatatypeFormatter());
    var parseResult = fmtr.Parse(xr, typeof(ClinicalDocument));
    // There is a variable called structure which will contain your
    var cda = parseResult.Structure as ClinicalDocument;
} 

Not sure if that will help you transform, but that will read a CDA into a ClinicalDocument class.

Chemosphere answered 1/7, 2015 at 15:58 Comment(4)
I am getting warning that objects are not supported.And cda becoming nullQueue
It looks like your XML file doesn't have a correct root element. I imagine the error you're getting is something along the lines of "element 'document' not supported". I think a CDA is supposed to start with <ClinicalDocument. You can do one of two things, either change the root element of your instance to ClinicalDocument or, you can adapt example 86 from the developer's guide to read a different root element (see ParseString as an example of how to do this in R2SerializationHelper.cs in test project)Chemosphere
Can you please provide a link of guide?I can't find it on google.Thanks a lot.Queue
The guide is available through Lulu here : lulu.com/shop/justin-fyfe/… , it is an e-book and mostly covers HL7v3 messaging, not an abundance on CDA per se (though the datatypes and overriding RMIM stuff are very good references and very applicable). Were you able to solve the "element not supported" exception?Chemosphere
D
1

You will need to create an XSLT that can be used to apply a transformation of the CDA to output the HTML you require

Deferment answered 24/6, 2015 at 17:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.