Here is some JavaScript that I put inside of a destination transformer. It traverses every OBR segment and whenever there is a blank Observation date, it copies the Speciment date to the Observation date. Pretty simple requirements. Everything works except the assignment from OBR-14 to OBR-7:
It took a while to figure out that "undefined" is a keyword similar to what null is to a SQL database and should not be placed in quotes. Got that working.
Based on other code examples I expected to use x['OBR']['OBR.7']['OBR.7.1'] to reference this HL7 but this does not work so I used tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR] instead. Why are some able to get this to work and others have not?
The assignment also doesn't work:
tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR]=tmp['OBR']['OBR.14']['OBR.14.1'][CountOBR];
What changes are needed to make this work?
Thanks,
John
Code:
var CountOBR=0; for each (x in tmp..OBR) { if ( tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR]==undefined) { // Set the Observation date equal to the Specimen date tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR]=tmp['OBR']['OBR.14']['OBR.14.1'][CountOBR]; } CountOBR++; }
Based on other code examples I expected to use x['OBR']['OBR.7']['OBR.7.1'] to reference this HL7 but this does not work so I used tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR] instead. Why are some able to get this to work and others have not?
The assignment also doesn't work:
tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR]=tmp['OBR']['OBR.14']['OBR.14.1'][CountOBR];
What changes are needed to make this work?
Thanks,
John
Comment