Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mirth processing multiple segments

Tags:

mirth

Here I am doing some mapping for Next of Kin $('Nok') (see mapping table).

Then to process this I have the Javascript below. The reason that I am trying this was is, at times we get multiple next of kin segments come through. If that is the case, mirth throws error as ‘DETAILS: TypeError: Assignment to lists with more than one item is not supported’

var i = 0;
msg['NK1'][i]['NK1.3']['NK1.3.1'] = $('NoK')

for each ( nk1 in msg.NK1) {
   nk1 = $('NoK').toString();
   i++;
}

But unfortunately my script doesn’t work. Basically, it doesn’t throw any error, but it doesn’t do what it supposed to do for multiple segment. It does works for a single segment

This my outbound message:

NK1|1|BENNY^BEN^^^MR^^L|<12K1.3.1>22<12K1.3.1>627^^RELTN|PRETTY GREEN^LONDON^""^""^GH15 3KW^^^Q36|||^^RELT|20030321|||||||9 NK1|2|^^^^^^L|SP^^RELTN|41 PIPERS GREEN^LONDON^""^""^NW9 8UH^^^Q36|||^^RELT|20010923|||||||9

like image 365
dushi kanagasabai Avatar asked May 10 '26 08:05

dushi kanagasabai


1 Answers

for(var i = 0; i< msg['NK1'].length(); i++) {
    msg['NK1'][i]['NK1.3']['NK1.3.1'] = YourTransformerFunction(msg['NK1'][i]['NK1.3']['NK1.3.1'].toString());
}

length needed () to work.

like image 87
Amin Wahi Avatar answered May 15 '26 09:05

Amin Wahi