Announcement

Collapse
No announcement yet.

XML to CCDA

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML to CCDA

    I am trying to create a CCDA document out of an xml input.
    I really thought this would be a simpler one-to-one mapping, but it turns out that is not the case.

    The output that I am getting is actually the complete template I have used in the channel, and none of the mappings are working.

    I struggled a lot with namespaces, but it still does not work.

    This is the transformer code, that I am using
    Code:
    //var msgs= new XML();
    //default xml namespace = 'urn:hl7-org:v3';
    //tmp.setNamespace('urn:hl7-org:v3');
    
    
    var dateString = DateUtil.getCurrentDate("yyyyMMddhhmmss");
    var dob=msg['Message']['Body']['RxHistoryResponse']['Patient']['DateOfBirth']['Date'].toString();
    formattedDOB=dob.split("-").join("");
    
    
    tmp['id'][0]="";
    tmp['id'][0]['@root']=msg['Message']['Header']['RelatesToMessageID'].toString();
    tmp['id'][1]="";
    tmp['id'][1]['@extension']=msg['Message']['Header']['MessageID'].toString();
    tmp['id'][1]['@root']="SS";
    tmp['title']="SS Medication History";
    tmp['effectiveTime']="";
    tmp['effectiveTime']['@value']=dateString;
    tmp['recordTarget']['patientRole']['id']['@extension']=msg['Message']['Body']['RxHistoryResponse']['Patient']['Identification']['MutuallyDefined'].toString();
    tmp['recordTarget']['patientRole']['id']['@root']="Mutually Defined Id";
    tmp['recordTarget']['patientRole']['addr']['postalCode']=msg['Message']['Body']['RxHistoryResponse']['Patient']['Address']['ZipCode'].toString();
    tmp['recordTarget']['patientRole']['patient']['name']['given']=msg['Message']['Body']['RxHistoryResponse']['Patient']['Name']['FirstName'].toString();
    tmp['recordTarget']['patientRole']['patient']['name']['family']=msg['Message']['Body']['RxHistoryResponse']['Patient']['Name']['LastName'].toString();
    tmp['recordTarget']['patientRole']['patient']['birthTime']['@value']=formattedDOB;
    This is just a part of the whole code. It's a long list of mappings.


    This is how the output looks like.(just the recordTarget\patients data). yeesh!
    Code:
    <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <realmCode code="US"/>
        <typeId extension="POCD_HD000040" root="2.16.840.1.113883.1.3"/>
        <templateId root="2.16.840.1.113883.10.20.22.1.1"/>
        <templateId root="2.16.840.1.113883.10.20.22.1.2"/>
        <id root=""/>
        <id extension="" root="SS"/>
        <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Summarization of Episode Note"/>
        <title>SS Medication History</title>
        <effectiveTime value="20160516124904"/>
        <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/>
        <languageCode code="en-US"/>
        <recordTarget>
            <patientRole>
                <id extension="" root="Mutually Defined Id"/>
                <addr>
                    <streetAddressLine/>
                    <streetAddressLine/>
                    <city/>
                    <state/>
                    <postalCode/>
                </addr>
                <telecom use="H" value=""/>
                <telecom use="W" value=""/>
                <patient>
                    <name>
                        <given/>
                        <family/>
                        <prefix/>
                        <suffix/>
                    </name>
                    <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
                    <birthTime value=""/>
                    <maritalStatusCode/>
                    <religiousAffiliationCode/>
                    <raceCode/>
                    <ethnicGroupCode/>
                    <birthplace/>
                    <languageCommunication/>
                </patient>
            </patientRole>
        </recordTarget>
    </ClinicalDocument>
    XML has never been my strong suite.

    I am pretty sure I am missing something very small.
    Please advise.
    Last edited by siddharth; 05-15-2016, 11:22 PM. Reason: corrections
    HL7v2.7 Certified Control Specialist!

  • #2
    Hi Siddharth,

    I tried the following steps:

    Uncheck strip namespaces.


    First I copied all the values from the inbound message to some variables.
    Then I created
    default xml namespace="urn:hl7-org:v3";

    After that I mapped outbound template to the variables. The values are getting mapped.

    Comment


    • #3
      Thanks for the help.

      It works. I had to create an extraction step that will basically extract everything I need from the XML and then I map it in the outbound.

      However, I don't know the reason why direct mapping -XML to XML - is not working. Do you know the reason for this behaviour?
      HL7v2.7 Certified Control Specialist!

      Comment


      • #4
        Originally posted by siddharth View Post
        Thanks for the help.

        It works. I had to create an extraction step that will basically extract everything I need from the XML and then I map it in the outbound.

        However, I don't know the reason why direct mapping -XML to XML - is not working. Do you know the reason for this behaviour?

        I think it might be something to do with namespaces..I followed the following thread:

        http://www.mirthproject.org/communit...ead.php?t=6105


        Are you setting the namespace? As CDA use the "urn:hl7-org:v3" you need:

        1) Be sure to un-check the "strip namespace" of the outbound template:
        2) Set the following line before any map code (note than you need to recover msg variables before setting the default namespace to HL7V3 as otherwise you couldn't get msg values. This is usual when msg and tmp are from different namespace:

        Comment

        Working...
        X