如何将CCD xml响应转换为C#对象

时间:2015-11-06 11:44:25

标签: c# xml xsd ccd

我应该实现一个简单的c#客户端来调用其余的Web服务。 Web服务,返回表示CCD Docment的XML。 现在我想知道如何在Object c#中转换响应。

这是代码:

public void readSectionFromCCD(String appID, String shardSecret, String userID, String password,String templateID)
{
    String currentTime = DateTime.Now.ToString("yyyyMMdd");
    String URL = "https://dokumenttijakelu.fi/WSRest/";
    var client = new RestClient(URL);
    string hash = CalculateMD5Hash(currentTime + shardSecret + password);
    var request = new RestRequest("resource/ccd/" + userID + "/" + appID + "/" + currentTime + "/" + hash+"?"+templateID, Method.GET);
    var response = client.Execute(request);
} 

如果我读了回复。内容我可以读到这个:

 <Reply>
  <errorCode>OK</errorCode> 
  <errorDescription /> 
- <ccdContent>
  <?xml-stylesheet type="text/xsl" href="CCD.xsl"?> 
- <!--  The following sample document depicts a fictional character’s health summary. Any resemblance to a real person is coincidental. 
  --> 
- <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd">
- <!--  
********************************************************
CDA Header - test
********************************************************

  --> 
  <typeId extension="POCD_HD000040" root="2.16.840.1.113883.1.3" /> 
  <templateId root="2.16.840.1.113883.10.20.1" /> 
- <!--  CCD v1.0 Templates Root 
  --> 
  <id root="db734647-fc99-424c-a864-7e3cda82e703" /> 
  <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of episode note" /> 
  <title>Decipher Test PHR</title> 
  <effectiveTime value="20151104" /> 
  <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25" /> 
  <languageCode code="en-US" /> 
- <recordTarget>
- <patientRole>
  <id extension="test" root="2.16.840.1.113883.19.5" /> 
- <patient>
- <name>
  <given>test</given> 
  <family>test</family> 
  </name>
  <administrativeGenderCode code="" codeSystem="2.16.840.1.113883.5.1" /> 
  <birthTime value="20151102" /> 
  </patient>
- <providerOrganization>
  <id root="2.16.840.1.113883.19.5" /> 
  <name>Good Health Clinic</name> 
  </providerOrganization>
  </patientRole>
  </recordTarget>
- <author>
  <time value="20151102172336+0200" /> 
- <assignedAuthor>
  <id root="20cf14fb-b65c-4c8c-a54d-b0cca834c18c" /> 
- <assignedPerson>
- <name>
  <prefix>Dr.</prefix> 
  <given>Robert</given> 
  <family>Dolin</family> 
  </name>
  </assignedPerson>
- <representedOrganization>
  <id root="2.16.840.1.113883.19.5" /> 
  <name>Good Health Clinic</name> 
  </representedOrganization>
  </assignedAuthor>
  </author>
- <informant>
- <assignedEntity>
  <id nullFlavor="NI" /> 
- <representedOrganization>
  <id root="2.16.840.1.113883.19.5" /> 
  <name>Good Health Clinic</name> 
  </representedOrganization>
  </assignedEntity>
  </informant>
- <custodian>
- <assignedCustodian>
- <representedCustodianOrganization>
  <id root="2.16.840.1.113883.19.5" /> 
  <name>Good Health Clinic</name> 
  </representedCustodianOrganization>
  </assignedCustodian>
  </custodian>
- <legalAuthenticator>
  <time value="20151102172336+0200" /> 
  <signatureCode code="S" /> 
- <assignedEntity>
  <id nullFlavor="NI" /> 
- <representedOrganization>
  <id root="2.16.840.1.113883.19.5" /> 
  <name>Good Health Clinic</name> 
  </representedOrganization>
  </assignedEntity>
  </legalAuthenticator>
- <participant typeCode="IND">
- <associatedEntity classCode="GUAR">
  <id root="4ff51570-83a9-47b7-91f2-93ba30373141" /> 
- <addr>
  <streetAddressLine /> 
  <city /> 
  <state /> 
  <postalCode /> 
  </addr>
  <telecom value="(tel:)" /> 
- <associatedPerson>
- <name>
  <given /> 
  <family /> 
  </name>
  </associatedPerson>
  </associatedEntity>
  </participant>
- <participant typeCode="IND">
- <associatedEntity classCode="NOK">
  <id root="4ac71514-6a10-4164-9715-f8d96af48e6d" /> 
  <code code="" codeSystem="2.16.840.1.113883.6.96" displayName="" /> 
  <telecom value="(tel:)" /> 
- <associatedPerson>
- <name>
  <given /> 
  <family /> 
  </name>
  </associatedPerson>
  </associatedEntity>
  </participant>
- <documentationOf>
- <serviceEvent classCode="PCPR">
- <effectiveTime>
  <low value="20151102172336+0200" /> 
  <high value="" /> 
  </effectiveTime>
- <performer typeCode="PRF">
  <functionCode code="PCP" codeSystem="2.16.840.1.113883.5.88" /> 
- <time>
  <low value="1990" /> 
  <high value="20000407" /> 
  </time>
- <assignedEntity>
  <id root="20cf14fb-b65c-4c8c-a54d-b0cca834c18c" /> 
- <assignedPerson>
- <name>
  <prefix>Dr.</prefix> 
  <given>Robert</given> 
  <family>Dolin</family> 
  </name>
  </assignedPerson>
- <representedOrganization>
  <id root="2.16.840.1.113883.19.5" /> 
  <name>Good Health Clinic</name> 
  </representedOrganization>
  </assignedEntity>
  </performer>
  </serviceEvent>
  </documentationOf>
- <!--  
********************************************************
CDA Body
********************************************************

  --> 
- <component>
- <structuredBody>
- <!--  
********************************************************
Purpose section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.13" /> 
- <!--  Purpose section template 
  --> 
  <code code="48764-5" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Summary Purpose</title> 
  <text>Transfer of care</text> 
- <entry typeCode="DRIV">
- <act classCode="ACT" moodCode="EVN">
  <templateId root="2.16.840.1.113883.10.20.1.30" /> 
- <!--  Purpose activity template 
  --> 
  <code code="23745001" codeSystem="2.16.840.1.113883.6.96" displayName="Documentation procedure" /> 
  <statusCode code="completed" /> 
- <entryRelationship typeCode="RSON">
- <act classCode="ACT" moodCode="EVN">
  <code code="308292007" codeSystem="2.16.840.1.113883.6.96" displayName="Transfer of care" /> 
  <statusCode code="completed" /> 
  </act>
  </entryRelationship>
  </act>
  </entry>
  </section>
  </component>
- <!--  
********************************************************
Payers section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.9" /> 
- <!--  Payers section template 
  --> 
  <code code="48768-6" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Payers</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Payer name</th> 
  <th>Policy type / Coverage type</th> 
  <th>Covered party ID</th> 
  <th>Authorization(s)</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Advance Directives section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.1" /> 
- <!--  Advance directives section template 
  --> 
  <code code="42348-3" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Advance Directives</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Directive</th> 
  <th>Description</th> 
  <th>Verification</th> 
  <th>Supporting Document(s)</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Functional Status section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.5" /> 
- <!--  Functional status section template 
  --> 
  <code code="47420-5" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Functional Status</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Functional Condition</th> 
  <th>Effective Dates</th> 
  <th>Condition Status</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Problems section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.11" /> 
- <!--  Problem section template 
  --> 
  <code code="11450-4" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Problems</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Condition</th> 
  <th>Effective Dates</th> 
  <th>Condition Status</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Family History section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.4" /> 
- <!--  Family history section template 
  --> 
  <code code="10157-6" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Family history</title> 
- <text>
  <paragraph>Father (alive)</paragraph> 
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Diagnosis</th> 
  <th>Age At Onset</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  <paragraph>Mother (alive)</paragraph> 
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Diagnosis</th> 
  <th>Age At Onset</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Social History section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.15" /> 
- <!--  Social history section template 
  --> 
  <code code="29762-2" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Social History</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Social History Element</th> 
  <th>Description</th> 
  <th>Effective Dates</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Alerts section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.2" /> 
- <!--  Alerts section template 
  --> 
  <code code="48765-2" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Allergies, Adverse Reactions, Alerts</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Substance</th> 
  <th>Reaction</th> 
  <th>Status</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Medications section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.8" /> 
- <!--  Medications section template 
  --> 
  <code code="10160-0" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Medications</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Medication</th> 
  <th>Instructions</th> 
  <th>Start Date</th> 
  <th>End Date</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Medical Equipment section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.7" /> 
- <!--  Medical equipment section template 
  --> 
  <code code="46264-8" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Medical Equipment</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Supply/Device</th> 
  <th>Date Supplied</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Immunizations section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.6" /> 
- <!--  Immunizations section template 
  --> 
  <code code="11369-6" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Immunizations</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Vaccine</th> 
  <th>Date</th> 
  <th>Status</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Vital Signs section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.16" /> 
- <!--  Vital signs section template 
  --> 
  <code code="8716-3" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Vital Signs</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Observation</th> 
  <th>Value/Unit</th> 
  <th>Date/Time</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Results section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.14" /> 
- <!--  Results section template 
  --> 
  <code code="30954-2" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Results</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Observation (Range)</th> 
  <th>Value/Unit</th> 
  <th>Measurement Procedure</th> 
  <th>Date/Time</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Procedures section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.12" /> 
- <!--  Procedures section template 
  --> 
  <code code="47519-4" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Procedures</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Procedure</th> 
  <th>Date</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Encounters section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.3" /> 
- <!--  Encounters section template 
  --> 
  <code code="46240-8" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Encounters</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Encounter</th> 
  <th>Location</th> 
  <th>Date</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
- <!--  
********************************************************
Plan of Care section
********************************************************

  --> 
- <component>
- <section>
  <templateId root="2.16.840.1.113883.10.20.1.10" /> 
- <!--  Plan of Care section template 
  --> 
  <code code="18776-5" codeSystem="2.16.840.1.113883.6.1" /> 
  <title>Plan</title> 
- <text>
- <table border="1" width="100%">
- <thead>
- <tr>
  <th>Planned Activity</th> 
  <th>Planned Date</th> 
  </tr>
  </thead>
- <tbody>
- <tr>
  <td>-</td> 
  <td>-</td> 
  </tr>
  </tbody>
  </table>
  </text>
  </section>
  </component>
  <String /> 
  <String /> 
  <String /> 
  <String /> 
  <String /> 
  </structuredBody>
  </component>
  </ClinicalDocument>
  </ccdContent>
  </Reply

现在,我已从原始网站下载了CCD.xsd。我使用XSD.exe工具生成.cs类。

但是我无法反序列化对象的响应

0 个答案:

没有答案