stupidedi icon indicating copy to clipboard operation
stupidedi copied to clipboard

Do tables repeat?

Open kputnam opened this issue 5 years ago • 5 comments

Most X12 transaction set definitions have three tables: a header table, a detail table, and a summary table. The header and summary tables usually begin with a non-repeatable segment (eg, ST and SE); it seems clear that the tables must only occur once. In HP835, the summary table begins with an optional, repeatable PLB segment; however, it still doesn't make sense for the table to be repeated, because that would allow more than one SE segment.

Unlike header and summary tables, it's less clear if entire detail tables can be repeated, or if only the loop directly inside the tables can repeat. In most cases there is only a single detail table, and it begins with a repeatable loop; it's not clear if occurrences of that loop should each be placed in the same table or each in their own table. For most purposes, it doesn't matter. Currently (v1.2.0), each loop will be parsed into a separate table.

In other cases, there are detail tables which begin with either a non-repeatable segment or loop (005010X214 HN277). It's not clear if the table should be allowed to repeat, but most likely it should not. Finally, there are cases where a transaction set has multiple detail tables (005010X214 HN277). When these begin with repeatable segments or loops, then the ambiguity about repeating tables becomes significant.

If tables cannot repeat, then interleaving multiple detail tables would not be allowed. For example, in 005010 HN277, Table 2 - Billing Provider Detail begins with a repeatble HL**19 loop, and Table 2 - Patient Detail begins with a repeatable HL**PT loop. Suppose the input contains the sequence HL**19,HL**19, HL**PT. This could be organized into a single Billing Provider Detail table (with two occurrences of the HL**19 loop), followed by a single Patient Detail table. Now suppose the order is changed to HL**19, HL**PT, HL**19. This must construct at least two Billing Provider Detail tables. If tables cannot be repeated, this would be a syntax error.

I have sent a request to X12 for clarification, but I expect it will take a few months for a response. In the meantime, I will be changing TableDef.detail to define a non-repeatable table, and I will add TableDef.repeatable_detail as its counterpart. One advantage of this change is that TransactionSetDefs will more closely match the documentation they're derived from, both superficially and meaningfully.

kputnam avatar Jan 16 '19 02:01 kputnam

This item will make the library even better, a step in the right direction. Nothing wrong with having clear guidelines hence repatable_detail and non-repeatable concept for tables makes sense to me.

irobayna avatar Jan 16 '19 15:01 irobayna

Finally X12 replied to my question but it didn't help my understanding of this issue. Given that it took 9 months to receive an answer, I don't think I'm going to ask a clarifying question.

I asked about 005010X214 HN-277 page 26, where two "Table 2"s with repeatable loops are shown. One is for patient details and the second is for billing provider details. Their response is that there is only one table, and the order of HL segments has to be depth-first (parents, then children).

I'm not completely sure how to interpret that response. Maybe they mean that the transaction set shows two tables only for explanatory purposes, but logically it's the same table. I'll come back to this later, but that's what seems most likely to me.

To implement that, I don't think it would require changing the parser, just the definition classes and helpers would change. For example TransactionSetDef.build could ensure there is only one kind of each table type (header, detail, summary), and TableDef#repeatable? would always return false.

kputnam avatar Sep 28 '19 00:09 kputnam

There is only one Table 2 in 277, though it defines multiple loops.

The split of transaction sets into heading, detail, and summary areas is very common among EDI transaction set definitions...the heading, detail, and summary areas of a transaction set will be referred to as Tables 1, 2 and 3, respectively...Note that Table 2 would encompass multiple detail areas, if applicable.

Every transaction set definition will have one and only one heading area, composed of at least one segment.

The entire summary area comprises a segment group, which is not repeated.

A detail area is any looping structure between the heading area and the summary area (or the SE, if no summary area exists).

There can be multiple detail areas in a transaction set definition.

X12.59 5

"Detail areas" -- i.e. non-nested loops described in Table 2 -- simply repeat according to their loop repetition specification, with no requirements for adjacent loops.

(Caveat: The HIPAA implementation guides require that HL-loops are arranged in depth-first hierarchical order.)

pauldraper avatar Jun 12 '20 17:06 pauldraper

Thanks Paul, that clears things up very well. My file server is down so I can't look for those quotes. What is that document's name/title? Hopefully it's not something that was sitting under my nose the whole time!

kputnam avatar Jun 13 '20 05:06 kputnam

That's in the X12 standard (X12.59, section 5). I have that in .chm form.

pauldraper avatar Jun 14 '20 23:06 pauldraper