Can an Xlate Dest. Variable be a list?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Can an Xlate Dest. Variable be a list?

  • Creator
    Topic
  • #52712
    Daniel Lee
    Participant

      CL 5.8

      AIX 6.1

      I’m using inline code in my xlate to set xlateOutVals to a list:

      Code:

      set xlateOutVals [list $val1 $val2]

      I’m then using a variable @outList in my Destination to retrieve the values that I will later put into two different outbound fields in my xlate.  However, it looks like @outList is only retaining the first element of the list.  Can an xlate variable be a list?  If not, what are my other options?  How can I have inline code populate two different outbound HL7 fields?

    Viewing 9 reply threads
    • Author
      Replies
      • #75250
        David Barr
        Participant

          I think you need to store the data in two variables. You could use a single copy action, and have the destination be @outValue1 and @outValue2.

          Another option is to copy directly to the output fields from the results of the xltp proc. You just have to list them one after the other on the right hand side of the copy action.

        • #75251
          Daniel Lee
          Participant

            If I use two destination variables or fields how do I refer to them in my in-line code?  I normally just put my output from my inline code to $xlateOutVals.  What can should I do for two destination variables?

          • #75252
            Jim Kosloskey
            Participant

              Daniel,

              You should be able to take in a temp variable that is a list (I think I have done this) – you need to be sure to use list functions with the xlateInVals just like you did with the xlateOutVals.

              When I get back to my office on Monday I will check that out – if I have not posted back by EOB Monday – email me to trigger my faulty memory.

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

            • #75253
              Robert Kersemakers
              Participant

                Yes, as Jim said you should be able to have a list of values transferred into an xlate variable.

                Have you tried

                Code:

                set xlateOutVals [list $val1 $val2]
                echo “Out: “


                to see what’s really coming out of your tcl-code? This should tell you what’s inside your @outList.

                Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

              • #75254
                Daniel Lee
                Participant

                  Code:

                  set xlateOutVals [list $val1 $val2]
                  echo “Out: “


                  This works in my in-line code.  However, it doesn’t seem to go to my Destination variable.  Lets say I use the above code and in my destination I put @listIn.  Then in a copy statement after the above I put @listIn in my source window and have the following in-line code:

                  Code:

                  echo [lindex $xlateInVals 0]
                  echo [lindex $xlateInVals 1]


                  When I do this, @listIn did contain $val1 but $val2 no longer seems to exist.

                • #75255
                  Daniel Lee
                  Participant

                    Attached are the screenshots from my setup in the xlate.  From that I get the following in the XLT testing tool:

                    Code:

                    Command output:

                    Out: 12345 C
                    12345
                    C
                    inVals: 12345
                    12345

                    From the above you can see when I’m copying it into the variable my list looks good.  When I’m reading it from the variable it doesn’t appear to be a list anymore.  It’s just a one element variable.

                  • #75256
                    Daniel Lee
                    Participant

                      Here’s how I solved this.  Evidently the xlate variables can only be one variable and can not be a list.  What I did is left my first copy statment the same:

                      Code:

                      set xlateOutVals [list $val1 $val2]
                      echo “Out: “

                      But instead of just copying it to one variable I copied it to two so my destination looked like this:

                      Code:

                      @outVal1
                      @outVal2


                      Then instead of using them as a list I used them as seperate variables.  Thanks for looking at this and spuring my troubleshooting in the right direction.  As always, I appreciate this forum.

                    • #75257
                      Jim Kosloskey
                      Participant

                        Danieal,

                        I think what you want is a listn inside a list.

                        So in the proc where you create the list try this:

                        set xlateOutVals

                          Say val1 = a and val2 = b.

                          I suspect you only have one element in the Destination panel of your Xlate Action. So with your current code, the Xlate is only really populating the single Destination (your temp variable) with the first element of the list you are providing (a).

                          If you do what I propose the temp variable itself will now contain the whole list (look something like this {a b}) and you should see that list as the inbound for the next action.

                          However, change your retrieval to this:

                          echo [lindex [lindex $xlateInVals 0] 0]

                          echo [lindex [lindex $xlateInVals 0] 1]

                          Let us know if that works

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

                        1. #75258
                          Robert Kersemakers
                          Participant

                            Jim, I was just posting the exact same thing. Funny how a few pictures/screenshots make you realise what is going on.

                            Code:

                            set xlateOutVals [list [list $val1 $val2]]


                            is the way to go. This way the first element of xlateOutVals, which is copied towards @CRDinfo is a list itself and not just one value.

                            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                          • #75259
                            Daniel Lee
                            Participant

                              Thanks guys.  This give me a whole new insite on how the xlate deals with the destination values.

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