xlate string range help

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf xlate string range help

  • Creator
    Topic
  • #48621
    Nora Katz
    Participant

      I wanted to limit a OBR field to 29 characters, so I have the following xlate pre-proc

      lassign $xlateInVals input

      echo $input

      set xlateOutVals [string range $input 0 28]

      echo $xlateOutVals

      But, if the input is Urine Macroscopic I get back Urine and if the input is C-Reactive Protein I get back C-Reactive in the Testing Tool.  The echo lines look like the output I want.

      The space in the name appear to be the problem.  Is this just a problem with the testing tool or is my tcl incorrect?

    Viewing 4 reply threads
    • Author
      Replies
      • #59186
        Jim Kosloskey
        Participant

          Nora,

          The arguments you receive when invoked by Xlate are lists (with the exception of xlateId).

          You need to treat them as such Including the argument(s) you return.

          Jim Kosloskey

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #59187

          When you echo a list, tcl will print out the whole list giving the impression that the WHOLE list is a single element of the list.

          Code:

          tcl>set tmp [list blah blah blah]
          tcl>echo $tmp
          blah blah blah
          tcl>echo [lindex $tmp 1]
          blah
          tcl>

          When you return values, you have to make sure that you return a string as a single element.

          Try something like this:

          Code:

          set newString [string range $input 0 28]
          set xlateOutVals [list “$newString”]

          -- Max Drown (Infor)

        • #59188
          Michael Lacriola
          Participant

            Why use a xlate? Modify the variant for the OBR field to be 29 in length. Simple.

          • #59189
            Jim Kosloskey
            Participant

              The variant might be a shared use variant and/or the field could be one of the fields used in multiple segments.

              Not all uses may want the length changed.

              Jim Kosloskey

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #59190
              Nora Katz
              Participant

                Thank you all for the responses.  Yes, we did consider changing the length of the field, but we have many interfaces, and as we build interfaces in the future, we did not want to limit all interfaces to this length limitation that only one receiving system needed at this time.

                Jim provided me with a reusable tcl proc that worked great!

                Thanks again.

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