web stats
Identify first Letter in field and create if statement on result - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-06-2019, 07:45 AM
lukebuckley lukebuckley is offline
What's HL7?
 
Join Date: Feb 2019
Posts: 3
lukebuckley is on a distinguished road
Default Identify first Letter in field and create if statement on result

Hello,

I'm new to both Mirth and XML, so I hope this isn't a stupid question


I'm trying to populate the PV1-2 segment(Patient Class) based on the first letter of the PV1-19-1(Visit Number ID) If the Visit Number begins with 'I' then Insert 'I' in PV1-2 and same logic if the value is 'O' for outpatient.

At the moment this is a far as I could get. I know that the equals function is not incorrect but I cannot find any function that will let me specify the first Letter


Code:
if(msg['PV1']['PV1.19']['PV1.19.1'].toString().equalsIgnoreCase('O'))
{
	
	msg['PV1']['PV1.2'] ='O';
	
}else if(msg['PV1']['PV1.19']['PV1.19.1'].toString().equalsIgnoreCase('I'))
{
	
	msg['PV1']['PV1.2'] ='I';

}
If anyone can help I would be much obliged
Reply With Quote
  #2  
Old 03-08-2019, 08:25 AM
AlexNeiva AlexNeiva is offline
Mirth Guru
 
Join Date: Oct 2013
Location: Portugal
Posts: 277
AlexNeiva is on a distinguished road
Default

Hello lukebuckley,


please try this javascript code:


Code:
if(msg['PV1']['PV1.19']['PV1.19.1'].toString().charAt(0)=='O')
   ...

give it a try.




Best Regards
__________________
Best Regards,
Alex Neiva
Reply With Quote
  #3  
Old 03-14-2019, 04:09 AM
lukebuckley lukebuckley is offline
What's HL7?
 
Join Date: Feb 2019
Posts: 3
lukebuckley is on a distinguished road
Default

Thanks very much it worked a treat
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 01:19 AM.


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