PID.3 Reformat Using XlateInList

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf PID.3 Reformat Using XlateInList

  • Creator
    Topic
  • #51921
    Johnny Anderson
    Participant

      CL v5.5, Sun, Solaris 10.

      I need to reformat the repeating PID.3 fields of an input VXU.  Details are in the attachments.

      I added a CALL action with a tcl proc, see screen 1.  I get

    Viewing 13 reply threads
    • Author
      Replies
      • #72301
        Jim Kosloskey
        Participant

          Johhny,

          I think this:

             set

        • xlateInList

          should be:

             set

        • $xlateInList

          Moreover, if it were me, I think I could do all of this inside an Xlate without Tcl at all using IF/Else logic and field riteration.

        • email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

    • #72302
      Jim Kosloskey
      Participant

        Johnny,

        Besides the chage I suggested don’t you want to use xlateInVals instead of xlateInList?

        email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

      • #72303
        Johnny Anderson
        Participant

          I tried $xlateInList and got the below attachment.

          I forgot to mention that I have done my research using the forum, user manuals, and web sites but

          I can

        • #72304
          Jim Kosloskey
          Participant

            Johnny,

            xlateInList and xlate OutList are lists of the names of the elements you placed in the Source and Destination containers of the Xlate Action repsectively.

            For example if you had a COPy with:

            Source @myvar

            Destination @yourvar

            Then xlateInList would contain “@myvar” and xlateOutList would contain “@yourvar”. Not the data values for those names just the names.

            xlateInVals and xlateOutvals contain the actual data for the Source and Destination elements respectively.

            So for example if @myvar had the value of “123” and the same COPY

            The XlateInList would have the value “@myvar” and xlateOInVals would have the value “123”

            each of those (xlateInList and xlateInVals) are lists which in this case have one lement each.

            So to find out the Type in PID-3.4 you would need to look at xlateInVals.

            Again, if you were to ITERATE over the PID-3 field and inside that ITERATE check the value of PID-3.4 for the values you are looking for using an IF with ELSE I think you could accomplish what you want without Tcl.

            email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

          • #72305
            Johnny Anderson
            Participant

              Thanks Jim.  Okay, I

            • #72306
              Johnny Anderson
              Participant

                I

              • #72307
                Jim Kosloskey
                Participant

                  Johnny,

                  Your incr should be like this:

                  incr pid3NbrLoc 2

                  instead of:

                  incr $pid3NbrLoc 2

                  Note the removal of the $.

                  email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

                • #72308
                  Johnny Anderson
                  Participant

                    Thanks Jim for the incr fix.   I thought you define a variable with no $ and then after that you use $.  Are there

                    exceptions to that?  I have a new error message: invalid command name “elseif”.  I added an IF stmt to check for

                    null fields and got the error msg.  I

                  • #72309
                    Levy Lazarre
                    Participant

                      Johnny,

                      There are two ways to access a variable in Tcl, by value and by reference. If you only need the value of the variable, you access it using the $ character (variable substitution). However, if you need to modify the variable in place, you access it by reference, using the variable’s name, without any $ character. This is the equivalent of using a pointer in the C language.

                      There are Tcl commands that need to modify the variable in place, so they call the variable’s name, not the value.

                      ‘inc’ is one of these commands that directly access the variable. So if you define a variable named myvar and you want to increment it by 2, you go like this:

                      set myvar 10

                      incr myvar 2   ;# you get a syntax error with incr $myvar

                      Other commands like this are: append, lappend, array. If you look up a command’s syntax, Tcl will let you know if the command requires a variable’s name instead of the value:

                      “incr varName ?increment?”  

                      “append varName ?value value …?”

                      “lappend varName ?value value …?”

                      As for the error with the “elseif”, it is happening because you have inserted a blank line between the end of the “if” statement and the beginning of the “elseif”. It has to do with the way Tcl parses the control structure. A newline is treated in Tcl as a command separator. So it makes it appear to Tcl that the “elseif” is a command, instead of a clause belonging to the “if” statement. You just need to move up all your “elseif” clauses like this:

                      if {$pid3Type eq “”} { ;#  null – skip it

                                 echo “### Null – skip it”

                                 incr pid3NbrLoc 2

                                 incr pid3TypeLoc 2

                                 continue

                             } elseif {$pid3Type eq “SR”} { ;#  SR – Patient Nbr

                                 set $demPat $pid3Nbr

                                 echo “### SR demPat: ” $demPat

                                 incr pid3NbrLoc 2

                                 incr pid3TypeLoc 2

                                 continue

                             }

                      Finally, a simple “return” statement should break you out of a procedure.

                      I hope this helps.

                    • #72310
                      Johnny Anderson
                      Participant

                        Thanks for the info Levy.  I’ll make those changes.

                      • #72311
                        Johnny Anderson
                        Participant

                          Thanks Levy, those changes worked except the

                        • #72312
                          Jim Kosloskey
                          Participant

                            Johnny,

                            As far as I know you only option is to use xpmerror to throw an error then select the desired error action in the COPY Action (the Error: pull down which defaults to skip).

                            The options are: skip (which skips this ACTION); pad (which pads the field with what is in Default I think; or error which immediately sends the message to the Error DB and moves to the next message.

                            I guess another option is to set a temp variable in your proc that you test after the COPY and if the temp variable indicates an error has occurred, do a SUPPRESS Action which will kill the message but you would not know it has happened unless you put something in the log and are constantly monitoring the log.

                            email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

                          • #72313
                            Levy Lazarre
                            Participant

                              Johnny,

                              The correct command to terminate the loop immediately inside the “else” clause is “break”.

                              However, I entirely agree with Jim’s comments. What you are trying to achieve is not possible within the Tcl fragment. Remember that the Tcl proc is called by the Xlate. When it ends, it has to return control to the CALLER (the Xlate). The only control you have is what the Tcl returns to its caller. This agrees with Jim’s suggestion of setting a temporary variable within the ‘else’ clause. The Xlate can then evaluate the value of this variable and issue a “SUPPRESS” when it’s necessary to abort.

                              I do not quite understand your business needs and I am wondering if you are running the translation on the batch as a whole or if you have split the batch in invididual messages before sending them to translation. If they were split. everything could be done by iterating inside the Xlate as Jim mentioned, and no Tcl would be necessary.

                            • #72314
                              Johnny Anderson
                              Participant

                                Thanks Jim and Levy.  I changed my mind about the abort idea.  Now I prefer to skip the message and continue with the next one.  

                                I

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