Sidebar

Need to remove and replace a field regardless of it being blank or not

0 votes
260 views
asked Jul 6, 2020 by adam-d-5091 (320 points)
Forgive the noobie question but this has me stumped at this point. I simply would like to remove the contents of a field and replace if sometihng is there or add something to the field if it is blank. Below is my sample message:

 

MSH|^~\&|Paxera|Physicians East|Insight Medical|Physicians East|20200427145126||ORU^R01^ORU_R01|20200427145126|P|2.3.1|||NE||||eng^English^ISO639|||

I would like to make MSH-9 to always be ORU^R01

I currently have:

if (source.getNode("MSH-9") == "ORU^R01^ORU_R01") {
   message.setNode("MSH-9", "ORU^R01");
}

 

I know my issue here is it is always looking for ORU^R01^ORU_R01 hence why it isnt working every time.

 

Anyway, thanks in advance!

1 Answer

+1 vote
 
Best answer

Remove the if statement:

change:

if (source.getNode("MSH-9") == "ORU^R01^ORU_R01") {
   message.setNode("MSH-9", "ORU^R01");
}

to

message.setNode("MSH-9", "ORU^R01");

answered Jul 6, 2020 by michael-h-5027 (14,350 points)
selected Jul 6, 2020 by adam-d-5091
...