I have a channel's source data as HL7 v2.x ADT with a destination's template also HL7 v2.x. All source messages contain at least one IN1 segment. I am having diffiulty getting Mirth to automatically add more than one IN1 segment to the outgoing data template.
My javascript step looks like this:
When I process a source message with more than one IN1 segment, the output is a single IN1 segment with mutliple sub-fields. In the following output example, the source ADT-A04 had 3 IN1 segments:
IN1|1|100|
IN1|2|100|
IN1|3|100|
...resulting in output:
IN1|1^2^3|100^100^100|
The output is the same whether the index (i) is included and incremented, or not. What am I doing wrong?
My javascript step looks like this:
Code:
var i = 0; var tempInsuranceCarrierID = "" while (msg['IN1']['IN1.3']['IN1.3.1'][i] != null) { tempInsuranceCarrierID = msg['IN1']['IN1.3']['IN1.3.1'][i].toString(); if (tempInsuranceCarrierID.length > 0) { logger.info(i + ' insurance Carrier ID = ' + tempInsuranceCarrierID); tmp['IN1']['IN1.1']['IN1.1.1'][i] = msg['IN1']['IN1.1']['IN1.1.1'][i] tmp['IN1']['IN1.2']['IN1.2.1'][i] = msg['IN1']['IN1.2']['IN1.2.1'][i] ... ... } i = i + 1 }
IN1|1|100|
IN1|2|100|
IN1|3|100|
...resulting in output:
IN1|1^2^3|100^100^100|
The output is the same whether the index (i) is included and incremented, or not. What am I doing wrong?
Comment