TCL ORM/OBX filter issue

Homepage Clovertech Forums Read Only Archives Cloverleaf Tcl Library TCL ORM/OBX filter issue

  • Creator
    Topic
  • #54216
    Kaley Grimes
    Participant

    Good Morning,

    We have ORM messages that will sometimes have multiple OBR segments in the messages. Overall, we have a single inbound thread and two outboud threads. We want certain messages going to each.

    The script I have will kill an ORC, and OBR segment if it matches up with the data we do not want to cross to one of the threads. The problem I’m having is how would I also kill the OBX segment that corresponds with the ORC/OBR that’s being killed. There really isn’t any information in the OBX segment that I can filter on. The only thing I’ve been able to do so far is either add all of the OBX’s or remove them.

    Any suggestions?

    Here’s the code I have:

    proc tps_hcentral_killorm_based_on_SIM { args } {

       

       keylget args MODE mode               ;# Fetch mode

       set dispList {} ;# Nothing to return

       switch -exact — $mode {

           start {

               # Perform special init functions

       # N.B.: there may or may not be a MSGID key in args

           }

           run {

       # ‘run’ mode always has a MSGID     ;# fetch and process it

               keylget args MSGID mh

    # Retrieve the Message Type from the message

        set msg [msgget $mh]

      set field_sep [csubstr $msg 3 1]    ;# HL7 field separator      

        set sub_sep [csubstr $msg 4 1]      ;# HL7 subfield separator

    set sssub_sep [csubstr $msg 7 1]      ;# HL7 SUB-subfield separator          

        set fieldList [split $msg $field_sep] ;# Split the message into fields

        set msg_type [lindex $fieldList 8] ;# HL7 Message Type

        set subfieldList [split $msg_type $sub_sep] ;# Split the field into subflds

        set msg_type_1 [lindex $subfieldList 0] ;# HL7 Message Type part 1

      set msg_type_2 [lindex $subfieldList 1] ;# HL7 Message Type part 2

    set outbuf “” ;# Holds outbound message

       set pass “false”

       set orc_seg “”

    set obr_seg “”

    set obr2_0 “”

    set orc2_0 “”

    set obx_seg “”

    set simdept “”

    set simcode “”

    set segments [split $msg r] ;# Get segments

    if {[cequal $msg_type_1 “ORM”]} {

    #

    foreach seg $segments {

    set segtype [csubstr $seg 0 3] ;# segment type

      #####

    if [cequal $segtype MSH] {

    append outbuf ${seg}r    

    #msgset $mh $outbuf

    }

    if [cequal $segtype PID] {

    append outbuf ${seg}r

    #msgset $mh $outbuf

    }

    if [cequal $segtype PV1] {

    append outbuf ${seg}r

    #msgset $mh $outbuf

    }

    if [cequal $segtype ORC] {

    #blank out orc_seg from last pass through.  YOu may not need this code.

    set orc_seg “”

    set fieldList [split $seg $field_sep]

    set orc2 [lindex $fieldList 2]

    set orc2_0 [split $orc2 $sub_sep]

    ##########

    # do whatevever you xlate you need here.

    ##########

    set seg [join $fieldList $field_sep]

    #create your variable orc_seg and make it the ORC segment.

    set orc_seg $seg

    }

    if [cequal $segtype OBR] {

    set obr_seg “”

    set fieldList [split $seg $field_sep]

    set obr2 [lindex $fieldList 2]

    set obr2_0 [split $obr2 $sub_sep]

    set obr4 [lindex $fieldList 4]

    set obr4_0 [split $obr4 $sub_sep]

    set obr4_0_1 [lindex $obr4_0 0]

    set obr4_0_items [split $obr4 $sssub_sep]

    set simdept [lindex $obr4_0_items 1]

    set simcode [lindex $obr4_0_items 0]

    set seg [join $fieldList $field_sep]

    set obr_seg $seg

    if {$orc2_0 == $obr2_0} {

    set dept_check [regexp {CAR} $simdept]

    set simcode_check [regexp {5306|5009|5111|5008|5304} $simcode]

    #echo “dept_check is: $dept_check”

    #echo “simcode_check is: $simcode_check”

    if {(($dept_check == 1))&&(($simcode_check == 1))} {

    #do nothing

    } else {

    # here is where you add the segments to the outbuf if they meet the criteria

    if {![cequal $orc_seg “”]} {

    #echo “ORC_SEG is: $orc_seg”

    #checking to make sure that orc_seg is not empty.

    append outbuf ${orc_seg}r

    }

    #append OBR segment to outbuf

    append outbuf ${obr_seg}r

    #set variable pass to true.

    set pass “true”

    }

    }

    }

    #THE FOLLOWING CODE KILLS THE OBX SEGMENT BECAUSE PASS THE DEPT_CHECK AND SIMCODE_CHECK ARE TRUE.

    if [cequal $segtype OBX] {

    if {(($dept_check == 1))&&(($simcode_check == 1))} {

    #do nothing

    } else {

    append outbuf ${seg}r

    }

    }

    }

    }

               set outbuf [string trimright $outbuf “r”]

               set outbuf “$outbufr”

               msgset $mh $outbuf

               #check to see if the message should pass or not.  If pass is true then send it on.

               if {[cequal $pass true]} {

                lappend dispList “CONTINUE $mh”

            } else {

            lappend dispList “KILL $mh”

            }

            return $dispList

           }

           shutdown {

                   echo “tps_hcentral_killorm_based_on_SIM is shutting down”

           }

           

           time {

               # Timer-based processing

               # N.B.: there may or may not be a MSGID key in args

           }

           default {

               error “Unknown mode ‘$mode’ in tps_hcentral_killorm_based_on_SIM”

           }

       }

    }

Viewing 0 reply threads
  • Author
    Replies
    • #80621
      Kaley Grimes
      Participant

      McKesson and I figured out the issue. It was the nut behind the keyboard.

      The OBX if worked fine. I was looking at the message wrong.

Viewing 0 reply threads
  • The forum ‘Tcl Library’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,448
Topic Tags
288
Empty Topic Tags
10