Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   XML to CCDA (http://www.mirthcorp.com/community/forums/showthread.php?t=216012)

siddharth 05-15-2016 11:21 PM

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.

rav 05-16-2016 07:48 PM

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.

siddharth 05-17-2016 05:44 AM

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?

rav 05-17-2016 06:04 AM

Quote:

Originally Posted by siddharth (Post 255027)
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:


All times are GMT -8. The time now is 01:02 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation