Removing specific OBX segments from an ORU msg using TCL

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Removing specific OBX segments from an ORU msg using TCL

  • Creator
    Topic
  • #48341
    Jill Marcotte
    Participant

      I’m attempting to remove OBX segments that are not equal to BUN or CREATININE in an ORU message that may contain more than just those two results.

      Attached is the tcl proc thus far.  When testing with an inbound result such as a metabolic panel, it is not selecting the BUN and CREATININE only in the outbound message.  Any suggestions are appreciated.

      ######################################################################

      # Name: tps_remove_specific_obx

      # Purpose: remove specific OBX segments

      # UPoC type: tps

      # Args: tps keyedlist containing the following keys:

      #       MODE    run mode (“start”, “run” or “time”)

      #       MSGID   message handle

      #       ARGS    user-supplied arguments:

      #              

      #

      # Returns: tps disposition list:

      #          

      #

      proc tps_remove_specific_obx {args} {

       keylget args MODE mode

       switch -exact — $mode {

         run {

      keylget args MSGID mh

      set msg [msgget $mh]

      set segs [split $msg r]

             set msg “”

      set obxloc [lsearch -regexp $segs “^OBX”]

      set obxseg [lindex $segs $obxloc]

      set obxtxt [lindex [split $obxseg |] 5]

      set obx_fld2 [lindex [split $obxseg |] 2]

      set obx_fld3 [lindex [split $obxseg |] 3]

      set obx_fld31 [lindex [split $obx_fld3 ^] 1]

      set obx_fld4 [lindex [split $obxseg |] 4]

      set obx_flds “${obx_fld2}|${obx_fld3}|${obx_fld4}”

      set obx_cnt 1

      set obx_out “”

      foreach obxsg  {

       if [cequal $obxseg “OBX”] && [cequal $obx_fld31 “BUN”] || [cequal $obxseg “OBX”] && [cequal $obx_fld31 “CREATININE”] {continue}

       append obx_out “OBX|${obx_cnt}|${obx_flds}|${obxsg}r”

       incr obx_cnt

      return “{CONTINUE $mh

      }

      set new_msg [lreplace $segs $obxloc $obxloc $obx_out]

      msgset $mh [join $new_msg r]

      else return “{KILL $mh}”

         }

         default {

         }

       }

      }

    Viewing 1 reply thread
    • Author
      Replies
      • #58355
        Rentian Huang
        Participant

          Jill,

          Do you mean that you want to remove all OBX segments with OBX.3.1 NOT equal to “BUN” or “CREATININE”, and re-number OBX.1?

          Sam

        • #58356
          Jill Marcotte
          Participant

            Correct.  Any help is appreciated.

        Viewing 1 reply thread
        • The forum ‘Cloverleaf’ is closed to new topics and replies.