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

Guides::FiftyTen::X223::HC837I cannot be parsed deterministically #155

Closed
kputnam opened this issue Dec 24, 2018 · 3 comments
Closed

Guides::FiftyTen::X223::HC837I cannot be parsed deterministically #155

kputnam opened this issue Dec 24, 2018 · 3 comments
Labels

Comments

@kputnam
Copy link
Owner

kputnam commented Dec 24, 2018

The parser will complain because, starting from any segment in the 2400 SERVICE LINE NUMBER loop, reading an NM1*DN could either instantiate the 2420D child loop or the ancestor's older sibling, 2310F loop.

The grammar is correct and does match the documentation, so it looks like the parser will need some changes to accommodate this kind of grammar. My guess is we need to take into consideration the position of the header segment of each loop. In this case, 2310F, whose entry segment has position 2500, shouldn't be instantiated because 2400's entry segment has position 3650.

I think this change shouldn't cause any negative effects for the grammars that were faithfully transcribed from official X12 documentation. But in some other grammars, I'm guessing the position was made up or copied from other places, so those may cause parser errors on legitimate inputs.

To detect those problems, we will need to add a spec for each grammar that asserts it can parse valid inputs without any errors or InvalidSegmentVals, etc. I suggest completely automating having to write those tests by using some kind of naming conventions for "good" inputs that will match the file to the correct definition, and generate the specification similarly to auditor_spec.

@kputnam
Copy link
Owner Author

kputnam commented Jan 13, 2019

Fortunately, my hypothesis was wrong! The issue was simply that the parentheses were incorrect. This will be fixed when 831c7e3 is merged.

@kputnam kputnam added the defect label Jan 18, 2019
@RomanKapitonov
Copy link
Contributor

@kputnam Are you sure? I've been using Guides::FiftyTen::X223::HC837I as a basis for Guides::FiftyTen::X223A3::HC837I. And i did not encounter that issue.

If I apply the same changes from 831c7e3 to a new X223A3 transaction I get an error. Without those changes bin/edi-pp outputs a valid transaction.

@kputnam
Copy link
Owner Author

kputnam commented Jan 22, 2019

I'm not sure about X223A3, but the change I made to plain old X223 was correct, I believe. You can double-check your parentheses by doing this:

ruby -Ilib -rstupidedi -rpp -e 'pp Stupidedi::TransactionSets::FiftyTen::Implementations::X223A2::HC837' | grep -E '(Segment|Table|Loop)Def'

Prior to 831c7e3, the output for Stupidedi::Guides::FiftyTen::X223::HC837, the relevant portion of the output was:

        LoopDef[2320 OTHER SUBSCRIBER INFORMATION](
            SegmentDef[SBR](
            SegmentDef[CAS](
            SegmentDef[AMT](
            SegmentDef[AMT](
            SegmentDef[AMT](
            SegmentDef[OI](
            SegmentDef[MIA](
            SegmentDef[MOA](
          LoopDef[2330A OTHER SUBSCRIBER NAME](
              SegmentDef[NM1](
              SegmentDef[N3](
              SegmentDef[N4](
              SegmentDef[REF](
          LoopDef[2330B OTHER PAYER NAME](
              SegmentDef[NM1](
              SegmentDef[N3](
              SegmentDef[N4](
              SegmentDef[DTP](
              SegmentDef[REF](
              SegmentDef[REF](
              SegmentDef[REF](
              SegmentDef[REF](
              SegmentDef[REF](
          LoopDef[2330C OTHER PAYER ATTENDING PROVIDER](
              SegmentDef[NM1](
              SegmentDef[REF](
          LoopDef[2330D OTHER PAYER OPERATING PHYSICIAN](
              SegmentDef[NM1](
              SegmentDef[REF](
          LoopDef[2330E OTHER PAYER OTHER OPERATING PHYSICIAN](
              SegmentDef[NM1](
              SegmentDef[REF](
          LoopDef[2330F OTHER PAYER SERVICE FACILITY LOCATION](
              SegmentDef[NM1](
              SegmentDef[REF](
          LoopDef[2330G OTHER PAYER RENDERING PROVIDER NAME](
              SegmentDef[NM1](
              SegmentDef[REF](
        LoopDef[2330H OTHER PAYER REFERRING PROVIDER](
            SegmentDef[NM1](
            SegmentDef[REF](
        LoopDef[2330I OTHER PAYER BILLING PROVIDER](
            SegmentDef[NM1](
            SegmentDef[REF](

Notice the 2320I and 2320H loops are at the wrong depth

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

2 participants