Flitering PV1.2 when message does not contain a PV1

Homepage Clovertech Forums Read Only Archives Cloverleaf Tcl Library Flitering PV1.2 when message does not contain a PV1

  • Creator
    Topic
  • #51281
    Paul Johnston
    Participant

    Hello ,

    I have a tcl which filters the Patient Class – field PV1.2 using arguments passed.

    So far it works great to filter those messages which contain a PV1 .

    I want to use it for all my ADT messages but A60 and A34s do not contain a PV1

    Using this tcl for the messages without a PV1 does not produce any message.

    I hoped to CONTINUE with the message if it did not contain a PV1.

    Any thoughts ?

    Code:

    proc tps_class_Filter { 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
     keylget args ARGS.PTCLASS ptclass ;# Fetch Patient class from arguments
             
     set msg [msgget $mh]
               set segmentList [split $msg r]
               set fieldSeparator [crange $msg 3 3 ]

    # Split Args passed into list.            
               set classLst [split $ptclass |]

               foreach segment $segmentList {
                   if {[crange $segment 0 2] == “PV1″} {
                       set fieldList [split $segment $fieldSeparator]
                       set PV1f2  [lindex $fieldList 2]
    # echo $classLst
    foreach class $classLst {
      if [cequal $PV1f2 $class] {
    lappend dispList “KILL $mh”
    return $dispList
      }
    }
    lappend dispList “CONTINUE $mh”                        ;# CONTINUE the Message
    return $dispList
                            }
                  }
           }

           time {
               # Timer-based processing
               # N.B.: there may or may not be a MSGID key in args
           }

           shutdown {
               # Doing some clean-up work
           }

           default {
               error “Unknown mode ‘$mode’ in tps_class_Filter”
           }
       }

       return $dispList
    }

Viewing 3 reply threads
  • Author
    Replies
    • #69510
      James Cobane
      Participant

      Paul,

      I would set the default value of disp to CONTINUE at the beginning of the proc, and only change it to KILL when the message meets the specific criteria.

    • #69511
      Paul Johnston
      Participant

      Hi Jim ,

      Makes sense but do I need another CONTINUE or is my CONTINUE in the wrong section

      of the code. ?

    • #69512

      Try this (just changed the way you’re handling dispList):

      Code:

      proc tps_class_Filter { args } {
         keylget args MODE mode                      ;# Fetch mode

         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
                 keylget args ARGS.PTCLASS ptclass      ;# Fetch Patient class from arguments
               
                 set msg [msgget $mh]
                 lappend dispList “CONTINUE $mh”                             ;# Nothing to return
                 set segmentList [split $msg r]
                 set fieldSeparator [crange $msg 3 3 ]

                 # Split Args passed into list.            
                 set classLst [split $ptclass |]

                 foreach segment $segmentList {
                     if {[crange $segment 0 2] == “PV1″} {
                         set fieldList [split $segment $fieldSeparator]
                         set PV1f2  [lindex $fieldList 2]

                         foreach class $classLst {
                            if [cequal $PV1f2 $class] {      
                            lappend dispList “KILL $mh”
                            }
                         }
                     }
                 }
                 return $dispList
             }

             time {
                 # Timer-based processing
                 # N.B.: there may or may not be a MSGID key in args
             }

             shutdown {
                 # Doing some clean-up work
             }

             default {
                 error “Unknown mode ‘$mode’ in tps_class_Filter”
             }
         }

         return $dispList
      }

      -- Max Drown (Infor)

    • #69513
      Paul Johnston
      Participant

      That did it Max. Works well now.

      I think what you did was similar to what Jim was describing , setting the default at the beginning of the proc.

      Thanks very much to both.

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

Forum Statistics

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