web stats
Accepting wanted segments instead of deleting the unwanted ones. - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 06-14-2012, 07:14 AM
bob.nwl bob.nwl is offline
What's HL7?
Join Date: May 2012
Location: New Albany, IN
Posts: 4
bob.nwl is on a distinguished road
Default Accepting wanted segments instead of deleting the unwanted ones.

Currently my transformer deletes a list of unwanted segments.
delete msg['ZIR'];
delete msg['ZEN'];
delete msg['ZSP'];
Is there a way to keep only the segments that I need without using the static delete so that changes in the source message such as adding another z or IN segment do not affect the channel?

Something along the lines of:

If segment is not MSH, PID PV1 then delete segment.
Reply With Quote
Old 06-14-2012, 08:00 AM
cory_cole cory_cole is offline
Mirth Guru
Join Date: Mar 2012
Posts: 1,299
cory_cole is on a distinguished road

for each (seg in msg)
segName = seg.name().toString();
if(segName != 'PID' && segName != 'MSH' && segName != 'PV1')
delete seg;
Reply With Quote
Old 06-18-2012, 12:59 PM
Bostad Bostad is offline
Level 85 Channel Wizard
Join Date: Mar 2009
Location: Stratford Ontario
Posts: 712
Bostad is an unknown quantity at this point

If you have a large set of segments you want to keep you could do this:

var strGoodSeg = 'MSH~PID~PV1~NK1~OBR'  //you get the point right?

for each (seg in msg.children()) {

   var strCurSeg = seg.name();

   if (strGoodSeg.indexOf(strCurSeg) < 0) {     //okay to delete

         delete seg;

I can be reached through gmail and Google Talk using davidrothbauer at gmail dot com

Test all my code suggestions prior to implementation
Reply With Quote

delete segment, 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 06:04 AM.

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