1

I have a source message that is coming from an SQL Database. It's formatted as such:

<result>
    <rawmessage>A|Full Raw|HL7|Message|is here </rawmessage>
    <id>The-Messages-GUID-FromMSSQL</id>
</result>

I'd like to take the information from the query and separate it into multiple tables with each row being tied to the GUID connected with the message. I am able to get to the raw message and convert the HL7 string to XML but can't get to the data.

My current understanding is to have source and destination types in the channel be XML. I can access the ID using msg['id'] and save that to a channel map. I can also convert the HL7 string to XML and save it to a variable (See below). When I try to access a segment or a field using msg2['OBR']['OBR.2']['OBR.2.1'].toString() for example, I get the message Cannot read property "OBR" from undefined in my errors tab and in info in the console I get Undefined. If I remove ['HL7Message'] I get Cannot read property "OBR.2" from undefined in the error and <?xml version="1.0" encoding="UTF-8"?><HL7Message><MSH> in info. If I define the Channel Mapped Variable as msg1['OBR.2.1'] it comes back as undefined.

Here's my current transformer step:

channelMap.put('Raw Message', msg['rawmessage'].toString());
channelMap.put('Raw GUID', msg['id'].toString());
channelMap.put('XML Message', SerializerFactory.getSerializer('HL7V2').toXML($('Raw Message')));

var msg2 = $('XML Message')['HL7Message'];
logger.info(msg2);

channelMap.put('OBR 2', msg2['OBR.2.1']);

I'd expect to get the value of the field by using notation similar to msg['OBR']['OBR.2']['OBR.2.1'].toString() (the "normal" Mirth notation) by substituting msg with the variable name.

1 Answer 1

1

The difference is xml strings vs xml objects. The serializer returns a string. This will convert your string to an object.

var msg2 = new XML($('XML Message'));
1
  • Thank you! this was bugging me like crazy! I knew it had to be something simple and straightforward like that! Jul 1, 2019 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.