0

I am trying to deserialize an XML file using a c# class that was automatically generated. When I tried to Deserialize the xml file, I am getting an exception 'The specified type was not recognized.' Has anyone experienced this issue before? Your help will be greatly appreciated.

I tried to load the c# class and the xsd files, but they are too big to load here.

The c# class was generated from an xsd file that was created using the xml file below. Two xsd file was created qrda.xsd and qrda1.xsd, and the following command was used to generated the c# class (xsd qrda.xsd qrda1.xsd /c)

    <?xml version="1.0" encoding="utf-8"?>
<ClinicalDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="urn:hl7-org:v3"
 xmlns:voc="urn:hl7-org:v3/voc"
 xmlns:sdtc="urn:hl7-org:sdtc">
  <!-- QRDA Header -->
  <realmCode code="US"/>
  <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
  <!-- US Realm Header Template Id -->
  <templateId root="2.16.840.1.113883.10.20.22.1.1"/>
  <!-- QRDA templateId -->
  <templateId root="2.16.840.1.113883.10.20.24.1.1"/>
  <!-- QDM-based QRDA templateId -->
  <templateId root="2.16.840.1.113883.10.20.24.1.2"/>
  <!-- This is the globally unique identifier for this QRDA document -->
  <id root="96b52620-49bd-0132-cf19-4040b69a5a45"/>
  <!-- QRDA document type code -->
  <code code="55182-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Quality Measure Report"/>
  <title>QRDA Incidence Report</title>
  <!-- This is the document creation time -->
  <effectiveTime value="20141108213906"/>
  <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/>
  <languageCode code="eng"/>
  <!-- reported patient -->
    <recordTarget>
    <patientRole>
        <id extension="12345" root="PlaceholderOrganization" />
      <addr use="HP">
          <streetAddressLine>202 Burlington Rd.</streetAddressLine>
          <city>Bedford</city>
          <state>MA</state>
          <postalCode>01730</postalCode>
          <country>US</country>
      </addr>
      <telecom use="WP" value="tel:+1-781-271-3000"/>
      <patient>
        <name>
          <given>Jesus</given>
          <family>Abbott</family>
        </name>
        <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1" codeSystemName="HL7 AdministrativeGender"/>
        <birthTime value="19380305153120"/>
          <raceCode code="1002-5" displayName="American Indian or Alaska Native" codeSystemName="CDC Race and Ethnicity" codeSystem="2.16.840.1.113883.6.238"/>
          <ethnicGroupCode code="2186-5" displayName="Not Hispanic or Latino" codeSystemName="CDC Race and Ethnicity" codeSystem="2.16.840.1.113883.6.238"/>
          <languageCommunication>
            <templateId root="2.16.840.1.113883.3.88.11.83.2" assigningAuthorityName="HITSP/C83"/>
            <templateId root="1.3.6.1.4.1.19376.1.5.3.1.2.1" assigningAuthorityName="IHE/PCC"/>
            <languageCode code="eng"/>
          </languageCommunication>
      </patient>
    </patientRole>
  </recordTarget>

  <!-- Example of an author who is a device -->
    <author>
      <time value="20141108213906"/>
      <assignedAuthor>
        <!-- id extension="Cypress" root="2.16.840.1.113883.19.5"/ -->
        <!-- NPI -->
        <id extension="FakeNPI" root="2.16.840.1.113883.4.6"/>
        <addr>
          <streetAddressLine>202 Burlington Rd.</streetAddressLine>
          <city>Bedford</city>
          <state>MA</state>
          <postalCode>01730</postalCode>
          <country>US</country>
        </addr>
        <telecom use="WP" value="tel:(781)271-3000"/>
        <assignedAuthoringDevice>
          <manufacturerModelName>Cypress</manufacturerModelName >
          <softwareName>Cypress</softwareName >
        </assignedAuthoringDevice >
      </assignedAuthor>
    </author>
    <custodian>
      <assignedCustodian>
        <representedCustodianOrganization>
          <id root="2.16.840.1.113883.19.5"/>
          <name>Cypress Test Deck</name>
          <telecom use="WP" value="tel:(781)271-3000"/>
          <addr>
            <streetAddressLine>202 Burlington Rd.</streetAddressLine>
            <city>Bedford</city>
            <state>MA</state>
            <postalCode>01730</postalCode>
            <country>US</country>
          </addr>
        </representedCustodianOrganization>
      </assignedCustodian>
    </custodian>
    <legalAuthenticator>
      <time value="20141108213906"/>
      <signatureCode code="S"/>
      <assignedEntity>
        <id root="bc01a5d1-3a34-4286-82cc-43eb04c972a7"/>
        <addr>
          <streetAddressLine>202 Burlington Rd.</streetAddressLine>
          <city>Bedford</city>
          <state>MA</state>
          <postalCode>01730</postalCode>
          <country>US</country>
        </addr>
        <telecom use="WP" value="tel:(781)271-3000"/>
        <assignedPerson>
          <name>
             <given>Henry</given>
             <family>Seven</family>
          </name>
       </assignedPerson>
        <representedOrganization>
          <id root="2.16.840.1.113883.19.5"/>
          <name>Cypress</name>
        </representedOrganization>
      </assignedEntity>
    </legalAuthenticator>

  <documentationOf typeCode="DOC">
  <serviceEvent classCode="PCPR"> <!-- care provision -->
    <!-- No provider data found in the patient record
         putting in a fake provider -->
    <effectiveTime>
      <low value="20020716"/>
      <high value="20141108213906"/>
    </effectiveTime>
    <!-- You can include multiple performers, each with an NPI, TIN, CCN. -->
    <performer typeCode="PRF"> 
      <time>
        <low value="20020716"/>
        <high value="20141108213906"/>
      </time>
      <assignedEntity>
        <!-- This is the provider NPI -->
        <id root="2.16.840.1.113883.4.6" extension="111111111" /> 
        <representedOrganization>
          <!-- This is the organization TIN -->
          <id root="2.16.840.1.113883.4.2" extension="1234567" /> 
          <!-- This is the organization CCN -->
          <id root="2.16.840.1.113883.4.336" extension="54321" /> 
        </representedOrganization>
      </assignedEntity>
    </performer>
  </serviceEvent>
</documentationOf>

  <component>
    <structuredBody>
            <component>
        <section>
          <!-- 
            *****************************************************************
            Measure Section
            *****************************************************************
          -->
          <!-- This is the templateId for Measure Section -->
          <templateId root="2.16.840.1.113883.10.20.24.2.2"/>
          <!-- This is the templateId for Measure Section QDM -->
          <templateId root="2.16.840.1.113883.10.20.24.2.3"/>
          <!-- This is the LOINC code for "Measure document". This stays the same for all measure section required by QRDA standard -->
          <code code="55186-1" codeSystem="2.16.840.1.113883.6.1"/>
          <title>Measure Section</title>
          <text>
            <table border="1" width="100%">
              <thead>
                <tr>
                  <th>eMeasure Title</th>
                  <th>Version neutral identifier</th>
                  <th>eMeasure Version Number</th>
                  <th>Version specific identifier</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>Thrombolytic Therapy</td>
                  <td>2838875A-07B5-4BF0-BE04-C3EB99F53975</td>
                  <td>4</td>
                  <td>40280381-446B-B8C2-0144-95DE69F81CF4</td>
                  <td></td>
                </tr>
              </tbody>
            </table>
          </text>
          <!-- 1..* Organizers, each containing a reference to an eMeasure -->
          <entry>
            <organizer classCode="CLUSTER" moodCode="EVN">
              <!-- This is the templateId for Measure Reference -->
              <templateId root="2.16.840.1.113883.10.20.24.3.98"/>
              <!-- This is the templateId for eMeasure Reference QDM -->
              <templateId root="2.16.840.1.113883.10.20.24.3.97"/>
              <statusCode code="completed"/>
              <!-- Containing isBranch external references -->
              <reference typeCode="REFR">
                <externalDocument classCode="DOC" moodCode="EVN">
                  <!-- SHALL: This is the version specific identifier for eMeasure: QualityMeasureDocument/id it is a GUID-->
                  <id root="40280381-446B-B8C2-0144-95DE69F81CF4"/>
                  <!-- SHOULD This is the title of the eMeasure -->
                  <text>Thrombolytic Therapy</text>
                  <!-- SHOULD: setId is the eMeasure version neutral id  -->
                  <setId root="2838875A-07B5-4BF0-BE04-C3EB99F53975"/>
                  <!-- This is the sequential eMeasure Version number -->
                  <versionNumber value="4"/>                  
                </externalDocument>
              </reference>
            </organizer>
          </entry>
        </section>
      </component>

            <component>
        <section>
          <!-- This is the templateId for Reporting Parameters section -->
          <templateId root="2.16.840.1.113883.10.20.17.2.1"/>
          <code code="55187-9" codeSystem="2.16.840.1.113883.6.1"/>
          <title>Reporting Parameters</title>
          <text>
            <list>
              <item>Reporting period: January 1st, 2013 00:00 - December 31st, 2013 23:59</item>
            </list>
          </text>
          <entry typeCode="DRIV">
            <act classCode="ACT" moodCode="EVN">
              <!-- This is the templateId for Reporting Parameteres Act -->
              <templateId root="2.16.840.1.113883.10.20.17.3.8"/>
              <code code="252116004" codeSystem="2.16.840.1.113883.6.96" displayName="Observation Parameters"/>
              <effectiveTime>
                <low value="20130101000000"/>
                <high value="20131231235959"/>
              </effectiveTime>
            </act>
          </entry>
        </section>
      </component>
            <component>
        <section>
          <!-- This is the templateId for Patient Data section -->
          <templateId root="2.16.840.1.113883.10.20.17.2.4"/>
          <!-- This is the templateId for Patient Data QDM section -->
          <templateId root="2.16.840.1.113883.10.20.24.2.1"/>
          <code code="55188-7" codeSystem="2.16.840.1.113883.6.1"/>
          <title>Patient Data</title>
          <text>

          </text>

<entry>
  <encounter classCode="ENC" moodCode="EVN">
    <!--  Encounter activities template -->
    <templateId root="2.16.840.1.113883.10.20.22.4.49"/>
    <!-- Encounter performed template -->
    <templateId root="2.16.840.1.113883.10.20.24.3.23"/>
    <id root="1.3.6.1.4.1.115" extension="54272ceb637970595b9c0000"/>
    <code code="4525004" codeSystem="2.16.840.1.113883.6.96" sdtc:valueSet="2.16.840.1.113883.3.117.1.7.1.292"><originalText>Encounter, Performed: Emergency Department Visit</originalText></code>
    <text>Encounter, Performed: Emergency Department Visit</text>
    <statusCode code="completed"/>
    <effectiveTime>
      <!-- We try to look for the admit/discharge times on the encounter if they are
           there. If not, we fall back to the typical start/end date. -->
      <low value='20130112170120'/>
      <high value='20130112210120'/>
    </effectiveTime>

    <participant typeCode="LOC">
      <!-- Facility Location template -->
      <templateId root="2.16.840.1.113883.10.20.24.3.100"/>
      <time>
        <!-- Attribute: facility location arrival datetime -->
        <low value='20130112170120'/>
        <!-- Attribute: facility location departure datetime -->
        <high value='20130112210120'/>
      </time>
      <participantRole classCode="SDLOC">
        <code nullFlavor="UNK"/>
        <telecom nullFlavor="UNK"/>
        <playingEntity classCode="PLC">
          <name></name>
        </playingEntity>
      </participantRole>
    </participant>



  </encounter>
</entry>
<entry>
  <encounter classCode="ENC" moodCode="EVN">
    <!--  Encounter activities template -->
    <templateId root="2.16.840.1.113883.10.20.22.4.49"/>
    <!-- Encounter performed template -->
    <templateId root="2.16.840.1.113883.10.20.24.3.23"/>
    <id root="1.3.6.1.4.1.115" extension="54272ceb637970595b9e0000"/>
    <code code="4525004" codeSystem="2.16.840.1.113883.6.96" sdtc:valueSet="2.16.840.1.113883.3.117.1.7.1.292"><originalText>Encounter, Performed: Emergency Department Visit</originalText></code>
    <text>Encounter, Performed: Emergency Department Visit</text>
    <statusCode code="completed"/>
    <effectiveTime>
      <!-- We try to look for the admit/discharge times on the encounter if they are
           there. If not, we fall back to the typical start/end date. -->
      <low value='20130401150120'/>
      <high value='20130401163120'/>
    </effectiveTime>

    <participant typeCode="LOC">
      <!-- Facility Location template -->
      <templateId root="2.16.840.1.113883.10.20.24.3.100"/>
      <time>
        <!-- Attribute: facility location arrival datetime -->
        <low value='20130401150120'/>
        <!-- Attribute: facility location departure datetime -->
        <high value='20130401163120'/>
      </time>
      <participantRole classCode="SDLOC">
        <code nullFlavor="UNK"/>
        <telecom nullFlavor="UNK"/>
        <playingEntity classCode="PLC">
          <name></name>
        </playingEntity>
      </participantRole>
    </participant>



  </encounter>
</entry>
<entry>
  <encounter classCode="ENC" moodCode="EVN">
    <!--  Encounter activities template -->
    <templateId root="2.16.840.1.113883.10.20.22.4.49"/>
    <!-- Encounter performed template -->
    <templateId root="2.16.840.1.113883.10.20.24.3.23"/>
    <id root="1.3.6.1.4.1.115" extension="54272ceb637970595ba10000"/>
    <code code="183452005" codeSystem="2.16.840.1.113883.6.96" sdtc:valueSet="2.16.840.1.113883.3.117.1.7.1.424"><originalText>Encounter, Performed: Non-Elective Inpatient Encounter</originalText></code>
    <text>Encounter, Performed: Non-Elective Inpatient Encounter</text>
    <statusCode code="completed"/>
    <effectiveTime>
      <!-- We try to look for the admit/discharge times on the encounter if they are
           there. If not, we fall back to the typical start/end date. -->
      <low value='20130401170120'/>
      <high value='20130404180120'/>
    </effectiveTime>
    <sdtc:dischargeDispositionCode code="10161009" 
            codeSystem="2.16.840.1.113883.6.96"/>




  </encounter>
</entry>

<entry>
  <!-- Physical Exam Finding -->
  <observation classCode="OBS" moodCode="EVN">
    <!--  Result observation template -->
    <templateId root="2.16.840.1.113883.10.20.22.4.2"/>
    <!-- Physical Exam, Finding template -->
    <templateId root="2.16.840.1.113883.10.20.24.3.57"/>
    <id root="1.3.6.1.4.1.115" extension="54272ceb637970595ba20000"/>
    <code code="405795006" codeSystem="2.16.840.1.113883.6.96" sdtc:valueSet="2.16.840.1.113762.1.4.1045.14"><originalText>Physical Exam: Time of Symptom Onset</originalText></code>    
    <text>Physical Exam: Time of Symptom Onset</text>
    <statusCode code="completed"/>

    <effectiveTime>
      <low value='20130401140120'/>
      <high value='20130401140120'/>
    </effectiveTime>
    <value xsi:type="CD" nullFlavor="UNK"/>

  </observation>
</entry>





<entry>
  <!-- Patient Characteristic Payer -->
  <observation classCode="OBS" moodCode="EVN">
    <templateId root="2.16.840.1.113883.10.20.24.3.55"/>
    <id root="1.3.6.1.4.1.115" extension="54272ceb637970595ba50000"/>
    <code code="48768-6" codeSystemName="LOINC" codeSystem="2.16.840.1.113883.6.1" displayName="Payment source"/> 
    <statusCode code="completed"/>
    <value code="349" codeSystem="2.16.840.1.113883.3.221.5" xsi:type="CD" sdtc:valueSet="2.16.840.1.114222.4.11.3591"><originalText></originalText></value>
  </observation>            
</entry>

<entry>
  <observation classCode="OBS" moodCode="EVN">
    <!--  Problem observation template -->
    <templateId root="2.16.840.1.113883.10.20.22.4.4"/>
    <!--  Diagnosis active template -->
    <templateId root="2.16.840.1.113883.10.20.24.3.11"/>
    <id root="1.3.6.1.4.1.115" extension="54272ceb637970595b9b0000"/>
    <code code="282291009" displayName="diagnosis" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT"/>
    <text>Diagnosis, Active: Ischemic Stroke</text>
    <statusCode code="completed"/>
    <effectiveTime>
      <!-- Attribute: admission datetime -->
      <low value='20130401170120'/>
      <!-- Attribute: discharge datetime -->
      <high value='20130403180120'/>
    </effectiveTime>
    <priorityCode  code="63161005" 
              codeSystem="2.16.840.1.113883.6.96"
              sdtc:valueSet="2.16.840.1.113883.3.117.1.7.1.14"
              />


    <value code="111297002" codeSystem="2.16.840.1.113883.6.96" xsi:type="CD" sdtc:valueSet="2.16.840.1.113883.3.117.1.7.1.247"><originalText>Diagnosis, Active: Ischemic Stroke</originalText><translation code="433.01" codeSystem="2.16.840.1.113883.6.103"/>
<translation code="I63.00" codeSystem="2.16.840.1.113883.6.90"/>
</value>

    <entryRelationship typeCode="REFR">
      <observation classCode="OBS" moodCode="EVN">
        <!-- Problem Status (consolidation) template -->
        <templateId root="2.16.840.1.113883.10.20.22.4.6"/>
        <!-- Problem Status, Active template -->
        <templateId root="2.16.840.1.113883.10.20.24.3.94"/>
        <id root="96b8a910-49bd-0132-cf19-4040b69a5a45"/>  
        <code code="33999-4" 
          codeSystem="2.16.840.1.113883.6.1"
          codeSystemName="LOINC" 
          displayName="status"/>
        <statusCode code="completed"/>
        <value xsi:type="CD" code="55561003" 
           displayName="active"
           codeSystem="2.16.840.1.113883.6.96" 
           codeSystemName="SNOMED CT"/>
      </observation>
    </entryRelationship>
  </observation>
</entry>










        </section>
      </component>
    </structuredBody>
  </component>
</ClinicalDocument>
Denes
  • 47
  • 3
  • 11
  • You need to provide a [minimal, complete and verifiable example](http://stackoverflow.com/help/mcve). We don't have the class you've generated, and we don't have the code you've used to deserialize the XML. – Charles Mager Jul 28 '15 at 15:40
  • I did not add the class because I thought it was too much. I will load the class and xsd file soon. – Denes Jul 28 '15 at 15:53
  • The class is too big, so I can't post it. – Denes Jul 28 '15 at 15:59

3 Answers3

0

I validated against our CaboLabs.com CDA schema. There are invalid attributes in your CDA, remove the "valueSet" from the "code" elements, that's not valid.

Complete error list:

ERROR: Element '{urn:hl7-org:v3}code', attribute '{urn:hl7-org:sdtc}valueSet': The attribute '{urn:hl7-org:sdtc}valueSet' is not allowed.
ERROR: Element '{urn:hl7-org:v3}code', attribute '{urn:hl7-org:sdtc}valueSet': The attribute '{urn:hl7-org:sdtc}valueSet' is not allowed.
ERROR: Element '{urn:hl7-org:v3}code', attribute '{urn:hl7-org:sdtc}valueSet': The attribute '{urn:hl7-org:sdtc}valueSet' is not allowed.
ERROR: Element '{urn:hl7-org:sdtc}dischargeDispositionCode': This element is not expected. Expected is one of ( {urn:hl7-org:v3}priorityCode, {urn:hl7-org:v3}subject, {urn:hl7-org:v3}specimen, {urn:hl7-org:v3}performer, {urn:hl7-org:v3}author, {urn:hl7-org:v3}informant, {urn:hl7-org:v3}participant, {urn:hl7-org:v3}entryRelationship, {urn:hl7-org:v3}reference, {urn:hl7-org:v3}precondition ).
ERROR: Element '{urn:hl7-org:v3}code', attribute '{urn:hl7-org:sdtc}valueSet': The attribute '{urn:hl7-org:sdtc}valueSet' is not allowed.
ERROR: Element '{urn:hl7-org:v3}value', attribute '{urn:hl7-org:sdtc}valueSet': The attribute '{urn:hl7-org:sdtc}valueSet' is not allowed.
ERROR: Element '{urn:hl7-org:v3}priorityCode', attribute '{urn:hl7-org:sdtc}valueSet': The attribute '{urn:hl7-org:sdtc}valueSet' is not allowed.
ERROR: Element '{urn:hl7-org:v3}value', attribute '{urn:hl7-org:sdtc}valueSet': The attribute '{urn:hl7-org:sdtc}valueSet' is not allowed.
Pablo Pazos
  • 3,080
  • 29
  • 42
  • This is an actual CCD document generated using the cypress tool. According to them, the valueset has to be included in there. – Denes Aug 14 '15 at 17:54
  • CCD should be a valid CDA, if it doesn't comply with the CDA schema, then is not a valid CDA and they are using a vendor customized CDA for CCD, that will be valid only with their own systems. If you want to sent that CCD to another system, you might have prolems. – Pablo Pazos Aug 15 '15 at 04:13
  • @Pablo Pazos: This is not CCD, this is a QRDA document which should be validated against QRDA XML Schema, which contains schema for sdtc extension. The use of SDTC namespace is governed by QRDA IG. – Shamil Oct 20 '16 at 18:45
0

The XSD files you created from a single XML file are unlikely to be good enough to work with HL7 documents (unless you are working with a system that only ever puts out a very narrow subset of the standard).

Furthermore the 'CD' issue you are having is not easily resolved with the approach you've taken. Basically the XSD validator is trying to find a complex type that is called 'CD' your generated XSD's probably just created a xsi:type attribute, but did not create the underlying complexType, to add to this type='CD' could just as easily be type='PQR' (or any of the other derived types, see image).

HL7 CD complextype derived types

You really need to generate your code from the original HL7 Schemas. However I'm not sure xsd.exe is up to the job as these are big complex schemas. Liquid XML Data Binder would probably do what you want, but its not free.

Sprotty
  • 5,676
  • 3
  • 33
  • 52
0

Supporting XSD documents are missing where were used for transformation.

You need to load the XSD documents to deserialize.