web stats
Need to move a segment - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-02-2010, 08:26 AM
beefmon beefmon is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Posts: 62
beefmon is on a distinguished road
Default Need to move a segment

I need to move my MRG segment to be right after the PID segment

I am not sure where to start.

I saw the createSegemntAfter command but not sure how to map it.


MSH|^~\&|MT ADM||OV ENG|OV ENG FAC|201006020809||ADT^A34|577711|D|2.4|||AL|NE|
EVN||201006020809|||Grigsby,Diane S.|201005190952|
PID|1||M000000202^^^^MR^ACH~423-72-3479^^^^SS^ACH~T1-20091020102533^^^^PI^ACH~T00000231^^^^HUB^ACH||COL EY^KATRINA^^^^^L|KATHY|19650305|F||X|2101 BATTERY^^Little Rock^AR^72202||501-376-3568|NONE||S|BAP|D00000003088|423-72-3479|
***Need it to go right here***
PV1|1|I|INT^3C-01^B|EMER|||ELSJ^ELSER^JOSEPH^M.^^^M.D.^^^^^^XX||| IM||||ED||Y|RAJA^RAJA^ALI^I.^^^MD^^^^^^XX|IN||MCD| ||||||||||||||||||ACH||ADM|||201005190952|||||||SM IC^SMITH^CHRISTOPHER^E.^^^M.D.^^^^^^XX|SMIC^SMITH^ CHRISTOPHER^E.^^^M.D.^^^^^^XX|
PV2||INT^3C Intermediate Care|DEVIATED SPETUM||||||||14||||||||||||||EMER|||||||||||N|
MRG|M000000893|
Reply With Quote
  #2  
Old 06-02-2010, 10:44 AM
beefmon beefmon is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Posts: 62
beefmon is on a distinguished road
Default

I got this to work but is there a better way to do this?


Code:
createSegmentAfter('MRG', msg['PID'])


msg['MRG'][0]['MRG.1']['MRG.1.1'] = msg['MRG'][1]['MRG.1']['MRG.1.1'].toString() 
msg['MRG'][0]['MRG.2']['MRG.2.1'] = msg['MRG'][1]['MRG.2']['MRG.2.1'].toString() 



delete msg['MRG'][1];
Reply With Quote
  #3  
Old 06-02-2010, 02:53 PM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 407
mourisj is an unknown quantity at this point
Default

Try using the message template and change the segment order there
__________________
JJ Mouris
FFE Luxembourg
IT-Department
Reply With Quote
  #4  
Old 06-03-2010, 04:21 AM
beefmon beefmon is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Posts: 62
beefmon is on a distinguished road
Default

Thanks for the suggestion but the message template thing did not work for me in this instance.

I tweaked the code a bit and threw my "gorilla programming" skills at it.

Works good for me but does anybody see a better way to do this?

Code:
for each (segment in msg.children()) 
{
if(segment.name() == "MRG")
{

	createSegmentAfter('MRG', msg['PID'])

	msg['MRG'][0]['MRG.1']['MRG.1.1'] = msg['MRG'][1]['MRG.1']['MRG.1.1'].toString() 
	msg['MRG'][0]['MRG.2']['MRG.2.1'] = msg['MRG'][1]['MRG.2']['MRG.2.1'].toString()

}
}

delete msg['MRG'][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 12:34 PM.


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