TCL Proc?

  • Creator
    Topic
  • #49408
    Rick Pritchett
    Participant

      ia m trying to use the following proc in my xlate

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

      # Name: OBX_Parser

      # Purpose:

      # UPoC type: xltp

      # Args: none

      # Notes: All data is presented through special variables.  The initial

      # upvar in this proc provides access to the required variables.

      #

      # This proc style only works when called from a code fragment

      # within an XLT.

      #

      proc OBX_Parser {} {

         upvar xlateId       xlateId

       xlateInList   xlateInList

       xlateInTypes  xlateInTypes

       xlateInVals   xlateInVals

       xlateOutList  xlateOutList

       xlateOutTypes xlateOutTypes

       xlateOutVals  xlateOutVals

      }

      set newOBX5 “”

      set newOBX5_2 “”

      set newOBX5_3 “”

      lassign $xlateInVals OBX5

      set Pos2 [string last ” ” $OBX5 79]

      set count1 [expr {$Pos2 + 79}]

      set Pos3 [string last ” ” $OBX5 $count1]

      set count2 [expr {$Pos3 + 79}]

      set Pos4 [string last ” ” $OBX5 $count2]

      if { [string length $OBX5] > 80 && [string length $OBX5] < 160 } {   #set Pos2 [string last ” ” $OBX5 79]   set newOBX5 [string replace $OBX5 $Pos2 $Pos2 ~]   set xlateOutVals

        } elseif {[string length $OBX5] > 160 && [string length $OBX5] < 240} {   set newOBX5 [string replace $OBX5 $Pos2 $Pos2 ~]   set newOBX5_2 [string replace $newOBX5 $Pos3 $Pos3 ~]   set xlateOutVals

        } elseif {[string length $OBX5] > 240 } {

          set newOBX5 [string replace $OBX5 $Pos2 $Pos2 ~]

          set newOBX5_2 [string replace $newOBX5 $Pos3 $Pos3 ~]

          set newOBX5_3 [string replace $newOBX5_2 $Pos4 $Pos4 ~]

          set xlateOutVals

        }  else {

             set xlateOutVals

         }

        #set xlateOutVals

        i call it with the following code in my xlate

        lassign $xlateInVals OBX5

        if { [string length $OBX5] > 79} {

        OBX_Parser

        } else {

           

         }

        for some reason it is not executed correctly.  i have it in an iteration and it appears that it is not called each iteration.  

        any ideas?

    Viewing 3 reply threads
    • Author
      Replies
      • #61840
        Tom Rioux
        Participant

          I tested your issue out with a message and xlate here on my system.  Initially, when I tested it, the result came out to be the same as yours.  Only the first iterate populated.   I soon found out that my message and the variant I was using in the xlate didn’t want to play well together. So, I made an adjustment to the variant and it started to work.

          The issue was that the variant  had the OBX and its NTE set up together as:

          …{

              [OBX]

              [NTE]

             }

          This was causing issues with the inbound message.  So I changed it to:

          …{

             [{OBX}]

             {{NTE}]

          }

          Once I did this, it started populating every OBX correctly.

          Hope this helps…

          Tom Rioux

        • #61841
          Rick Pritchett
          Participant

            The problem with that in my variant is set up as

            HL7 2.1 on both sides.

            MSH

            PID

            PV1

            OBR

            {OBX}

          • #61842
            Tom Rioux
            Participant

              Did you get it to work?    If not, how did you set up your iterate?

            • #61843
              Rick Pritchett
              Participant

                lassign $xlateInVals OBX5

                if { [string length $OBX5] > 80} {

                echo “hello”

                OBX_Parser

                } else {

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