简体   繁体   English

使用Mirth将XML转换为HL7

[英]XML to HL7 translation using Mirth

I am trying to get started with Mirth Connect. 我正在尝试使用Mirth Connect。 want to create a channel that would accept an XML and convert it in to HL7. 想要创建一个接受XML并将其转换为HL7的通道。 As a result i wan to create an ADT and OBR messages. 结果,我希望创建ADT和OBR消息。

Can anyone help me on this please? 有人可以帮我吗?

Am sharing my experience that how you can convert XML into HL7 using Javascript codes for source transformer 分享我的经验,即如何使用Java代码将XML转换为HL7作为源转换器

   var length = msg['orderList']['order'].length();
   var rcount = 0;
   for(var i=0;i<length;i++)
   {
    var SEG = new XML("<OBR/>");
    SEG['OBR.1']['OBR.1.1']=i+1;
    SEG['OBR.16']['OBR.16.1']=msg['orderList']['order'][i]['provider'].toString();
    tmp['OBR'][i]=SEG;
    var reslen = msg['orderList']['order'][i]['result'].length();
    logger.info(reslen);
    for(var j=0;j<reslen;j++)
    {
        var RSEG = new XML("<OBX/>");
        RSEG['OBX.1']['OBX.1.1'] = rcount;
        RSEG['OBX.3']['OBX.3.1'] = msg['orderList']['order'][i]['result'][j]['resultcode'].toString();
        RSEG['OBX.3']['OBX.3.2']=msg['orderList']['order'][i]['result'][j]['text'].toString();
        RSEG['OBX.7'] = msg['orderList']['order'][i]['result'][j]['range'].toString();
        RSEG['OBX.6']['OBX.6.2'] = msg['orderList']['order'][i]['result'][j]['unit'].toString();
        tmp['OBX'][rcount]=RSEG;
        rcount++;
    }
}
logger.info(SerializerFactory.getSerializer('HL7V2').fromXML(tmp));

Dont forgot to create a HL& template in source outbound

**MSH|^~\&|||||||||
PID|||||||||||||||||||||||||||
ORC|||||||||||||||||||**



sample XML

<PatientOrder>
<patient>
<name><fullname>XXXXXXXXXXX, XXXX.</fullname><firstname>XXXXX</firstname><lastname>XXXXX</lastname></name>
<address>
<address1>XXXXXX XXXX XXXX Med XXXX</address1><address2>Information XXXXX Fl</address2><address3>XXXX XXXX St  </address3><address4>XXXXXX XXXXXX, XX XXXXX</address4><telephone>XXX/XXXX-XXXX</telephone><fax>XXX/XXX-XXX</fax><latitude>X2.XXXXX</latitude><longitude>-X1.XXXXX</longitude></address>
</patient>
<orderList>
 <order>
    <provider>57423</provider>
    <result>result
            <resultcode>7685-1</resultcode>
            <text>Hemoglobin test2</text>
            <resultdate></resultdate>
            <range>3to52</range>
            <unit>mg</unit>
        </result>
        <result>result
            <resultcode>7685-1</resultcode>
            <text>Hemoglobin test2</text>
            <resultdate></resultdate>
            <range>3to52</range>
            <unit>mg</unit>
        </result>
    </order>
<order>
    <provider>57423</provider>
    <result>result
            <resultcode>7685-1</resultcode>
            <text>Hemoglobin test2</text>
            <resultdate></resultdate>
            <range>3to52</range>
            <unit>mg</unit>
        </result>
    </order>
</orderList>
</PatientOrder>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM