ITERATE

This action defines an iterative block of translation actions. The block repeats every time the specified basis is encountered in the input record. This is the only way to deal safely with repeating elements.

Iteration is based on a specific element of the input record. For example, an HL7 segment, HL7 repeating group, a field name from a record, or a constant list.

When defining an iteration, these items must be defined:

  • Type is what you are iterating over.
  • Basis is where you are iterating.
  • Variable is how to ensure you get all repetitions.

Iterating over a user-defined list referenced by a variable

To iterate over a user-defined list that is referenced by a variable, use the “user” iterate type (list, segment, field, group, and user are all iterate types).

For the basis, use the name of the variable. For example, @mylist.

The iterate then loops over each element in the list that is referenced by @mylist.

Example:

COPY =a b c d --> @mylist
ITERATE user @mylist %u1

In this example, %u1 contains “a” for the first iteration.