web stats
IF Statements in Mirth? - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2013, 09:22 AM
R A R A is offline
OBX.3 Kenobi
 
Join Date: Jan 2012
Location: London, UK
Posts: 173
R A is on a distinguished road
Default IF Statements in Mirth?

Code:
AdmittingDoctor = msg['PV1']['PV1.9']['PV1.9.1'].toString();
if (AdmittingDoctor.substring(1,2) = "G")	
	{
	AdmittingDoctor =  "C9999998";
	};
Simple thing, and I have if ststements but never with a substring, but am getting an error with the above.

Basically if the field begins with a G set field to C9999998.

Can anyone see if I am doing something wrong?

Error
Code:
OURCE CODE:
	168: */169: 170: Specialty = msg['PV1']['PV1.10']['PV1.10.1'].toString();171: 172: AdmittingDoctor = msg['PV1']['PV1.9']['PV1.9.1'].toString();173: if (AdmittingDoctor.substring(1,2) = "G")
	{174: 
	AdmittingDoctor =  "C9999998";175: 
	};176: 177: /*LINE NUMBER:
	173DETAILS:
	ReferenceError: Function function substring() { [native code for String.substring, arity=2] } can not be used as the left-hand side of assignment or as an operand of ++ or -- operator. (com.mirth.connect.server.MirthJavascriptTransformerException) (org.mule.umo.transformer.TransformerException)

Last edited by R A; 03-13-2013 at 09:25 AM.
Reply With Quote
  #2  
Old 03-13-2013, 11:12 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,040
cory_cole is on a distinguished road
Default

if (AdmittingDoctor.substring(1,2) == "G") not
if (AdmittingDoctor.substring(1,2) = "G")
Reply With Quote
  #3  
Old 03-18-2013, 05:15 AM
R A R A is offline
OBX.3 Kenobi
 
Join Date: Jan 2012
Location: London, UK
Posts: 173
R A is on a distinguished road
Default

Quote:
Originally Posted by cory_cole View Post
if (AdmittingDoctor.substring(1,2) == "G") not
if (AdmittingDoctor.substring(1,2) = "G")

Brilliant, did wonder this as I have used the == before

Does the same apply for blanks/nulls?

i.e.
Code:
if (ReferringDoctor == "")	
	{
	ReferringDoctor =  "C9999998";
	};
Many Thanks
Reply With Quote
  #4  
Old 03-18-2013, 06:01 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,040
cory_cole is on a distinguished road
Default

Yes.

== comparison equals
= set equals
Reply With Quote
  #5  
Old 03-18-2013, 08:12 AM
R A R A is offline
OBX.3 Kenobi
 
Join Date: Jan 2012
Location: London, UK
Posts: 173
R A is on a distinguished road
Default

Quote:
Originally Posted by cory_cole View Post
Yes.

== comparison equals
= set equals
brilliant, thanks
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:09 PM.


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