Announcement

Collapse
No announcement yet.

Converting xml data field in DB to HL7 message -- outbound

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

  • Converting xml data field in DB to HL7 message -- outbound

    Hello Team,
    I am a newbie to Mirth and JavaScript.
    I am struggling to get the sample code. Please guide me as soon as possible.

    I am using Mirth 3.1.1.7461 version and the scenario is that we are picking data from DB and we have to transform and send HL7 message to the destination.

    I am able to convert few fields which have String data properly; however i am stuck in converting xml data field to HL7.

    Here is the sample xml that is stored in GT1 field :-
    <guarantorno />
    <fname>Test First</fname>
    <mname />
    <lname>Name</lname>
    <birthdate>10/04/1972</birthdate>
    <sex>F</sex>
    <homephone>(123)234-1234</homephone>
    <workphone />
    <address>12401 Test address</address>
    <address2 />
    <city>testcity</city>
    <state>FL</state>
    <zipcode>12345-7638</zipcode>
    <type>Default Guarantor</type>
    <relationship>03</relationship>
    <ssn />
    and in transformer i have written below code in which

    var guarXML=msg['guarantorinfo'].toString();
    if(guarXML !='undefined'){
    for each ( guarantor in msg['guarantorinfo']){
    logger.info("guarantor"+ guarXML);
    // tmp['GT1'][0]['GT1.2']['GT1.2.1'] =guarXML.guarantor.guarantorno; --
    I am getting Cannot read property "guarantorno" from undefined error
    tmp['GT1'][0]['GT1.3']['GT1.3.2'] =msg['guarantor']['fname']; -- I am getting Cannot read property "fname" from undefined error


    }

    }
    guarXML is picking up data correctly below is test sample that is picked up from guarXML
    guarantor<guarantorno/><fname>Test first</fname><mname/><lname>Name</lname><birthdate>10/04/1972</birthdate><sex>F</sex><homephone>(123)234-1234</homephone><workphone/><address>12401 Test address</address><address2/><city>Testcity</city><state>FL</state><zipcode>12345-7638</zipcode><type>Default Guarantor</type><relationship>03</relationship><ssn/>
Working...
X