web stats
Check which segment of AIP exists - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2017, 07:05 PM
DragonQueen DragonQueen is offline
OBX.1 Kenobi
 
Join Date: Aug 2016
Posts: 37
DragonQueen is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 03-30-2017, 05:40 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

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
Reply With Quote
Reply

Tags
javascript, segment

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 02:12 AM.


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