web stats
Mirth Community - View Single Post - XML to CCDA
Thread: XML to CCDA
View Single Post
  #1  
Old 05-15-2016, 11:21 PM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default 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 at 11:22 PM. Reason: corrections
Reply With Quote