Comments (3)
Yes, you have the right idea! Try this:
# ....
machine, = parser.read(Stupidedi::Reader.build(edi_content))
# After parsing, state machine is positioned at the end of input (last segment), so let's rewind
isa = machine.first
# We can't use isa.iterate(:ISA) here because #iterate always starts searching
# _after_ the cursor position, and would skip the first ISA!
#
# Note: if there was a way to rewind to right before the first segment, iterate
# would work just fine here. Or alternatively, #iterate could be made to search
# right at the current segment. Unfortunately this might break legacy code!
while isa.defined?
# Unwrap Either<StateMachine> to just a StateMachine. This is safe because we just checked isa.defined?
isa = isa.fetch
# Note: this returns an Either<Zipper<Segment>>
# seg = isa.segment
# We can use #iterate here because GS occurs somewhere after an ISA, rather than in the same location as the ISA.
isa.iterate(:GS) do |gs|
puts extract(gs, 6)
end
# Find the next ISA segment, returns Either<StateMachine>
isa = isa.find(:ISA)
end
puts "no more ISAs found. quitting."
sleep 1
from stupidedi.
If this does the trick, please close the issue. Otherwise let me know how I can help!
from stupidedi.
seems like that does the trick. thank you very much!
from stupidedi.
Related Issues (20)
- Doesn't handle arbitrarily large input files, and never will be able to HOT 5
- Duplicate Keys HOT 3
- Unknown patient gender in 270 causes validation error HOT 2
- value PR is not allowed in element NM101 HOT 2
- Segment ST Does not occur HOT 2
- Parse EDI 850 ERROR HOT 1
- Accept Tempfile in Stupidedi::Reader.build HOT 1
- Segment N1*PR~ cannot be reached
- Parsing an 837 and grabbing segment values HOT 2
- Is there a way to skip validations and build without some of the segments HOT 2
- 004010 version - B3-07 precision doesn't work as intended HOT 2
- value 091 is not allowed in element DTM01 Date/Time Qualifier HOT 2
- TD1 for X12 Release 4010 gets reduced to 2 fields instead of 10 for no reason HOT 1
- 835 - 005010X221A1 - NTE segment error HOT 2
- Stream writing HOT 2
- help wanted: Only the first element is return when iterating a repeated element HOT 2
- Inconsistent floating point output in 834 ICM data HOT 9
- Adding the additional accepted values for a segement HOT 1
- File permissions issue on v1.4.3
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 stupidedi.