Combine results with Iteration

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Combine results with Iteration

  • Creator
    Topic
  • #49288

    Hi,

    I have the following inbound ORU message

    MSH

    PID

    ORC

    OBR

    ORC

    OBR

    ORC

    OBR

    OBX (1)

    OBX (2)

    OBX (3)

    OBX (4)

    I need to copy the OBX segments to the pair of ORC/OBR that are missing this segment. The message should look like this after it goes through the engine.

    MSH

    PID

    ORC

    OBR

    OBX (1)

    OBX (2)

    OBX (3)

    OBX (4)

    ORC

    OBR

    OBX (1)

    OBX (2)

    OBX (3)

    OBX (4)

    ORC

    OBR

    OBX (1)

    OBX (2)

    OBX (3)

    OBX (4)

    For the last couple of days I have tried using iterations on an Xlate and I kind of get close but not

    where I need to be.

    I appreciate any help you can provide regarding this matter.

    Thanks,

    Glenn

Viewing 1 reply thread
  • Author
    Replies
    • #61378
      Anonymous
      Participant

      Glenn,

      I’m sure there may be a simpler way to do this, but here is what I did.

      1.  Initialize a counter variable:

          COPY     =0 -> @ctr

      2.  Iterate through your OBR’s.  The only entry I have for the OBR is a MATH entry to increment the counter.

           MATH: ADD   =1 @ctr -> @ctr

      3.  After the iterate, add a MATH:SUB to subtract one from the final count in your counter variable.  This could have also been done without the MATH entries by taking the final OBR-2 field and reading it into a counter but not all systems may send that field:

          MATH: SUB     @ctr =1 -> @ctr

      4.  Copy the @ctr variable into a % variable that isn’t going to be used:

          COPY     @ctr -> $%l1

      5. Iterate again through your ORC/OBR pairs.  Set the iterate up as below.  The basis will depend on how your variant is set up.

           ITERATE   ENGINE=group   Basis= 1(0).1   Variable=  %g1

      6.  Move your ORC/OBR fields as needed.

      7.  Inside the ORC/OBR iterate, set up a nested iterate.   The settings should b:

           ITERATE   ENGINE=group   Basis= 1(0).1(%l1).1  Variable= %g2

      8.  Move your OBX segments in this manner:

           1(0).1(%l1).1(%g2).OBX.000571 ->  1(0).1(%g1).1(%g2).OBX.00571

      I got this to work in my tester (5.2).   Let me know if you can get it to work for you.  I’m also here in Houston at Memorial Hermann.   Look me up if you want me to email you the code.

      Thanks…

      Thomas G Rioux

      thomas.rioux@memorialhermann.org

    • #61379

      Many Thanks to Jim Kosloskey and Thomas Rioux for helping me solve this puzzle.

      Attached is the completed solution in case anybody is interested.

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

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,293
Replies
34,435
Topic Tags
286
Empty Topic Tags
10