Announcement

Collapse
No announcement yet.

Identify first Letter in field and create if statement on result

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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

    Comment


    • #3
      Thanks very much it worked a treat

      Comment

      Working...
      X