0

Sorry for the trivial request, but it's a difficult time for me. I have this part of XML code:

<?xml version="1.0" encoding="UTF-8"?>
<ClinicalDocument xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd" xmlns="urn:hl7-org:v3" xmlns:mif="urn:hl7-org:v3/mif" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<structuredBody moodCode="EVN" classCode="DOCBODY">
  <component>
    <section ID="DESCRIPTION">
      <code code="57832-8" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" codeSystemVersion="2.19" />
      <title>DESCRIPTION</title>
      <text>
        <list ID="RQO">
          <caption>REQUEST:</caption>
          <item>
            <content ID="Prest_1">90153 - CORTISOLO [S]</content>
          </item>
          <item>
            <content ID="Prest_2">90171 - DEIDROEPIANDROSTERONE (DEA)</content>
          </item>
          <item>
            <content ID="Prest_3">90172 - DEIDROEPIANDROSTERONE SOLFATO (DEA-S)</content>
          </item>
          <item>
            <content ID="Prest_4">90413 - TESTOSTERONE [P]</content>
          </item>
          <item>
            <content ID="Prest_5">90414 - TESTOSTERONE LIBERO</content>
          </item>
        </list>
        <list ID="DIAG">
          <caption>Problem:</caption>
          <item>
            <content ID="Prob_1">Control</content>
          </item>
        </list>
      </text>
    </section>
  </component>      
</structuredBody>

I would need to get the values contained in the text tag, and in particular: 1) Prest_1 2) 90153 - CORTISOLO [S] and all the following lines. Thanks for your help.

8
  • So the question should be, "how would I deserialize this xml?", and my comment would be, "what have you tried, what is not working for you?". At that point you would say, "i don't where to start", to which id reply, "try to search google first and then come back with parts that aren't working". and then you would say, "ok thanks" Commented Jun 18, 2020 at 9:31
  • I'm using a class, HL7SDK.Xml.Cda, but I can't see the text tag, the last tag I see in the hierarchy is <section ID = "DESCRIPTION">. Obviously I tried to solve with google and other posts, but I did not succeed, also because I am not well but I have to finish the job. Thanks anyway for your help. Commented Jun 18, 2020 at 9:41
  • You are using Hl7 medal data So use schema at bottom of page : hl7.org/documentcenter/public/wg/inm/…. Locate the xsd.exe utility from Microsoft (download) which will automatically create the c# classes to use for serialization. If you need help ask. I've done lots of projects using HL7. You can alos get additional info from : hl7.org/implement/standards/product_brief.cfm?product_id=7 Commented Jun 18, 2020 at 9:50
  • @jdwengI have a customer-supplied CDA.xsd file, which contains this code: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <xs:schema targetNamespace="urn:hl7-org:v3" xmlns:xs="w3.org/2001/XMLSchema" xmlns="urn:hl7-org:v3" xmlns:mif="urn:hl7-org:v3/mif" elementFormDefault="qualified"> <xs:include schemaLocation="POCD_MT000040.xsd"/> <xs:element name="ClinicalDocument" type="POCD_MT000040.ClinicalDocument"/> </xs:schema> And I also have the POCD_MT000040.xsd file to which reference is made (I don't insert it because it's too big), but I don't know how to use them. Commented Jun 18, 2020 at 10:02
  • I don't know if it's the right way, but I generated a class from my cda.xsd, using xsd / classes / language: CS "cda.xsd" / outputdir: c: \ temp. He created me a .cs file which I am now going to examine to see how to use it. Commented Jun 18, 2020 at 10:16

1 Answer 1

2

LINQ to XML makes it easy.

c#

void Main()
{
    const string FILENAME = @"e:\temp\ClinicalDocument.xml";

    XDocument doc = XDocument.Load(FILENAME);
    XNamespace ns = doc.Root.GetDefaultNamespace();

    foreach (var el in doc.Descendants(ns + "content"))
    {
        Console.WriteLine("ID='{0}', Content='{1}'", el.Attribute("ID").Value, el.Value);
    }
}

Output

ID='Prest_1', Content='90153 - CORTISOLO [S]'
ID='Prest_2', Content='90171 - DEIDROEPIANDROSTERONE (DEA)'
ID='Prest_3', Content='90172 - DEIDROEPIANDROSTERONE SOLFATO (DEA-S)'
ID='Prest_4', Content='90413 - TESTOSTERONE [P]'
ID='Prest_5', Content='90414 - TESTOSTERONE LIBERO'
ID='Prob_1', Content='Control'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.