Modifying iteration variables in an xlate

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Modifying iteration variables in an xlate

  • Creator
    Topic
  • #49403
    Dennis Dunn
    Participant

      Hello again,

      I have HL7 ORU messages that I need to modify.  I want to insert OBX segments before the OBX segments that already exist in the message.  These new OBX segments will form a header to the order report that is getting stuffed into the billing system.

      My first stab at this copies over the MSH, PID, PV1 and OBR segments and adds some OBX segments.  I then iterate over the existing OBX groups.  I was trying to increment the value of %g1 in the pre-xlate tcl to move the OBX from group %g1 to group %g1 + 18.

      set d [xpmfetch $xlateId {$%g1}]

      set ctr [datget $d VALUE]

      set ctr [expr $ctr + 18]

      xpmstore $xlateId {$%g1} d -c $ctr

      datdestroy $d

      This does not increment the value of %g1 like I thought it would.  Do you have any suggestions on how to insert OBX groups /before/ the existing OBX groups?

      Thanks for your help.

      –dennis

    Viewing 4 reply threads
    • Author
      Replies
      • #61812
        Dennis Dunn
        Participant

          Hello,

          Here is my second stab at trying to insert segments into a message.

          set d [xpmfetch $xlateId {$%g1}]

          set i [datget $d VALUE]

          datdestroy $d

          set j [expr $i + 18]

          set k [expr $j + 1]

          xpmstore $xlateId “~1(0).1(0).3(0).0($j).OBX(0).00569(0)” d -c $k

          However, I get this error message when I test the translation

          MESSAGE 1

          [0:TEST] Mismatched IR Tags

          Tcl callout error

          erroCode: NONE

          errorInfo:

          error storing into “0(0).1(0).3(0).0(18).OBX(0).00569(0).[0].[0]”

             while executing

          “xpmstore $xlateId “~1(0).1(0).3(0).0($j).OBX(0).00569(0)” d -c $k”

          Where is the .[0].[0] coming from?  I tried specifing the complete path like this

          set d [xpmfetch $xlateId {$%g1}]

          set i [datget $d VALUE]

          datdestroy $d

          set j [expr $i + 18]

          set k [expr $j + 1]

          set path “~1(0).1(0).3(0).0($j).OBX(0).00569(0)”

          append path {.[0]}

          xpmstore $xlateId $path d -c $k

          … but I still get the same error message.

          MESSAGE 1

          [0:TEST] Mismatched IR Tags

          Tcl callout error

          erroCode: NONE

          errorInfo:

          error storing into “0(0).1(0).3(0).0(18).OBX(0).00569(0).[0].[0]”

             while executing

          “xpmstore $xlateId $path d -c $k”

          Thanks again.

          –dennis

        • #61813
          Dennis Dunn
          Participant

            Hi,

            That really irritates me when somebody posts to a forum asking for help but they haven’t done their research.   🙂

            I figured out the problem with my second attempt, I had specified the pathname incorrectly.  Even though xpmfetch needs the tilde to indicate an output field name, xpmstore doesn’t.  Presumably because there is no other place to logically store a value except in the destination.

            I’d still like to hear your comments about modifing the iteration variable.

            Thanks again.

            –dennis

          • #61814
            Ryan Spires
            Participant

              Dennis,

              without knowing the full details of what is going on…

              If what you are wanting to do is Insert “generated” OBX’s before the inbound message OBX’s… several things.

              I usually hijack a list variable say %l1

              I will use it as a counter… remember 0 is the first value of the path.

              If your path is 1(0).0(0).OBX(0).00569  —set id…

              Then create your first OBX by setting %l1 to 0

              copy

              =0    $%l1

              use the %l1 as your map to value

              math add

              $%l1

              =1        1(0).0(0).OBX(%l1).00569    (set id, 1 more than path variable)

              copy remaining fields for first obx then before moving to the next OBX you want to generate or the obx that you are mapping from the inbound…

              You want to manually increment the “counter/pathvariable”

              math add

              $%l1

              =1         $%l1

              If you need additional “generated” obx’s, repeat above

              when you are ready to jump into your obx iterate for you inbound data

              iterate the inbound as normal… but use the $%l1 as the outbound variable and continue to math add 1 to increment

              iterate 1(0).0(0).OBX    %s1

              math add

              $%l1

              =1             1(0).0(0).OBX(%l1).00569    (only increment 1 more than path to maintain OBX Set ID)

              copy rest of fields like this

              copy

              1(0).0(0).OBX(%g1).00570      1(0).0(0).OBX(%l1).00570

              when done with all field copies but still inside iterate

              manually increment path value (%l1)

              math add

              $%l1

              =1           $%l1

              Obviosly your path (1(0).0(0).OBX)  may be a bit different depending on your variant… but this should get you started.

              I suspect you don’t need the xpm logic

              Ryan

            • #61815
              Charlie Bursell
              Participant

                Ryan has a good idea but it requires too much work for me and I am lazy  ðŸ˜€

                I would really like it if we were passed the actual address inside of an iterate.  Instead we are passed something like:

                  0(0).OBX(%s1).$5

                In other words, what was entered in the config file.

                What I do is set up my counter or establish which iteration I want to output or access using whatever method is best for the situation.

                Then, since I use the address in xlateInList, simply do something like:

                set newAddr [string map “(%s1) ($cnt)” $inAddr]

                And go from there.

                Most of the time when doing stuff like this, I prefer to use a CALL statement rather than a COPY.  It gives me greater control over the output.

                It doesn’t make my way better, just different  ðŸ˜‰

              • #61816
                Dennis Dunn
                Participant

                  Hi!

                  The signal-to-noise ratio on this forum is amazing!

                  I went with Ryan’s solution this time because it was so bloody easy.  Nothing like climbing over a mountain and then meeting someone who came through the tunnel.

                  Thanks for your help.

                  –dennis

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