开发者

Mirth: overwriting msg object with contents in an XML object

The task is to send an XML object from Channel-A to Channel-B

<MyMessage>
<ID>42</ID>
<hl7v2>
    MSH|^~\&|LAB|....
    PID|1|....
</hl7v2>
</MyMessage>

The steps of the channel communication:

  • in the Channel-B's source transformer, extract the HL7v2 contents
  • OVERWRITE the current msg object in Channel-B with the extracted contents
  • continue in the other Channel-B source transformers and expecting to reference msg['PID']['PID.5'] as normal.

The good news is that I can extract the HL7v2 'payload' into a variable. The problem or difficulty is resetting the msg object, or any other object to be able to reference the HL7 properties as expected.

When I create a new variable with the SerializerFactory.getHL7Serializer, it wraps with the tags <HL7Message>.

channelMap.put('MessageID', msg['ID']); //successful
channelMap.put('v2payload',msg['HL7v2']); //also looks good

var v2Msg = SerializerFactory.getHL7Serializer(false,false,true).toXML(msg['HL7v2']);

channelMap.put('v2Msg', v2Msg );

Mirth: overwriting msg object with contents in an XML object

link to full size image

Question: Do you have any suggestions on how to overwrite the msg object?

How can I start referencing the msg as such:

msg['PID']['PID.5']

Current Conditions

  • the receiving channel's input type is XML
  • the need is to take extract all the properties from that XML object; ID is a database PK to be 开发者_运维技巧used later in the destination.


I'm sorry my original answer was bogged down with the peculiarities of my own scenario. I have reworked and tested to ensure that this works in your scenario.

Sending Channel - wraps the raw hl7 into your xml structure, and forwards to a channel called ReceiveXML. I have coded this in the Source Transformer, but you should code it where it works for you.

var wrappedHL7 = <MyMessage><ID>123</ID>
                      <hl7v2>{messageObject.getRawData()}</hl7v2>
                 </MyMessage>;

router.routeMessage("ReceiveXML", wrappedHL7);

Receiving Channel - extracts the hl7 from the xml, converts it to xml, and assigns back to the msg object. I have coded this in the source Filter - hence "return true;"

msg = new XML(SerializerFactory.getHL7Serializer(false,false,true).toXML(msg['hl7v2'].toString()));
return true;


All you have to do is put your incoming xml message into the inbound template area in mirth and then use the message tree to drag and drop the info from the XML that you need to the javascript section of the connector.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜