Announcement

Collapse
No announcement yet.

E4X Filtering

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

  • E4X Filtering

    Hi everyone,
    What's the correct E4X syntax to select a specific instance of a repeating field based on a value within one of the repetitions.

    PID.3:
    |100200300^^^^MR~100300400^^^^EP~100400500^^^^CN|

    Using E4X, I want to be able to say something like:

    var id = "the instance of PID.3 in which the value of PID.3.5 is EP"

    I have tried a bunch of things with E4X but can't quite get it.
    For instance:
    var id = msg['PID']['PID.3'[msg['PID']['PID.3']['PID.3.5'].toString().toLowerCase == 'mr']];


    Any help appreciated.

    Thank you!

    Steve

  • #2
    How about using if statement?

    var len=msg['PID']['PID.3'].length();

    for(i=0; i<len; i++)
    {
    if(msg['PID']['PID.3'][i]['PID.3.5'].toString() =="MR")
    {
    var ID =msg['PID']['PID.3'][i]['PID.3.1'].toString()
    }
    }

    logger.info(ID)

    ________________________
    Last edited by flyerman; 07-12-2015, 04:47 PM.

    Comment


    • #3
      Thanks for the reply. That's the exact code I started with, but somehow my ID is being overwritten. I'll keep trying.

      Comment

      Working...
      X