I've been banging my head against this problem for an hour, and I can't figure it out.
I have a JSON template, called "JSON Treatment Component Template" as follows:
{
"type": "/*{s:RXC-1}*/",
"code": "/*{s:RXC-2}*/",
"amount": "/*{s:RXC-3}*/",
"units": "/*{s:RXC-4}*/",
"strength": "/*{s:RXC-5}*/",
"strength_units": "/*{s:RXC-6}*/"
}
I have an HL7 message with the following RXC segments:
RXC|B|NSS250^SOD CHLOR 0.9% INJ|250|ML|250|ML|
RXC|A|VANC500I^VANCOMYCIN|1500|MG|500|MG|
When I run the following code, I expect two entries in the JSON, one for the "SOD CHLOR" and another for "VANCOMYCIN"
var rxcSegments = source.getAllNodes('RXC');
template = qie.getVariable('JSON Treatment Component Template');
for (var x = 0; x < rxcSegments.length; x++) {
var rxcSegment = qie.parseHL7String(rxcSegments[x]);
var jsonObs;
jsonObs = qie.evaluateTemplate(template, null, 'JSON', true, null, rxcSegment);
message.addObjectToJSONArray('/components', jsonObs);
}
However, this is the JSON output!
"components": [
{
"type": "B",
"code": "NSS250^SOD CHLOR 0.9% INJ",
"amount": "250",
"units": "ML",
"strength": "250",
"strength_units": "ML"
},
{
"type": "B",
"code": "NSS250^SOD CHLOR 0.9% INJ",
"amount": "250",
"units": "ML",
"strength": "250",
"strength_units": "ML"
}
]
It makes no sense!