Tcl Proc to filter on multiple Insurance Company ID’s

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Tcl Proc to filter on multiple Insurance Company ID’s

  • Creator
    Topic
  • #51105
    Shaun Beckman
    Participant

      We were tasked to write a filter which kills a message based on two Insurance Company IDs. If “123” is in IN1_3.1 or if “567” is in IN2_3.1, kill the message. They have since added 50 codes that need to be added to the filter. I.E. If any of the 50 codes are in IN1_3.1 or in IN2_3.1, kill the message.

      Can someone recommend how to do this without having to write a mile long IF statement?

      Below is a portion of the filter.

        # Here we retrieve the data from our original message

       

        set msg [msgget $mh]

        # Now we need to determine our field and subcomponent seperatoprs

       

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

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

        set disposition “KILL”

           

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

       

        set segmentList [split $msg r]

        foreach segment $segmentList {

            if {[cequal [crange $segment 0 2] IN1]} {

        set fieldList [split $segment $field_sep]

        set in1_3 [lindex $fieldList 3]

        set in1_3_list [split $in1_3 $sub_sep]

        set in2_3 [lindex $fieldList 3]

        set in2_3_list [split $in2_3 $sub_sep]          

        set in1_3_1 [lindex $in1_3_list 0]

        set in2_3_1 [lindex $in2_3_list 1]

         

         puts “this is in1_3_1: $in1_3_1”

         puts “this is in2_3_1: $in2_3_1”

         

         if {[cequal $in1_3_1 “123”] || [cequal $in2_3_1 “567”]} {

         set disposition “KILL”

          } else {

         set disposition “CONTINUE”

      Thanks in advance for any suggestions.

    Viewing 6 reply threads
    • Author
      Replies
      • #68815
        Tom Rioux
        Participant

          Here is one way to do it (which I’m sure I’ll get much grief about).

        • #68816
          Shaun Beckman
          Participant

            Pardon my ignornance here, but do I need to build the table somewhere in the Tcl Proc, or as usual in the Lookup Table Configurator?

          • #68817
            Bob Richardson
            Participant

              Another approach could be to create an internal list and perform

              an “lcontain” test in your if.  Here is a snippet of what we did in a proc below; however, we have now converted this to a table lookup much like

              the previous post as we expect more of these codes to pop up like dandelions in my lawn…

              Ask yourself:  will this list grow?  what will be the maintenance load in the future?  

              Good luck.

              CODE SNIPPET:

                     set amb_list

                      if { [lcontain $amb_list $obr_20_1]} {

                               lappend dispList “KILL $mh”

                      } else {

                              lappend dispList “CONTINUE $mh”

                      }

              1. #68818
                Shaun Beckman
                Participant

                  Both great suggestions. Thanks guys. The list will continue to grow, so I’ll go with the table for now, but I already have a use for the list in a different Proc.

                  Thanks again.

                • #68819
                  Shaun Beckman
                  Participant

                    I have created the table and dropped the second arg, but the issue I am running into is if the first iteration = Y, but the 2nd, 3rd…iterations do not, the message is continued. How can I make the filter work if any of the iterations on in1_3_1 = Y, the message will be killed?

                      set segmentList [split $msg r]

                      foreach segment $segmentList {

                          if {[cequal [crange $segment 0 2] IN1]} {

                      set fieldList [split $segment $field_sep]

                      set in1_3 [lindex $fieldList 3]

                      set in1_3_list [split $in1_3 $sub_sep]

                      set in1_3_1 [tbllookup InsCodes [lindex $in1_3_list 0]]

                       

                       puts “this is in1_3_1: $in1_3_1”

                     

                       if {[string equal $in1_3_1 “Y”]} {

                         set disposition “KILL”

                       } else {

                         set disposition “CONTINUE”

                    }

                    Thanks in advance for any suggestions.

                  • #68820
                    Bob Richardson
                    Participant

                      Greetings,

                      You can add a break command once you find an instance where the condition is true to KILL the message.   This will end the foreach loop.

                      For example in your logic:

                       if {[string equal $in1_3_1 “Y”]} {

                          set disposition “KILL”

                          break  

                       } else {

                          set disposition “CONTINUE”

                      }

                      Happy hunting!

                    • #68821
                      Shaun Beckman
                      Participant

                        That worked. Thanks again Robert, I really appreciate the help.

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