web stats
transformer: search a value in string of a segment - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-24-2020, 06:24 AM
Polly Polly is offline
Mirth Newb
 
Join Date: Jun 2017
Posts: 8
Polly is on a distinguished road
Default transformer: search a value in string of a segment

Hello,

I have follow Problem.

I have a transformer with 3 conditions. Only all conditions are true, the transformer make the changes.
My Problem is the third condition.

Code:
if (msg['MSH']['MSH.9']['MSH.9.2'].toString() == 'A08' && msg['PV1']['PV1.2']['PV1.2.1'].toString() == 'V' && msg['EVN']['EVN.4']['EVN.4.1'].toString() == '50')
{
	msg['MSH']['MSH.9']['MSH.9.2'] = "A01";
	msg['EVN']['EVN.1']['EVN.1.1'] = "A01";
	msg['PV1']['PV1.2']['PV1.2.1'] = "P";	
	return true;
}
The Segment EVN.4.1 has different values. Only the string contains the value 50, the transformer condition is true.
Succinct I want to search the value 50 in the string.
Examples for the EVN.4.1. = |43~50~2~59~11| or |43~2~50~20|

Can anybody help me?
Reply With Quote
  #2  
Old 03-24-2020, 09:01 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

You have multiple msg['EVN']['EVN.4']['EVN.4.1']. So Try this...

var evn = false;
for each(evn4 in msg['EVN']['EVN.4']['EVN.4.1'])
{
if (evn4.toString() == 50)
{
evn = true;
}

}//I did it this to prevent testing of all conditions every time.

if (msg['MSH']['MSH.9']['MSH.9.2'].toString() == 'A08' && msg['PV1']['PV1.2']['PV1.2.1'].toString() == 'V' && evn)
{
msg['MSH']['MSH.9']['MSH.9.2'] = "A01";
msg['EVN']['EVN.1']['EVN.1.1'] = "A01";
msg['PV1']['PV1.2']['PV1.2.1'] = "P";
return true;
}
Reply With Quote
  #3  
Old 03-24-2020, 11:01 AM
Polly Polly is offline
Mirth Newb
 
Join Date: Jun 2017
Posts: 8
Polly is on a distinguished road
Default great job

Many thanks. Thats it....
Thank You....
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:05 PM.


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