Announcement

Collapse
No announcement yet.

transformer: search a value in string of a segment

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

  • 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?

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

    Comment


    • #3
      great job

      Many thanks. Thats it....
      Thank You....

      Comment

      Working...
      X