web stats
Combine Two Z Segments Into One - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 09-03-2013, 09:08 AM
nplaisted nplaisted is offline
What's HL7?
Join Date: Jul 2012
Posts: 5
nplaisted is on a distinguished road
Default Combine Two Z Segments Into One

We have an inbound HL7 feed that often contains multiple ZP2 segments in a single message. We have a problem with values that should be in the same segment being split into 2 segments. The vendor will only fix it on their side for a large fee, so we are trying to fix it within Mirth Connect, but are a little stumped how to go about it.

Here is an example of the ZP2 segments:

ZP2|1|P|30|O|FAM||||||||1000||22|||Coinsurance Out of Network|EXCLUDES DEDUCTIBLE|||
ZP2|1|P|60|O|IND||||||||1000||22|||Coinsurance Out of Network|EXCLUDES DEDUCTIBLE|||

What I need to do with these ZP2 segments is this:
- If ZP2.1 through ZP2.5 are all the same in 2 diferent segments, Then move the value from ZP2.14 from the 2nd segment into the first segment, and then delete the 2nd ZP2 segment.

Note: there could be many more ZP2 segments with all different values. Some will have a match and need this transformation, some will not.

So for the example above, the outbound ZP2 segments should look like this:

ZP2|1|P|30|O|FAM||||||||1000|2000|22|||Coinsurance Out of Network|EXCLUDES DEDUCTIBLE|||
ZP2|1|P|60|O|IND||||||||1000|2000|22|||Coinsurance Out of Network|EXCLUDES DEDUCTIBLE|||

Ultimately what we are trying to do is call a stored procedure for each ZP2 segment, but when that ZP2.14 value is not in the same segment it does not work.

I hope all this makes sense. Any guidance getting started on this would be greatly appreciated.
Reply With Quote
Old 09-04-2013, 11:08 PM
glenn71 glenn71 is offline
OBX.3 Kenobi
Join Date: Nov 2010
Location: Sydney Australia
Posts: 129
glenn71 is on a distinguished road

I am no expert... but possibly something like this?

var z1 = '';
var z2 = '';
var z3 = '';
var z4 = '';
var z5 = '';
var i = -1;

for each (z in msg.ZP2)
    if (z1 != z['ZP2.1'].toString() || z2 != z['ZP2.2'].toString() || 
        z3 != z['ZP2.3'].toString() || z4 != z['ZP2.4'].toString() || 
        z5 != z['ZP2.5'].toString() ) 
        z1 = z['ZP2.1'].toString();
        z2 = z['ZP2.2'].toString();
        z3 = z['ZP2.3'].toString();
        z4 = z['ZP2.4'].toString();
        z5 = z['ZP2.5'].toString();
    } else {
       msg['ZP2'][i]['ZP2.14'] = z['ZP2.14'].toString();
       delete z;

Last edited by glenn71; 09-04-2013 at 11:27 PM.
Reply With Quote

combine segments, iterate, loop segments repeating, segment, z segment

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 07:19 AM.

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