1

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');
Serge K.
  • 5,303
  • 1
  • 20
  • 27
smathew
  • 11
  • 2
  • 2
    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. Sep 25 '17 at 12:30
  • The msg['PID']['PID.8']['PID.8.1'] is the location where the gender value is located in the HL7 messages. – smathew Sep 26 '17 at 12:39
  • 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. Sep 26 '17 at 12:58

1 Answers1

0
// 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';
}
agermano
  • 1,679
  • 6
  • 16
  • Although this code might solve the problem, a good answer should also explain **what** the code does and **how** it helps. – BDL Apr 02 '20 at 11:13
  • @BDL it's only two lines and both of them are commented with what they do? – agermano Apr 02 '20 at 21:28