X12 EDI Loops Structure
Typical X12 EDI loops structure does not look like XML format file – it is difficult to see where one block ends and another block begins due to absence of so called closing tags. In order to see X12 EDI loops and understand the structure of the file, one should have a look at templates given in EDI X12 standard documentation. These templates are usually given together with EDI software used. In the examples you can see blocks that are nested in one another (looks like tree structure) – this is EDI X12 looping template.
In a typical 837 Healthcare Claim or 850 Purchase Order transaction, for example, we can see that loops shown in a tree structure represent blocks of repeating segments. But some other EDI files’ structure is represented by hierarchical looping. In this case X12 EDI loops may have child loops with numeric ID’s of the parent loops (837 Healthcare Claim is a typical example). Extracting data from hierarchical looping structure is quite hard.
Unbounded and Bounded Loops
Usually unbounded loop starts with a definite segment that has other child segments, and starting segment can occur only once in the loop. The next appearance of the starting segment starts a new loop. Loops may be optional or mandatory as we know and the defined maximum number of times it can repeat. We can view N1/N2/N3/N4 Name and Address loop as a good example of the unbounded loop.
In general, a bounded loop is similar to an unbounded one, but the main difference is that a bounded loop is bracketed by LS Start loop and LE End loop segments. Bounded loops are used for identification of the loops that may be indistinguishable from each other.
Usually 837 Health Care Claim may show us an example of the bounded loop:
- NM1 loop starts at position 2110 and identifies the subscriber
- In NM1 loop there are several NM1 loops identifying entities related to the given subscriber, e.g. at 2310 there is an NM1 loop describing the Health Care provider
- 2310 loop is bounded by an LS/LE structure. If we do not have this type of structure it may seem that a new NM1 loop at 2110 position serves for Subscriber.