Filter based on ADT^A38

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Filter based on ADT^A38

  • Creator
    Topic
  • #49562
    Rick Pritchett
    Participant

    I know i can kill these by routing them then use a proc to kill then off but i would like to filter at the inbound data level does anyone see why my code will not work?  Do i need to look at the subfield level?

    run {

               set mh [keylget args MSGID]

       set dispList

         set msg [msgget $mh]

         set fldSep [string index $msg 3]

         set subSep [string index $msg 4]

         set segList [split $msg r]

         set MSH [lindex [lregexp $segList {^MSH}] 0]

         set MSHflds [split $MSH $fldSep]

         set MSH_9 [lindex $MSHflds 8]

         if {[string equal $MSH_9 ADT^A38] } {

         set dispList

      return $dispList

         } else {

             

             return $dispList

         }

      }

      shutdown {

         return “”

      }

         }

      }

Viewing 2 reply threads
  • Author
    Replies
    • #62489
      Steve Robertson
      Participant

      Rickey, I think maybe you’re not setting the dispList correctly. I’m pretty sure you need to CONTINUE messages you want to keep processing. Also, I lappend the dispList rather than set it. Might or might not be necessary.

      I’m not an expert on tcl syntax nor on the engine. I know there are often many ways to accomplish the same thing. But I have a message filter that works for me. Here is how I do it:

      Edit — I left out some lines! The code below should work for you.

      set msg [msgget $mh]

      set Separator_1 [cindex $msg 3]

      set Separator_2 [cindex $msg 4]

      set splitmsg [split $msg r]

      set mshseg [lindex $splitmsg 0]

      set fields [split $mshseg $Separator_1]

      set msgtype [lindex $fields 8]

      # Substitute underscore for subfield separator in message type

      set MsgType [split $msgtype $Separator_2]

      set msg_type “”

      append msg_type [lindex $MsgType 0]_[lindex $MsgType 1]

      if {$msg_type == “ADT_A38”} {

    • #62490
      John Hamilton
      Participant

      Rickey,  your code looks right at first glance.

      What I would do is confirm that MSH_9 really has what you think it has in it.  Also I wouls use cequal as opposed to “string compare” But that is just me.

      A couple of echo’s and showing us the results would be helpful.

    • #62491
      Bryan Dort
      Participant

      This is a very typical issue.  You are dealing with a list made up of subfields on MSH-9, not a string.  A couple of ways to build filters like this.  

      1.)  break the field down further into its subfields and test for ‘ADT’ and then ‘A38’.  

      2.)  The better way is to normalize the subfield seperator like the engine does and replace the ‘^’ with a ‘_’.  This way you can do string compares easily.  (You see this in the engine as ‘ADT_A38’.)

      Use something like:

      Code:

      set MSH_9 [string map “$subSep _” [lindex $MSHflds 8]]
      if {[string equal $MSH_9 ADT_A38] } {

      You should be good to go.

Viewing 2 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