Using TCL to filter on 2 conditions (SYNTAX ERRORS?)

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Using TCL to filter on 2 conditions (SYNTAX ERRORS?)

  • Creator
    Topic
  • #50088
    Duy Nguyen
    Participant

    I am writing a proc to filter messages for a physician mnemonic (ROUST) where they only want messages to cross from one Location of Care (L.ADMED).

Viewing 6 reply threads
  • Author
    Replies
    • #64858
      Kevin Kinnell
      Participant

      The

       if {} {

       } else {

       }

      looks ok.

      Couple o’ things though…

      Since you are setting condition1 and condition2 it doesn’t seem reasonable

      to do a case insensitive comparison.

      The comment says it’s a post-xlate only proc; why go through all of the

      overhead of the list-searching regexp commands?  If your lmatch -regexp

      is guaranteed to work, you only have the one OBR; your PV1 will be the

      first one in the list (are you really going to have a variable number?)  Can

      you just lindex into the segments list to grab them based on position?

      Why not just test for the least-likely-to-be-true condition, and if it is true

      test for the other, instead of doing three logical operations and then comparing?

    • #64859
      Tom Rioux
      Participant

      Well, first of all tell us exactly what you are looking for.  You seem to contradict yourself with these two statements in your post and in your proc comments:

      First you say:

      I am writing a proc to filter messages for a physician mnemonic (ROUST) where they only want messages to cross from one Location of Care (L.ADMED).

      Then you say:

      # Purpose: Kills all messages where OBR.16=”ROUST” AND PV1.3 IS NOT “L.ADMED” LOC ***(only use POST-XLATE)***

      If the first statement is correct, and you only want message to cross from L.ADMED, then take out the “!” from the first IF statement where you are setting the variable “condition2”.  

      Hope this helps…

      Tom Rioux

    • #64860

      I believe the problem is the negation (!)  in this if statement:

      Code:

      if {![string equal -nocase $subField L.ADMED]} {set condition2 true}

      Here’s an easy way to test your logic. My apologies if you already know this.

      Pull out some of the code to test it out on the command line like this:

      Code:

      # Kills all messages where OBR.16=”ROUST” AND PV1.3 IS NOT “L.ADMED”

      set obr16 “ROUST”
      set subField “L.ADMED”
      set condition1 “false”
      set condition2 “false”

      if {[string equal -nocase $obr16 “roust”]} {set condition1 true}
      if {[string equal -nocase $subField “L.ADMED”]} {set condition2 true}

      puts “condition1: $condition1”
      puts “condition2: $condition2”

      if {[string equal -nocase $condition1 true] && [string equal -nocase $condition2 false]}    {
         puts “kill the message”
      } else {
         puts “keep the message”
      }

      Put that code into tmp.tcl, and then from the command line type “tcl tmp.tcl”. Then make adjustments to the script until you get the logic working the way you want it to.

      -- Max Drown (Infor)

    • #64861
      Duy Nguyen
      Participant

      Thanks for all the prompt replies everyone.  I will have a go at it again today using everyone’s input and testing tips.  =)

    • #64862
      Duy Nguyen
      Participant

      I’ve tried testing this in the TCL mode at the command line and of course it works.  But when I go back to the testing tool, I’m getting this whenever I execute the TCL proc against my LENGTH ENCODED FILE (created from SMAT):

      Please Wait ……

      Command Issued: hcitpstest -r run -f len10 -c sms_ib_data -e “hcitpstestshowbydisp ” e:/quovadx/qdx5.4.1/integrator/okprod2/roust-rad-no.len “only_roust_admed”

      Command output:

      [0:TEST] Tcl error:

      msgId = message0

      proc = ‘only_roust_admed’

      args = ”

      result = ‘wrong # args: no script following “{[string equal $condition1 true] && [string equal ” argument’

      errorInfo: ‘

      wrong # args: no script following “{[string equal $condition1 true] && [string equal ” argument

         while compiling

      “if {[string equal $condition1 true] && [string equal $condition2 true]}”

         (“run” arm line 49)

         invoked from within

      “switch -exact — $mode {

             start {

                 # Perform special init functions

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

            …”

         (procedure “only_roust_admed” line 6)

         invoked from within

      “only_roust_admed {MSGID message0} {CONTEXT sms_ib_data} {ARGS {}} {MODE run} {VERSION 3.0}”‘

      I’m really frustrated because I believe it’s syntatically correct and I think everyone said the logic looks correct as well.  Anything I might have overlooked?  TIA.

    • #64863
      Duy Nguyen
      Participant

      Well the source of the problem was at the end of my IF statement. (pointed out by a fellow Cloverleafer  🙂 )

      I had moved my begin bracket ” { ” to the next line and TCL complained.

    • #64864
      Alice Kazin
      Participant

      You can continue on the next line if you put “” at end of previous line

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

Forum Statistics

Registered Users
4,966
Forums
28
Topics
9,105
Replies
33,625
Topic Tags
248