1
votes

Hi I'm trying to change the code and value in HL7 using Javascript in Mirth Connect. If the incoming msg has Code labeled 'B' and B = Boy and I want to change the outgoing message to 'M' and M = Male. How would I do that if the HL7 msg segment is in msg['PID']['PID.8']['PID.8.1']. I wrote down what I think the coding is below. Is it correct or am I missing something?

var PID8 = msg['PID']['PID.8']['PID.8.1']

var B = 'Boy'

var M = 'Male'

if (PID8 === B) {

msg['PID']['PID.8']['PID.8.1']().toString= 'M';

 } else if ('M');
1
What is the type of msg['PID']['PID.8']['PID.8.1'] ? Also, your else if clause is useless, you can remove it.Serge K.
The msg['PID']['PID.8']['PID.8.1'] is the location where the gender value is located in the HL7 messages.smathew
Yes, is it a String or a function ? You can log it using console.log and typeof msg['PID']['PID.8']['PID.8.1'].Serge K.

1 Answers

0
votes
// if B for Boy
if (msg['PID']['PID.8']['PID.8.1'].toString() == 'B') {
    // change to M for Male
    msg['PID']['PID.8']['PID.8.1'] = 'M';
}