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

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2012, 06: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
  #2  
Old 06-14-2012, 07:00 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,225
cory_cole is on a distinguished road
Default

for each (seg in msg)
{
segName = seg.name().toString();
if(segName != 'PID' && segName != 'MSH' && segName != 'PV1')
{
delete seg;
}
}
Reply With Quote
  #3  
Old 06-18-2012, 11:59 AM
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
Default

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

Code:
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
http://www.linkedin.com/pub/david-rothbauer/5/923/518
codeismydrug.wordpress.com
hl7coders.wordpress.com

Test all my code suggestions prior to implementation
Reply With Quote
Reply

Tags
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 01:17 AM.


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