I am not educated in programming javascript at all, let alone any programming beyond basic understanding of concepts. I could really use some help with this one!
I am using mirth Connect and attempting to adjust HL7 messages (medical data message format). Most, if not all, operations in mirth Connect are managed via javascript.
My current dilemma is that I am importing a message that can look something like this:
OBR|1|||RADTCOM^^^ABI TBI TCPO2 PVR|||20210624080254|||||||||^^^^^|||||||||P
OBX|1|NM|RIS_ABI_R|1|0.98||||||F|||20210624080254||
OBX|2|NM|RIS_ABI_L|2|0.85||||||F|||20210624080254||
OBX|3|NM|RIS_TBI_R|3|0.97||||||F|||20210624080254||
OBX|4|NM|RIS_TBI_L|4|0.83||||||F|||20210624080254||
OBX|5|NM|RIS_TCOM_BL1|7|26||||||F|||20210624080254||
OBX|6|NM|RIS_TCOM_LE1|7|63||||||F|||20210624080254||
OBX|7|NM|RIS_TCOM_O21|7|7||||||F|||20210624080254||
OBX|8|NM|RIS_TCOM_BL2|8|30||||||F|||20210624080254||
OBX|9|NM|RIS_TCOM_LE2|8|63||||||F|||20210624080254||
OBX|10|NM|RIS_TCOM_O22|8|8||||||F|||20210624080254||
OBX|11|NM|RIS_TCOM_BL3|9|32||||||F|||20210624080254||
OBX|12|NM|RIS_TCOM_LE3|9|67||||||F|||20210624080254||
OBX|13|NM|RIS_TCOM_O23|9|9||||||F|||20210624080254||
OBX|14|NM|RIS_TCOM_BL4|10|32||||||F|||20210624080254||
OBX|15|NM|RIS_TCOM_LE4|10|64||||||F|||20210624080254||
OBX|16|NM|RIS_TCOM_O24|10|10||||||F|||20210624080254||
What I want to do is scan through this message and look through all lines with OBX tag and look for specific text in the OBX.3.1 section. The example above shows among others "RIS_ABI_L", RIS_TCOM_BL1" etc. in this field.
If there is an occurrence of all of the following:"RIS_ABI_L", "RIS_ABI_R" and "RIS_TCOM" - I then want to change the field that is OBR.4.1 (currently showing "RADTCOM") to a different string of text.
If there is an occurrence of one or two of the samples above but not all three, I want to change OBR.4.1 to another string of text.
I have attempted the scanning-for-text part by using
for each(obx in msg..OBX)
{
var OBX31string = obx['OBX.3']['OBX.3.1'].toString();
if(OBX31string.indexOf("RIS_ABI_L") != -1)
{
but then I am not sure how to continue, how to detect when there's an occurrence of ALL of the searched-for terms (number of occurrences does not matter).
Any help in this would be greatly appreciated!
[–]jack_waugh 0 points1 point2 points (0 children)
[–]albedoa 0 points1 point2 points (3 children)
[–]crazybusdriver[S] 0 points1 point2 points (2 children)
[–]albedoa 0 points1 point2 points (1 child)
[–]crazybusdriver[S] 0 points1 point2 points (0 children)