Reply To: HL7 message received on port into a file for receiving sys

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf HL7 message received on port into a file for receiving sys Reply To: HL7 message received on port into a file for receiving sys

#59568
Anonymous
Participant

    Here is a code skeleton I would provide. Modify as you as necessary. This proc was wriiten as to filter out A08 messages. In your case look in the MSH segment 8th field. see if it is P03, if so replace in this script A08 with P03.

    save the file. That means your proc should be same name as the file name. Compile it in tclprocs directory.

    Test it.

    Deploy it.

    -Reggie-

    proc Kill_A08_from_hmm { args } {

       keylget args MODE mode                      ;# Fetch mode

       keylget args ARGS.CODE code

       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^M

           }

           run {

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

             keylget args MSGID mh

               # Here we retrieve the data from our original message

               set msg [msgget $mh]

               # Now we need to determine our field and subcomponent seperators

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

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

               # Here we spilt the original message into a list of the segments contained wit

    hin

               set segmentList [split $msg r]

               set msh_8 “”

               set msh_8_1 “”

               # Now we iterate over each segment in our list.

               foreach segment $segmentList {

                   if [cequal [crange $segment 0 2] MSH] {

                           set fieldList [split $segment $field_sep]

                           set msh_8 [lindex $fieldList 8]

                           set subfldList [ split $msh_8 $sub_sep]

                           set msh_8_1 [lindex $subfldList 1]

                   } else {

                   }

               }

    # The following command is used to select specific patient types.

                   if {[regexp {A08} $msh_8_1]} {

                   lappend dispList “KILL $mh”

                   return $dispList

               } else {

                   lappend dispList “CONTINUE $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 Kill_A08_from_hmm.tcl”

              }

           }

           return $dispList

    }