Comments (4)
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.
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.
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.
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)
- Make changes to toHtml output so that it supports an Edit form HOT 1
- Fix method that removes loop ambiguity HOT 1
- getFinalizedMatch function needs to prioritize child loops over siblings HOT 1
- Examples for converting x12 837 and 835 to xml using java using this parser HOT 4
- Handling apostrophes in elements in `toX12String()` HOT 2
- Unable to parse huge x12 documents HOT 4
- X12 270/271 HOT 1
- Is it possible to get updated 5010 based 270/271 mapping files? HOT 3
- add 271 5010 - 005010X279A1 HOT 3
- X12Reader - getMatchedLoop unable to handle 271 LS and LE segments HOT 1
- Fix 277 5010 x212 mapping HOT 2
- 277 5010 x212 mapping has loop 2000B nested under 2000A HOT 1
- We found an ending segment but we never stored the first part of the loop! HOT 2
- README.md is pretty incomplete. HOT 7
- Creating/Writing example from README.md produces IndexOutOfBoundsException HOT 5
- A new PRV segment Mapper missing after the HI segment HOT 9
- Allow for custom mapping files
- 270/271 5010 support HOT 9
- Documentation error? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x12-parser.