web stats
Replacing Multiple Special Characters in OBX Segments - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-27-2019, 11:31 AM
Kprince Kprince is offline
Mirth Newb
 
Join Date: Jul 2016
Posts: 7
Kprince is on a distinguished road
Default Replacing Multiple Special Characters [&,\, ETC] in OBX Segments

Hi All,

I'm trying to replace multiple special characters [&,\] in repeating OBX segments.
The source system allows free texting and doesn't escape them so I need a transform.

I'm currently using the following transform but it doesn't handle the [&].
It reads as a subcomponent so I end up with <OBX.5.1><OBX.5.1.1> tags around the Text when there's an &.

Code:
for (var i=0;i<msg['OBX'].length();i++) {
            msg['OBX'][i]['OBX.5'] = msg['OBX'][i]['OBX.5']['OBX.5.1'].toString().replace(/\\/g, "/");
            
};
How can I update this to handle the &?

Last edited by Kprince; 06-27-2019 at 11:38 AM.
Reply With Quote
  #2  
Old 06-27-2019, 11:47 AM
Kprince Kprince is offline
Mirth Newb
 
Join Date: Jul 2016
Posts: 7
Kprince is on a distinguished road
Default

Adding message sample for Clarity

Code:
OBX|1|TX|ExamCol^Colonoscopy^Unknown|1|HISTORY & PHYSICAL||||||C|||20190625075326|1040
OBX|2|TX|ExamCol^Colonoscopy^Unknown|1|\||||||C|||20190625075326|1040

transformed

OBX|1|TX|ExamCol^Colonoscopy^Unknown|1|<OBX.5.1><OBX.5.1.1>HISTORY </OBX.5.1.1><OBX.5.1.2> PHYSICAL</OBX.5.1.2></OBX.5.1>||||||C|||20190625075326|1040
OBX|5|TX|ExamCol^Colonoscopy^Unknown|1|/||||||C|||20190625075326|1040
Reply With Quote
  #3  
Old 06-27-2019, 02:37 PM
jg12345 jg12345 is offline
OBX.3 Kenobi
 
Join Date: Oct 2012
Posts: 106
jg12345 is on a distinguished road
Default

In 'Summary' tab, choose 'Data Types' button and untick 'Parse Subcomponents'

Code:
for each (seg in msg.OBX) {
	if(seg['OBX.5']['OBX.5.1'].toString() !='') {
	var temp = seg['OBX.5']['OBX.5.1'].toString();
	seg['OBX.5'] = temp.replace("&","AND");
	}
}
Reply With Quote
  #4  
Old 06-27-2019, 03:20 PM
Kprince Kprince is offline
Mirth Newb
 
Join Date: Jul 2016
Posts: 7
Kprince is on a distinguished road
Default

Thanks That works.
I forgot to disable parsing of Subcomponents.
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 05:57 AM.


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