No announcement yet.

Priority Flag

  • Filter
  • Time
  • Show
Clear All
new posts

  • Priority Flag

    Can someone help me with a javascript:I have to check for key words in an ORU message and then return them as urgent, critical or normal based on the report content:
    So if I see a word “PRIORITY” at the end of the report, I need to then check for list of key words:
    · malignancy
    · cancer
    · cancer follow up
    · lesion
    etc., and then change the alert code as “U”, if there is no above list of words, it has to flag as “T” and all other reports without urgent needs to have “N”.
    current script what I have is it checks for urgent only, struggling to check for a list of words:var found = 0;
    for each (seg in msg..OBX)
    var str = seg['OBX.5']['OBX.5.1'].toString();if (str.match(/priority/i))
    found = 1;
    if (found != 1)
    for each (seg in msg..OBR)
    seg['OBR.27']['OBR.27.6'] = "N"
    if (found == 1)
    for each (seg in msg..OBR)
    seg['OBR.27']['OBR.27.6'] = "T";

  • #2
    Hope my interpretation of the challenge is accurate but the below will traverse the msg OBRs and collect the corresponding OBXs. Along the way it'll check the last OBX for any occurrence of 'priority'. If 'priority' is found, a priority flag is set and processing of the OBXs continues while checking for key values from the list. If a value from the list is found, a key found flag is set. After OBX processing completes, the OBR-27.6 field is set based upon the findings for the priorityFound and keyFound flags.

    function xlateOBR() {
      for each (obr in msg.OBR) {
        /** CUSTOM OBR MAPPINGS CAN GO HERE ie. obr['OBR.1'] = ... etc. */
        //xlate OBX
        var priorityFound = false
        var keyFound = false
        var obxGrp = getSegmentsAfter(msg,obr,'OBX',false)
        //check for any occurrence of priority in the last OBX segment
        if (msg.children()[obxGrp[obxGrp.length-1].childIndex()]['OBX.5']['OBX.5.1'].toString().toUpperCase().match(/PRIORITY/)) {
          priorityFound = true
        //loop thru OBXs
        for (var obxIdx = 0; obxIdx <= obxGrp.length-1; obxIdx++) {
          var obx = msg.children()[obxGrp[obxIdx].childIndex()]
          /** CUSTOM OBX MAPPINGS CAN GO HERE ie. obx['OBX.1'] = ... etc. */
          if (priorityFound && ! keyFound) {
            //check OBX for key words
            if (obx['OBX.5']['OBX.5.1'].toString().toUpperCase().match(/MALIGNANCY|CANCER|LESION/)) {
              keyFound = true
        }//end OBX loop
        //map OBR priorities
        if (priorityFound) {
          if (keyFound) {
            obr['OBR.27']['OBR.27.6'] = 'U'   //priority w/urgent needs (Urgent)
          } else {
              obr['OBR.27']['OBR.27.6'] = 'T'  //priority w/o urgent needs (Critical)
        } else {
            obr['OBR.27']['OBR.27.6'] = 'N'  //all other w/o urgent needs (Normal)
      }//end OBR loop
    }//end function xlateOBR
    //call xlateOBR
    If this doesn't fit the requirements and a sample HL7 message can be provided, I'm happy to take another look.
    Last edited by jkrebs; 05-26-2020, 06:45 AM.


    • #3
      Thank you

      will check this and update


      • #4
        Adding the link to the getSegmentsAfter function in case you don't have it.