Giter Site home page Giter Site logo

Comments (4)

angelaszek avatar angelaszek commented on July 24, 2024

I wasn't able to reproduce this. Here is the code from the unit test I wrote. I put the data you provided in the test.txt file.

` URL url = this.getClass().getResource("/837_5010/test.txt");
X12Reader reader = new X12Reader(FileType.ANSI837_5010_X222, new File(url.getFile()));

    Assert.assertEquals(1, reader.getLoops().size());
    Assert.assertEquals(1, reader.getLoops().get(0).findLoop("2300").size());
    Assert.assertNotNull(reader.getLoops().get(0).getLoop("2300").getSegment("CLM"));
    Assert.assertEquals(1, reader.getLoops().get(0).findLoop("2400").size());
    Assert.assertNull(reader.getLoops().get(0).getLoop("2400").getSegment("CLM"));
    Assert.assertEquals("OPI56804", reader.getLoops().get(0).getElement("2300", "CLM", "CLM01"));`

from x12-parser.

mcpierce avatar mcpierce commented on July 24, 2024

In my case the code isn't explicitly looking for the 2300 loop, Instead, once the 837 is loaded, it starts at the top and goes through each loop, segment, element and value and they are loaded into a Java data model. Does the 2300 loop not show up when using methods like getInnerLoops() of Loop?

from x12-parser.

angelaszek avatar angelaszek commented on July 24, 2024

Here are some examples that might help:

This gets the top of the overall structure
Loop loop = reader.getLoops().get(0);

Now lets get the first loop 2000B in the structure
Loop loop2000B = loop.findLoop("2000B").get(0)

If you do loop2000B.getLoops() it will return Loop 2300 since it is a direct child loop of Loop 2000B. getLoops() won't return Loop 2400 directly since it is one level down and a child loop of Loop 2300. You will need to call getLoops() on the 2300 loop object to get to the Loop object for 2400.

To get loop 2400 directly from loop 2000B (or any other loop higher than loop 2400) you can do something like this:
Loop loop2400 = loop2000B.findLoop("2400").get(0)
This is because findLoop searches through the child loops to find loop 2400.

Hopefully this helps answer your question.

from x12-parser.

mcpierce avatar mcpierce commented on July 24, 2024

Closing this as not-a-bug.

It turns out in our document builder code, we were not restoring the parent loop when descending into child loops. The 2300 loops was the symptom that made this error apparent.

Thanks for the great library!

from x12-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.