Announcement

Collapse
No announcement yet.

Check which segment of AIP exists

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

  • Check which segment of AIP exists

    We receive the provider id in either ['AIP'][2]['AIP.3']['AIP.3.1'] or ['AIP'][1]['AIP.3']['AIP.3.1'] if ['AIP'][2]['AIP.3']['AIP.3.1'] segment does not exist.
    I tried using if statement with .length > 0 but I get this error:

    TypeError: Cannot call method "length" of undefined

    I am using Mirth 3.4.1

  • #2
    Try this

    Code:
    providerID='';
    if(msg['AIP'].length() > 1) {//more than one AIP segment 
    if(msg['AIP'].length() == 2)  { //contains exactly 2 AIPs
    if(msg['AIP'][2]['AIP.3']['AIP.3.1']) providerID=msg['AIP'][2]['AIP.3']['AIP.3.1'].toString();
    if(!msg['AIP'][2]['AIP.3']['AIP.3.1']) providerID=msg['AIP'][1]['AIP.3']['AIP.3.1'] .toString();
    }
    }
    else providerID=msg['AIP']['AIP.3']['AIP.3.1'].toString();  // for only one AIP
    HL7v2.7 Certified Control Specialist!

    Comment

    Working...
    X