I am trying to write a JavaScript to remove string in OBX 5.1 after "\."
Here is the inbound OBX segment:
OBX|2|NM|WBC^White Blood Cell Count^WinPath||3.2\\.br\\This result could indicate your patient might have\\.br\\sepsis. Take into consideration the absolute\\.br\\neutrophil and lymphocyte counts when making your|x 10^9/l|4 - 10|L|||F|||||
Here is the expected outbound OBX segment:
OBX|2|NM|WBC^White Blood Cell Count^WinPath||3.2|x 10^9/l|4 - 10|L|||F|||||
I have written this Javascript code. It is compiling but not removing the unwanted text.
Here is what I have written:
var RegExp_pattern = "\\.";
function indexOf(stringToTrim) {
return stringToTrim.indexOf(RegExp_pattern);
}
function substring(ssstringToTrim) {
return ssstringToTrim.substring(indexOf(OBX_TestValue), -1);
}
/* Single input message case */
var next = output.append(input[0]);
// loop through Order Group (OBR) & Result Group (OBX)
//
var cntObs = next.getRepeatCount("ObservationMessage");
for (var i = 0; i < cntObs; i++) {
var cntOrders = next.getRepeatCount("ObservationMessage[" + i + "]/Order");
for (var j = 0; j < cntOrders; j++) {
var cntResults = next.getRepeatCount("ObservationMessage[" + i + "]/Order[" + j + "]/Results");
for (var k = 0; k < cntResults; k++) {
var OBX_TestValue = next.getField("ObservationMessage[" + i + "]/Order[" + j + "]/Results[" + k + "]/OBX/ObservationValue");
if (OBX_TestValue.indexOf(OBX_TestValue) > 0) {
OBX_TestValue = substring(OBX_TestValue);
}
}
}
}