Trying to TCL process ADT^A04 records only

Homepage Clovertech Forums Read Only Archives Cloverleaf Tcl Library Trying to TCL process ADT^A04 records only

  • Creator
    Topic
  • #51691
    Mark Boerger
    Participant

    I put the following script in my TPS Inbound data, but all records seem to

    process.

    What process removes/skips the transaction or does just returning

    lappend displist “KILL $MSGID” in Cloverleaf tell it to remove the transaction?

    or Is my script incorrect?

    Any help is appreciated

    Mark

    proc tps_filter_RODS { args } {

       global HciConnName

       

       # Get mode start or run

       set mode [keylget args MODE]

       # Get the name of the procedure to be used for error messages, debug, etc.

       set myname “$HciConnName/[lindex [info level 1] 0]”

       

       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 msgId

               set msg [msgget $msgId]

               set field_sep [string index $msg 3]   ;# HL7 field separator

               set sub_sep [string index $msg 4]   ;# HL7 subfield separator

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

         

          set PID [lindex [lregexp $segList {^PID}] 0]   ;# Get 1st PID

          set PID5 [lindex [split [lindex [split $PID $field_sep] 4] $sub_sep] 0]   ;# Get PID-5_0 Patient Last Name

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

          set MSH8 [lindex [split $MSH $field_sep] 8]   ;# Get MSH-8 Message Type and Event Type

          set MSH82 [lindex [split $MSH8 $sub_sep] 1]   ;# Get MSH-8 Component 2

         if {[regexp — {A04} $MSH82] ==1  } {

            lappend dispList “CONTINUE $msgId”

            } else {

            lappend dispList “KILL $msgId”

         }

               }

      shutdown {

          # Doing some clean-up work

      }

           default {

               error “Unknown mode ‘$mode’ in $myname”

           }

       }

       return $dispList

    }

Viewing 1 reply thread
  • Author
    Replies
    • #71307
      Nick Stainback
      Participant

      There is something with the regexp that is not parsing correctly and it is allowing all message but A04’s to pass which seems to be the oppasite of what you want to do.

      unless there is a reason you have to use the regexp you can try

      if {$MSH82 == “A04”}  {

          lappend dispList “CONTINUE $msgId”

             } else {

         lappend dispList “KILL $msgId”

          }

    • #71308
      Charlie Bursell
      Participant

      set MSH8 [lindex [split $MSH $field_sep] 8]   ;# Get MSH-8 Message Type and Event Type

      set msgType [string map “$sub_sep _” $MSH8]

      if {$msgType eq “ADT_A04”} {return “{KILL $mh}”

      Don’t make a simple problem hard  ðŸ˜€

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

Forum Statistics

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