IF and Iterate

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf IF and Iterate

  • Creator
    Topic
  • #49499
    Mark Perschbacher
    Participant

      I have been reviewing the wealth of postings about iterations and math operations, but I may be trying to accomplish something new (read impossible).  What I am trying to do is write an xlate that evaluates the OBR’s in an ORU, and any that have a P in field 25, it creates an OBX with several constant fields.  

      ITERATE: TYPE:Group BASIS: 1(0).1  VARIABLE: %g2

      nested ITERATE: TYPE:Segment BASIS: 1(0).1(%g2).0(0).OBR  VARIABLE: %s2

      nested IF 1(0).1(%g2).0(0).OBR(%s2).00258 eq =P

      COPY =whatever -> 1(0).1(%g2).1(0).OBX(%s2).00569.[0]

      With this xlate, it writes out an OBX, but they are not associated with the corresponding OBR.  They are all placed at the end of the message.  I need to put a MATH operation in, but I am not sure where.  Any help would be greatly appreciated.

    Viewing 2 reply threads
    • Author
      Replies
      • #62240
        Robert Milfajt
        Participant

          I just scanned the HL7 2.3 ORU definition, and it appears you have a segment iteration where you do not need one.  However, without knowing your particular HL7 definition, I am only guessing.  Try this:

          ITERATE: TYPE:Group BASIS: 1(0).1  VARIABLE: %g2

          nested IF 1(0).1(%g2).0(0).OBR.00258 eq =P

          COPY =whatever -> 1(0).1(%g2).1(0).OBX.00569.[0]

          Hope this helps.

          Robert Milfajt
          Northwestern Medicine
          Chicago, IL

        • #62241
          Jim Kosloskey
          Participant

            Mark,

            As we do not know what variant you are using let’s assume the standard ORU^xxx structure.

            In that structure (as Bob pointed out) the OBR is really a group under the ORC and the OBX is a group under the OBR.

            So the repetitions are Group repetitions.

            If your sending system actually sends multiple OBR groups per message (many do not), then you do need to iterate at that group level. If the sending system is only going to send one repetition of the OBR group per message, then you do not need to iterate at the OBR group (after all a single repetition is zero in the address path).

            In any case, your repetition for the OBX is a group repetition not a segment repetition.

            So if your variant has the normal structure, you need to modify your iteration(s) as Bob pointed out.

            That said, it sounds like you might want to create additional OBX repetitions with fixed values if the current repetition OBR contains a given value in a particular field.

            If that is true, then you will also need to position yourself properly and manage the repetitions of the outbound OBXs via your own iteration counter.

            Thanks,

            Jim Kosloskey

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

          • #62242
            Mark Perschbacher
            Participant

              It looks like I was pounding my head against the wall for naught.  I had been manipulating the HL7 variant with regards to the OBR, but not recompiling the xlate, sheesh.  Works fine now, thanks for your help.

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