Tcl -exact mode not working as expected

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Tcl -exact mode not working as expected

  • Creator
    Topic
  • #50070
    Shaun Beckman
    Participant

      I recently started using the code below, which was not

      written by me, and the exact mode is not working as expected.

      The filter is designed to pass results containing specific

      physician codes, but it is also passing results containg codes

      that are similar to those suppplied.

      The args supplied are:  {DRCODES {123|6682|4664|5681}}

      The filter is also passing results with codes like 10123,  

      and 105681.

      Any help will be greatly appreciated.

      We are runing v5.5 rev 1 in a Redhat es4 environment.

      proc filter_nonphysician {args} {

         keylget args MODE mode

         keylget args ARGS uargs

         switch -exact — $mode {

            start {

                return “”

            }

            run {

                set drcodes UNKNOWN  ;# default value

                keylget args MSGID mh

        keylget uargs DRCODES drcodes

        # init – variables

        set pv1_7_1 “”;set pv1_8_1 “”;set pv1_9_1 “”;set pv1_17_1 “”

        set obr_16_1 “”

                # get message

        set msg [split [msgget $mh] r]

        # PV1 Seg – extract Dr codes from pv1 – 7.1,8.1,9.1 & 17.1

        set pv1_loc [lsearch -regexp $msg {^PV1}]

        set pv1_seg [lindex $msg $pv1_loc]

        echo $pv1_seg

        set pv1_7_1 [lindex [split [lindex [split $pv1_seg |] 7] ^] 0]

        set pv1_8_1 [lindex [split [lindex [split $pv1_seg |] 8] ^] 0]

        set pv1_9_1 [lindex [split [lindex [split $pv1_seg |] 9] ^] 0]

        set pv1_17_1 [lindex [split [lindex [split $pv1_seg |] 17] ^] 0]

        set dr_cd_in_msg “${pv1_7_1} ${pv1_8_1} ${pv1_9_1} ${pv1_17_1} “

                # OBR seg – extract Dr codes from obr – 16.1

        set obr_loc [lsearch -regexp $msg {^OBR}]

        set obr_seg [lindex $msg $obr_loc]

        set obr_16_1 [lindex [split [lindex [split $obr_seg |] 16] ^] 0]

        append dr_cd_in_msg $obr_16_1

                # Check if the physician codes are in pv1 7.1,8.1,9.1,17.1 or obr16.1

        # If found continue message else kill message

                if {[regexp $drcodes $dr_cd_in_msg]} {

           echo “Found a Match … continue message”

           echo DR_CD_IN_MSG: $dr_cd_in_msg

           return “{CONTINUE $mh}”

        } else {

           echo “Dr code not in message .. message killed”

           echo “Dr codes in Message: $dr_cd_in_msg”

           echo “Wanted Dr codes : $drcodes”

           return “{KILL $mh}”

        }

            }

         }

      }

    Viewing 5 reply threads
    • Author
      Replies
      • #64767
        Charlie Bursell
        Participant

          Right after ” keylget uargs DRCODES drcodes” add this

          set drcodes “^($drcodes)$”.  Or you could change your arguments.

          You could also do it like:

          set drcodes “\m($drcodes)\M”

          This should delimit what you want.

        • #64768
          Shaun Beckman
          Participant

            I went with your second recommendation,

            (set drcodes “\m($drcodes)\M”, and it is

            now working as expected.

            Thanks, Charlie!!!

          • #64769
            Kevin Kinnell
            Participant

              Shaun,

              What was the ‘-exact’ switch that wasn’t working?

              –kevin (curious) kinnell

            • #64770
              Shaun Beckman
              Participant

                Kevin,

                This shows my inexperience with Tcl. I thought the exact

                command (switch -exact — $mode) would cause the script

                to search for the args exactly as they were entered.

                Maybe someone else can elaborte on the exact command.

              • #64771
                Kevin Kinnell
                Participant

                  Oh, I get it.  I was fuzzled because there wasn’t any ‘-exact’ toggle in the

                  regexp command–I get fuzzled pretty easily.  (The regexp command doesn’t

                  have an -exact toggle. 🙄)

                  On a switch command, the -exact option just toggles ‘strict’ matching on.

                  Charlie has a post here somewhere with some recommendations for learning

                  Tcl. You might also try the Tclers Wiki for some pointers.

                • #64772
                  Shaun Beckman
                  Participant

                    Thanks for the info.

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