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

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
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



Code:
// 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
  // else do not sent message out via TCP/IP

Example XML output

Code:
 <MSH.6>
            <ZDC.3>
                <ZDC.3.1>Murphy</ZDC.3.1>
                <ZDC.3.2>Charles</ZDC.3.2>
                <ZDC.3.3/>
                <ZDC.3.4/>
                <ZDC.3.5>NSP</ZDC.3.5>
            </ZDC.3>
            <ZDC.2>
                <ZDC.2.1>132877</ZDC.2.1>
                <ZDC.2.2/>
                <ZDC.2.3/>
                <ZDC.2.4/>
                <ZDC.2.5>PAS</ZDC.2.5>
            </ZDC.2>
            <ZDC.7>
                <ZDC.7.1>GP</ZDC.7.1>
            </ZDC.7>
        </MSH.6>
Attached Files
File Type: xml HL7toXML Route.xml (16.9 KB, 0 views)
File Type: txt Sample XML Output.txt (3.5 KB, 1 views)
File Type: txt Test MDM HL7 to XML.txt (584 Bytes, 0 views)

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

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.

Code:
msg['ZDC'][0]['ZDC.7']['ZDC.7.1'].toSring
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.
Code:
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
Code:
msg['MSH']['MSH.6']['MSH.6.1'] = renameField(msg['ZDC'][0]['ZDC.3'], 'MSH.6.1');
Reply With Quote
Reply

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 09:15 PM.


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