web stats
Converting HL7 2.4 to XML - custom Z segment filed/components not recognised - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 03-14-2019, 08:26 AM
Mark Sull Mark Sull is offline
Mirth Newb
Join Date: Apr 2018
Location: Ireland
Posts: 13
Mark Sull is on a distinguished road
Default Converting HL7 2.4 to XML - custom Z segment filed/components not recognised

Hi All,

I have built a route to convert a pipe HL7 2.4 message to XML. I need to manipulate the message so that specific Z segment fields are placed in the MSH segment. However, mirth places all fields behind a component as opposed to a specific/individual field.

In below code I want to check if the first iteration of a Z (ZDC) segment has the value 'GP' in the ZDC.7.1, if true then populate MSH-9. If false then do not send the message outbound via TCP/IP route.

1. Do you need to define Z segments/components in order to map individually fields?
2. Is there a function in mirth, to stop processing and not send the message outbound as the criteria is not satisfied in the if statement?

Thanks in advance

// If ZDC segment 1 equals GP then place values in MSH , else do not sent message out via TCP/IP
if (msg['ZDC'][0]['ZDC.7']['ZDC.7.1'].toSring == 'GP'){
   msg['MSH']['MSH.6']['MSH.6.1']= XML(msg['ZDC']['ZDC.3'].toString());
   msg['MSH']['MSH.6']['MSH.6.2']= XML(msg['ZDC']['ZDC.2'].toString());
   msg['MSH']['MSH.6']['MSH.6.3']= XML(msg['ZDC']['ZDC.7'].toString());
  // else do not sent message out via TCP/IP

Example XML output

Attached Files
File Type: xml HL7toXML Route.xml (16.9 KB, 2 views)
File Type: txt Sample XML Output.txt (3.5 KB, 2 views)
File Type: txt Test MDM HL7 to XML.txt (584 Bytes, 1 views)

Last edited by Mark Sull; 03-14-2019 at 08:28 AM.
Reply With Quote
Old 03-14-2019, 03:56 PM
agermano agermano is offline
Mirth Guru
Join Date: Apr 2017
Location: Indiana, USA
Posts: 712
agermano is on a distinguished road

To answer your second question first, you can do that check in the filter instead of the transformer.

You have a typo in your code that could possibly be causing an issue.

This will always return an empty string, and so won't match 'GP'.

If you are already filtering messages you shouldn't have to check the value again in the transformer.

Just to clean up your code a bit, the following two lines produce similar (though, still not what you need) results. You don't need to stringify and create new xml objects every time.
msg['MSH']['MSH.6']['MSH.6.1']= XML(msg['ZDC']['ZDC.3'].toString());
msg['MSH']['MSH.6']['MSH.6.1']= msg['ZDC']['ZDC.3'];
Here is a code template function that should get you where you need to go: https://github.com/nextgenhealthcare...%20HL7%20Field

Then you can do
msg['MSH']['MSH.6']['MSH.6.1'] = renameField(msg['ZDC'][0]['ZDC.3'], 'MSH.6.1');
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 01:41 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation