TCL Proc to Clear or Modify FT1 Data

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL Proc to Clear or Modify FT1 Data

  • Creator
    Topic
  • #51369
    Keith Oulson
    Participant

      Greetings!

      Please forgive the length and detail of this post.  I have been working to modify an existing – working script as a result of a new surgery practice being established at the hospital and have lost my way.

      The previous script acted upon msgs as part of an xLate, a configuration which I hope to retain.

      The previous script, which has been working for years, acted on an incoming charge message FT1 segment (FT1.10) and if a certain CDM was included in the message the script would modify the quantity of the items being charged from what was received in the message to a quantity of one {1}.

      OR

      If the incoming message did not contain one of the targeted CDM’s, the script would modify the Amount and Total bits (FT1.11-12) to null { }

      Here is that proc; I don’t know who wrote it – perhaps my predecessor or his…:

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

      # clear_QTY_OR_CHG – clearing QTY or OR charges.

      #

      # Args: tps keyedlist containing:

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

      #       MSGID   message handle

      #       ARGS    keyed list of user arguments containing:

      #

      # Returns: tps keyed list containing

      # KILL explicitly kill the message

      #

      proc clear_QTY_OR_CHG { args } {

          upvar xlateInVals inVals xlateOutVals outVals

          set cdmstr {3520020 3590091 3600091 3600092 3600093 3600100 3650091 3600112 3600113 3670102 3670103 3670104 3600114 3600115 3600116 3600117 3600118 3600119 3600120}

          set cdm [lindex $inVals 0]

          echo cdm $cdm

          echo outVals $outVals

          if {[string first $cdm $cdmstr] >= 0 } {

      set outVals [lreplace $outVals 1 1 1 ]

      echo outVals $outVals                        

             } else {

         set outVals [lreplace $outVals 2 3 {} {}]

      }  

         }

      My intention was to include a second if statement to detect a second set of CDM’s.  CDM’s from this group require the message to be unchanged as it passes through, input = output or no action.

      Here is the modified script I have been testing:

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

      # Name:  clear_QTY_OR_CHG2 – clearing QTY or OR charges.

      #

      # Args: tps keyedlist containing:

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

      #       MSGID   message handle

      #       ARGS    keyed list of user arguments containing:

      #

      # Returns: tps keyed list containing

      # KILL explicitly kill the message

      #

      # Original script modified by Keith Oulson Oct 21 09

      # This script acts upon FT1 bits 7, 10, 11 and 12 to adjust quantity and amount in charges.  Added second CDM set and second if statement.

      proc clear_QTY_OR_CHG2 { ARGS } {

          upvar xlateInVals inVals xlateOutVals outVals

          set cdmstr {3520020 3590091 3600091 3600092 3600093 3600100 3650091 3600112 3600113 3670102 3670103 3670104 3600114 3600115 3600116 3600117 3600118 3600119 3600120}

          set cdmstr2 {4387371 4387372 4387373 4387374 4387375 4387376 4387377 4387378 4387379 4387380 4387381 4387382 4387383 4387384 4387385 4387386 4387387 4387388 4387389 4387390 4387391 4387392 4387393 4387394 4387395 4387396 4387397 4387398 4387399 4387400 4387401 4387402 4387403 4387404 4387405 4387406 4387407 4387408 4387409 4387410 4387411 4387412 4387413 4387414 4387415 4387416 4387417 4387418 4387419 4387420 4387421 4387422 4387423 4387424 4387425 4387426 4387427 4387428 4387429 4387430 4387431 4387432 4387433 4387434 4387435 4387436 4387437 4387438 4387439}

      #Create cdm variable using data from inVals, the first CDM

          set cdm [lindex $inVals 0]

      #Display CDM data

          echo cdm $cdm

      #Display out put data from outVals

          echo outVals $outVals

      #Test if the first CDM in the msg is a target CDM from list

          if {[string first $cdm $cdmstr] > = 0 } {

      #If it is, modify the output by changing FT1.10 to a value of 1

      set outVals [lreplace $outVals 1 1 1 ]

      #Test if the CDM matches one from the second list…

        } elseif {[string first $cdm $cdmstr2] > = 0 } {

      #Pass input to output

       set outVals [$inVals]  

      #supplemental if statement replacing with null

      #   set outVals [lreplace $outVals 1 1 {}]  }

      #Display out put

      echo outVals $outVals

             } else {

      #Otherwise modify FT1.11-12 with blank

         set outVals [lreplace $outVals 2 3 {} {}]

        }

      }

      I don’t know if I am suffering from a logic problem, a syntax problem or something else…  Just finished the Lvl 2 class and was hoping to be able to work through this but… here I am needing help.

      Other details:  Cloverleaf 5.6 / AIX 5.3.  HL7 2.3 to 2.2 (Cerner to HBOC)

      This proc is called from an xLate during the copy of FT1 bits in the xLate as a “PRE” proc.  The copy action acts on FT1 bits 361, 364, 365, 366.  AKA FT1 bits 7, 10,11, 12.

      I have tried changing the order of the statements and I continue to get the Tcl call out error.  It has been suggested I need to boot the box to correct this.  My frustration is that now one of the previously working pieces is not working in test as you can see by the output below…  The part where the amount and total amount are being replaced with null.

      Here is some of the output from the process:

      [cmd :cmd :INFO/0:   chg2_xlate:11/24/2009 15:58:30] Doing ‘xrel_post’ command with args ‘

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:58:30] Receiving a command

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:58:30] Command client went away.  Closing connection.

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:58:30] Receiving a command

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:58:30] Receiving a command

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:58:30] Received command: ”chg2_xlate’

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:58:30] Cmd null in ”chg2_xlate’

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:58:30] Receiving a command

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:58:30] Command client went away.  Closing connection.

      Engine idle — 11/24/2009 15:58:40

      Engine idle — 11/24/2009 15:58:59

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:59:17] Receiving a command

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:59:18] Receiving a command

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:59:18] Received command: ‘hnam_dft_in resend ib_pre_tps data 5120 /qvdx/qdx5.6/integrator/temp/tmpcc277b89f1f181fe__58769d8b_12523ccb0e3_1a1e_1259096357696 len10’

      [cmd :cmd :INFO/0:  hnam_dft_in:11/24/2009 15:59:18] Doing ‘resend’ command with args ‘ib_pre_tps data 5120 /qvdx/qdx5.6/integrator/temp/tmpcc277b89f1f181fe__58769d8b_12523ccb0e3_1a1e_1259096357696 len10’

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:59:18] Receiving a command

      [cmd :cmd :INFO/0:     chg2_cmd:11/24/2009 15:59:18] Command client went away.  Closing connection.

      cdm 3670102

      outVals 3670102 99 3309.00 3309.00

      outVals 3670102 1 3309.00 3309.00

      cdm 3670102

      outVals 3670102 99 3309.00 3309.00

      outVals 3670102 1 3309.00 3309.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.514972] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 4220081

      outVals 4220081 4 300.00 75.00

      cdm 4220081

      outVals 4220081 4 300.00 75.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.514978] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 4220081

      outVals 4220081 4 300.00 75.00

      cdm 4220081

      outVals 4220081 4 300.00 75.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.514984] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 4220081

      outVals 4220081 4 300.00 75.00

      cdm 4220081

      outVals 4220081 4 300.00 75.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.514990] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 4220081

      outVals 4220081 4 300.00 75.00

      cdm 4220081

      outVals 4220081 4 300.00 75.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.514996] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 3670102

      outVals 3670102 33 3309.00 3309.00

      outVals 3670102 1 3309.00 3309.00

      cdm 3670102

      outVals 3670102 33 3309.00 3309.00

      outVals 3670102 1 3309.00 3309.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.515002] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 3670102

      outVals 3670102 135 3309.00 3309.00

      outVals 3670102 1 3309.00 3309.00

      cdm 3670102

      outVals 3670102 135 3309.00 3309.00

      outVals 3670102 1 3309.00 3309.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.515008] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 4387371

      outVals 4387371 1 500.00 500.00

      outVals 4387371 1 500.00 500.00

      cdm 4387371

      outVals 4387371 1 500.00 500.00

      outVals 4387371 1 500.00 500.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.515014] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 4387371

      outVals 4387371 1 -500.00 -500.00

      outVals 4387371 1 -500.00 -500.00

      cdm 4387371

      outVals 4387371 1 -500.00 -500.00

      outVals 4387371 1 -500.00 -500.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.515020] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      cdm 3670102

      outVals 3670102 2 3309.00 3309.00

      outVals 3670102 1 3309.00 3309.00

      cdm 3670102

      outVals 3670102 2 3309.00 3309.00

      outVals 3670102 1 3309.00 3309.00

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

      [xlt :xlat:ERR /0:   chg2_xlate:11/24/2009 15:59:18] [0.0.515026] Xlate ‘HNAM_IBAX_DFT_NDC.xlt’ failed: Tcl callout error

      erroCode: NONE

      errorInfo:

      invalid command name “clear_QTY_OR_CHG2”

         while executing

      “clear_QTY_OR_CHG2”

      Engine idle — 11/24/2009 15:59:28

      🙄

    Viewing 6 reply threads
    • Author
      Replies
      • #69914
        James Cobane
        Participant

          Keith,

          Based on the error:

          sourceFilter /qvdx/qdx5.6/integrator/oen/tclprocs/clear_QTY_OR_CHG2.tcl: Failed to source filtered file: wrong # args: should be “proc name args body”

          I suspect you have a mismatched curly brace. Since Cloverleaf can’t ‘source’ the file, it doesn’t recognize the proc.

        • #69915
          Troy Morton
          Participant

            I have actually seen this before.

          • #69916

            It’s also possible that there may be a square or curly brace in your data.

            -- Max Drown (Infor)

          • #69917
            Keith Oulson
            Participant

              Jim, Troy and Max,

              Thanks for your insights.  Away from the office so I’ll have a look and let you know on Monday.

              I appreciate your insights and the time you committed to read that puppy…

              Happy holiday!

              Keith

            • #69918
              Chris Williams
              Participant

                The bottom line to why your code is throwing “failed to source” errors is this line:

                Code:

                 #   set outVals [lreplace $outVals 1 1 {}] }


                Even though this line is commented out in your code, TCL does not consider the closing brace to be commented out. It’s still “active”.

              • #69919
                Chris Williams
                Participant

                  As a side note, “args” in the context of a proc is a reserved word in TCL. “ARGS” is just a variable name. “args” represents all the remaining arguments, regardless of how many, passed to the proc that are not defined individually. Given the procedure

                  proc myProc {a b c args} {

                     body

                  }

                  Calling it as “myProc 1 2 3 4 5 6”

                  Produces

                  $a> 1

                  $b> 2

                  $c> 3

                  $args> 4 5 6

                  If you had used “ARGS” in the proc instead of “args”, you would get a “wrong # args” error.

                • #69920
                  Keith Oulson
                  Participant

                    Each of you touched on items that were a part of the problem.

                    Looking at the script with the perspective you provided, I was able to work through this.  The behavior I see now is much more in line with what was intended.  Thanks very much.

                    Learning that commenting a line of Tcl code does not necessarily inhibit the interpreter from seeing reserved characters or expressions was very helpful.

                    Also, as always in my work, I end up finding an additional paren or bracket.

                    Thanks again,

                    Keith

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