web stats
Easy way to swap segments? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-29-2012, 12:34 PM
nhaerich nhaerich is offline
OBX.2 Kenobi
 
Join Date: Oct 2010
Posts: 97
nhaerich is on a distinguished road
Default Easy way to swap segments?

I have a vendor that requires PID3 & PID18 to be swapped in ADT messages. Being still new to Mirth, is there an easy way to do this?

Thanks
Reply With Quote
  #2  
Old 08-29-2012, 12:43 PM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

var PID3 = msg['PID']['PID.3']['PID.3.1'].toString();
var PID18 = msg['PID']['PID.18']['PID.18.1'].toString();

msg['PID']['PID.3'] = PID18;
msg['PID']['PID.18'] = PID3;
Reply With Quote
  #3  
Old 08-29-2012, 04:15 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Quote:
Originally Posted by cory_cole View Post
var PID3 = msg['PID']['PID.3']['PID.3.1'].toString();
var PID18 = msg['PID']['PID.18']['PID.18.1'].toString();

msg['PID']['PID.3'] = PID18;
msg['PID']['PID.18'] = PID3;
Careful, that'll only swap the first components for each field. Also, in that case you're changing the nodes from complex to simple, so that may make other things break later on, depending on your code (if you're using the ER7 serializer for example).

A safer way is to swap the nodes in their entirety (you'll need this):

Code:
msg.PID['PID.3'] = [renameField(msg.PID['PID.18'],'PID.3'), msg.PID['PID.18'] = renameField(msg.PID['PID.3'],'PID.18')][0];
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
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 11:44 AM.


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