Killing all messages

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Killing all messages

  • Creator
    Topic
  • #50755
    Wesley Petrie
    Participant

    I wrote the following code and it tested fine in the testing tool. When applied to the route, it kills all messages. I only want vitals with nursing station {CI} to pass.

    Is my return wrong?

    ********* CODE BELOW ***********************

    set filter_name “MedStation_filter”

               set fld_sep [csubstr $msg 3 1]  ;# hl7 Field Separator

    #echo $fld_sep

               set cmp_sep [csubstr $msg 4 1]  ;# hl7 Component Separator

    #echo $cmp_sep

               set rep_sep [csubstr $msg 5 1]  ;# hl7 Repetition Separator

    #echo $rep_sep

               set slist [split $msg n]       ;# Get segments

    echo [csubstr $slist 1 3]

               set seg “”                      ;# Just in case

    #

               foreach seg $slist {

    echo “SEGNAME: [csubstr $seg 0 3]”

                   if [cequal [csubstr $seg 0 3] PV1] {

                       set fields [split $seg $fld_sep]

                       set room_bed [lindex [split [lindex $fields 3] $cmp_sep] 2]

             set station [string range $room_bed 0 1]

    echo “Room and Bed: $room_bed”

    echo “Station: [string range $room_bed 0 1]”

                       if [lcontain {CI} $station] {

                         echo “$filter_name – passed – station in {CI}”

                         return “{CONTINUE $mh}”

                       }

                       break

                   }

               }

    #

               echo “$filter_name – failed all test.”

               return “{KILL $mh}”

           }

       }

    }

Viewing 3 reply threads
  • Author
    Replies
    • #67401
      Tom Rioux
      Participant

      I’m assuming this isn’t all of the code.

    • #67402

      Ok … I know this isn’t really what you want to know, but you don’t need a loop to accomplish this. Instead, you can extract the field and then kill or not kill based on the contents of the field.

      Here is an example of a simple msg filter the demonstrates one way to kill messages w/o using any loops (foreach).

      proc tps_filter_PASS { args } {
      [code]proc tps_filter_PASS { args } {

      -- Max Drown (Infor)

    • #67403
      Wesley Petrie
      Participant

      Thomas and Max, thanks for your input.

      Thomas –  the code you presented worked… I’m still uncertain why my return failed but at least I have a solution.

      Max –  thanks for the code you provided. There is always room to explore different ways to “skin the cat”

    • #67404
      Tom Rioux
      Participant

      As Max pointed out (and I agree), you don’t need a loop to do this.  Looping through the segments is not as efficient as other methods. Here is one method that could be used to replace the looping.  Once you have your segments in your variable “slist”, instead of looping through them, use the lsearch command:

      set pv1_idx [lsearch -regexp $msg ^PV1]

      This will return you the index of your PV1 segment.  Then simply use that index to extract the segment:

      set pv1seg [lindex $slist $pv1_idx]

      Then extract your other fields as you have it listed.  As you said…just another way to skin a cat.

      Later…Tom

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

Forum Statistics

Registered Users
5,125
Forums
28
Topics
9,294
Replies
34,439
Topic Tags
287
Empty Topic Tags
10