Please can someone explain the code below?

Clovertech Forums Read Only Archives Cloverleaf Tcl Library Please can someone explain the code below?

  • Creator
    Topic
  • #52383
    Bashirat Hahn
    Participant

      Hi,

      I am still a cloverleaf newbie…I was told today about an A08 message that did not make it to our EMR. After researching I found the tcl below that is killing some of the A08 messages. The only problem is I cannot really tell why some of the messages are getting killed.

      Pleaseeeeee can someone interpret? Thanks in advance

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

      # Name: tpsA08Filter_Ibex

      # Purpose:

      # UPoC type: tps

      # Args: tps keyedlist containing the following keys:

      #       MODE    run mode (“start”, “run” or “time”)

      #       MSGID   message handle

      #       ARGS    user-supplied arguments:

      #              

      #

      # Returns: tps disposition list:

      #          

      #

      proc tpsA08Filter_Ibex { 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

         set PV1_2 “”

         set PV1_3 “”

         set msg [msgget $mh]

         set fieldSeparator [crange $msg 3 3]

         set subFieldSeparator [crange $msg 4 4]

         set sep [crange $msg 4 4]

         set repChar [crange $msg 5 5]

         set escChar [crange $msg 6 6]

         set subCompSeparator [crange $msg 7 7]

         set pttype “E”

         set null ”

         set empty {}

         set ind “Y”

         set segmentList [split $msg r]

         set dispList {}  

                 foreach segment $segmentList {

                     if {[crange $segment 0 2] == “PV1”} {

                         set PV1_2 [getHL7Fld $segment 2]

                         set PV1_3 [getHL7Fld $segment 3]

                       

                                       }  

      }  

        if { $PV1_2 != $pttype && $PV1_3 == $null } {

          set ind “N”

      }

        if { $PV1_2 != $pttype && $PV1_3 == $empty } {

          set ind “N”

      }

       

      if {$ind == “Y”} {

                lappend dispList “CONTINUE $mh”

      } else {

            lappend dispList “KILL $mh”

             }

      }

         return $dispList

      }

      }

    Viewing 3 reply threads
    • Author
      Replies
      • #73993
        Jim Kosloskey
        Participant

          Bashirat,

          It looks to me like the intent is:

          If PV1-2 is not equal to E and PV1-3 is an HL/7 null

             or

          If PV1 is not equal to E and PV1-3 is null (contains nothing or empty)

          The message is KILLed.

          However, I am not sure the HL/7 null piece is really going to work because it appears the value for null is set to apostrophe apostrophe (”) rather than double quote – double quote (“”).

          So check to see the values of PV1-2 and PV1-3 in the inbound messages in question are E and ” or E and null repsectively. If so the filter did that, otherwise there is something else going on.

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

        • #73994
          Jim Levy
          Participant

            If PV1.2 doesn’t equal variable pttype (E)  AND PV1.3 isn’t valued the message won’t be passed.

          • #73995
            Keith McLeod
            Participant

              It would appear as though you are using logic as follows:

              If PV2 is NOT equal to ‘E’ and PV3 is empty or blank, then

              Kill the message

              else

              Continue the message

              I took some liberties in shortening what I beleive is happening.  Hope it helps.

            • #73996
              Bashirat Hahn
              Participant

                Thank you very much for all the replies. In my own little way I was able to determine that it will kill messages that did not have ‘E’ in PV2 and PV3 is empty, but I wanted to make sure that the code was not doing anything else.

                Thanks again for the replies

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