saving discarded messages

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf saving discarded messages

  • Creator
    Topic
  • #48075
    Roman Partigula
    Participant

      I want to filter our messages and save all discarded ones to an error file

      Following is tps routin I want to use to do this.

      errorFile is supposed be opened only ones when this connection gets started

      and gets closed during shutdown  

      My problem is that RUN part of my routine doesn’t recognize myfileID defined in START

      Can anybody tell me please what I do wrong?

      Or may be it is another way how to do it?

      Thanks

      proc FilterParse { args } {

         package require medisyslib

         global HciSiteDir

         set errorFile $HciSiteDir/exec/processes/kicout/IBfiles/picisChgError.txt    

         keylget args MODE mode               ;# Fetch mode

         

         set dispList {} ;# Nothing to return

         switch -exact — $mode {

             start {

      set myfileID [ open $errorFile APPEND ]

             }

             run {  

                 keylget args MSGID mh

       set msg [msgget $mh]

       set fieldsep [ crange $msg 3 3 ]

       set segmlist [ split $msg r ]

       set mshSegm [ getSegment $segmlist “MSH” ]

                   set mshFieldList [ split $mshSegm $fieldsep ]

       set facility [ lindex $mshFieldList 3 ]

                 

       if { [ cequal $facility “JHMC” ] } {

                  lappend dispList “CONTINUE $mh”

      } else {

         msgwrite raw $mh $myfileID

         lappend dispList “KILL $mh”

         

      }

             }

             time {

               

         # N.B.: there may or may not be a MSGID key in args

             }

             

             shutdown {

         # Doing some clean-up work

                   close $myfileID

      }

         }

         return $dispList

    Viewing 4 reply threads
    • Author
      Replies
      • #57553
        John Perks
        Participant

          Globalize myfileID, and make sure the “Run Translation Procs in start-mode” is enabled for the process’ option.

        • #57554
          Jim Kosloskey
          Participant

            Roman,

            Here is another thought:

            Why not send the filtered message to another thread which is your error file thread (file protocol maybe)?

            You still need a filter proc (there are generic ones around) but let Cloverleaf manage the I/O, get the assured delivery, have SMAT, all that good stuff.

            Jim Kosloskey

            email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

          • #57555
            Roman Partigula
            Participant

              Jim Kosloskey wrote:

              Roman,

              Here is another thought:

              Why not send the filtered message to another thread which is your error file thread (file protocol maybe)?

              You still need a filter proc (there are generic ones around) but let Cloverleaf manage the I/O, get the assured delivery, have SMAT, all that good stuff.

              Jim Kosloskey

              If I undestand correctly I should creare two routes for one for good

              one for bad messages and two tps routines with “opposite”

              loggic?

            • #57556
              Jim Kosloskey
              Participant

                Roman,

                Yes that is one way.

                One route checks if the message were to be filtered and if so, sends the message on to the error file thread.

                The other route checks the same message and if it is to be filtered, kills the message.

                So one COPY of the message gets killed, another gets routed to the error file thread.

                Another way is to write a Tcl proc that dynalically changes the message routing – but that is not commonly done.

                Jim Kosloskey

                email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

              • #57557
                Craig Weldy
                Participant

                  I used a trxid proc to filter out charges to either pass through to the billing system or to be written out to an error thread.  I then crated the routes that look for the trxid’s defigned in the proc.  Has worked great and is easy to follow.  Below is the code.

                  ######################################################################

                  # Name: charge_route

                  # Purpose:

                  # UPoC type: trxid

                  # Args: msgId = message handle

                  # Returns: The message’s transaction ID

                  #

                  # Notes:

                  # The message is both modify- and destroy-locked — attempts to modify

                  # or destroy it will error out.

                  #

                  proc charge_route { mh } {

                     set datList [datlist]

                     set gh [grmcreate -msg $mh hl7 2.3 cerner23 dft]

                     set dh0 [grmfetch $gh {0(0).PV1(0).00133.[3]}]

                     set myent [datget $dh0 VALUE]

                     set ffour [string range $myent 0 3]

                     if { [string compare $ffour “MLMI”] == 0 } {

                        set trxId “LTHS”

                     } else {

                        set trxId “HBOC”

                     }  

                     grmdestroy $gh

                     hcidatlistreset $datList

                     return $trxId ;# return it

                  }

                  Craig Weldy
                  Senior Interface Analyst
                  Beacon Health System
                  South Bend, In, 46615

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