Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do tables repeat? #172

Open
kputnam opened this issue Jan 16, 2019 · 5 comments
Open

Do tables repeat? #172

kputnam opened this issue Jan 16, 2019 · 5 comments
Labels

Comments

@kputnam
Copy link
Owner

kputnam commented Jan 16, 2019

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.

@irobayna
Copy link
Collaborator

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.

kputnam added a commit that referenced this issue Jan 18, 2019
  child loops to be repeatable (per X12 specifications); added
  TableDef.repeatable_detail for other cases (#172)

- Improve error messages in BuilderDsl by adding position and better
  descriptor (AbstractVal#descriptor)

- Create pass/, fail/, skip/, and case/ directories for fixtures for
  each transaction set; pass/, fail/, and skip/ automatically create
  rspec examples and case/ are ignored (to be used for hand-written
  rspec examples)

- Deprecate 005010X223 and 005010XX223A1 HC837, since HIPAA mandated
  005010X223A2 HC837; in case it's accidentally still used, old (X223,
  X223A1) are aliased to the new (X223A2)

- Define 005010X223A2 HC837

- Fix incorrect set of allowed values in 005010X214 HN277's 2220D
  STC10-03 and STC11-03; fix wrong requirement designation for 2220D DTP
  Service Line Date.

- Fix wrong requirement designation for 005010X279A1 HB271's 2000D HL
  segment

- Fix countless non-fatal errors in 005010 fixture files, such as
  element values that aren't allowed; loops, segments and elements
  that shouldn't be present; missing loops, segments and elements that
  should be present; incorrect separator characters; wrong element
  value lengths; ...
kputnam added a commit that referenced this issue Jan 25, 2019
repeatable loop, then the table is also considered repeatable; however,
the parser will prefer to reuse the current table, if possible, when
instantiating new instances of that loop. Otherwise, when the table
starts with a segment (optional or mandatory), or a non-repeatable loop,
then the table cannot be repeated.

Fix an issue (previously irrelevant) so tables can begin with not only
the first required SegmentUse or LoopDef declared, but all segments or
loops that start at the same position. Now tables that begin with a
qualified loop (eg, 2000A, 2000B, 2000C) work with the above changes.

Make a change so the parser, when inserting a segment, will always
figure out a single Instruction to execute, but when looking for an
existing segment it will execute an Instruction for each possibility
(eg, when a loop's start segment could've been placed in either a new
table or the current one).

Restore 005010X212 HR276 and 005010X214 HN277 to their ideal state,
now that TableDef.detail infers whether the table is repeatable or not,
and now that the parser accomodates both cases correctly.

Write specs for Navigation#find that enumerate most possible cases with
a minimal grammar defined for each case
@kputnam
Copy link
Owner Author

kputnam commented Sep 28, 2019

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 kputnam removed the question label Sep 28, 2019
@pauldraper
Copy link

pauldraper commented Jun 12, 2020

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.)

@kputnam
Copy link
Owner Author

kputnam commented Jun 13, 2020

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!

@pauldraper
Copy link

pauldraper commented Jun 14, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants