Comments (6)
Sorry it's too much work to try filling in all the missing parameters to run the code and reproduce your issue, I don't have a good way to do that. Maybe you can put all the values in a hash map at the top and reference them in your example, replacing any sensitive data with dummy values and make sure you can run the code as a standalone example.
Can you paste the stacktrace so we can better see where the error occurs? Since only a TableDef
actually has entry_segment_uses
(plural), it seems somehow the parser is expecting to have a table somewhere but it's got a loop instead.
Can you paste the schema you're using or link to its file if it was included with stupidedi? It seems likely to be an issue with the schema definition but it's to hard to narrow it down yet.
from stupidedi.
Since the only thing calling entry_segment_uses
is where the parser is generating instructions on how to parse your grammar, I think it's more likely an issue with the definition of your schema.
This happens in AbstractState.tsequence
, which expects an array of TableDefs
as an argument. That method is called from TransactionSetState.instructions
, so I'm guessing you might have some segments that weren't inside a table? That seems to match the diagram you pasted, and I think that is common with third-party documentation that kind of skips some details.
Your schema should look something like this, where immediate children to the whole document are only TableDef
. You cannot put a segment outside of a table, and maybe we're missing a sanity check to catch that error in the definition before it propagates too far.
HP835 = b.build("HP", "835", "Health Care Claim Payment/Advice",
d::TableDef.header("1 - Header",
s:: ST.use(100, ...
s::BPR.use(200, ...
...
d::LoopDef.build("1000", d::RepeatCount.bounded(200),
s:: N1.use( 800, ...
s:: N3.use(1000, ...
...,
d::TableDef.header("2 - Details", ...
d::TableDef.header("3 - Header", ...
Yours may look slightly different as I've been working in a different branch for several months and I'm not sure which changes were shipped and which haven't. But the key is that segments belong inside loops or tables, loops belong inside tables or other loops, tables belong inside transaction sets. Nesting them in other ways won't work.
from stupidedi.
Thank you for your reply, kputnam. Please, see below the code with data:
config = Stupidedi::Config.contrib
b = Stupidedi::Builder::BuilderDsl.build(config)
b.ISA "00", nil, "00", nil,
"02", "TTLM",
"ZZ", "MMLOO",
"200210", "2114", "U", "00401", "2", "0", "P", ">"
b.GS "IM", "TTLM", "MMLOO", "20200210", "2115", "111", "X", "004010"
b.ST "210", "000020001"
b.B3 nil, "A123", "A12320201", "CC", nil, "20200210", "1100", nil, "20200208", nil, "TTLM"
b.C3 "USD"
b.N9 "DO", "A12320201"
b.G62 "86", "20200201"
b.N1 "SH", "Company 1"
b.N3 "Address 123"
b.N4 "Los Angeles", "CA", "90013", "US"
b.N1 "CN", "Company 2"
b.N3 "Address 345"
b.N4 "Las Vegas", "CA", "88901", "US"
b.LX "1"
b.L5 "1", "Linehaul Cost"
b.L0 "1", "2400", "DM", "4", "G", nil, nil, nil, nil, nil, "L"
b.L1 "1", nil, nil, "800"
b.LX "2"
b.L5 "2", "Fuel Cost"
b.L1 "2", nil, nil, "150"
b.SPO "A12320201"
b.L3 "2400", "G", nil, nil, "950"
b.SE "21", "000020001"
b.GE "1", "111"
b.IEA "1", "2"
I also found out that if I keep in the code only these 2 rows, it gets printed out:
b.ISA "00", nil, "00", nil,
"02", "TTLM",
"ZZ", "MMLOO",
"200210", "2114", "U", "00401", "2", "0", "P", ">"
b.GS "IM", "TTLM", "MMLOO", "20200210", "2115", "111", "X", "004010"
but if I add there this one (or anything below this row), it will throw the error mentioned above:
b.ST "210", "#{metadata.transaction_set_nb}"
This might be a dumb question, but where can I get the stacktrace? In the terminal window, the whole error is literarily this:
Completed 500 Internal Server Error in 282ms (ActiveRecord: 15.7ms)
NoMethodError - undefined method `entry_segment_uses' for #<Stupidedi::Schema::LoopDef:0x3fd089375d04 ...>
Did you mean? entry_segment_use:
That's all regarding the error, which makes it quite difficult to debug it, as I am only guessing now what element can be corrupted.
I attached the file with the instructions on how to generate the 210 document. edi_210.pdf
Also - are you suggesting that the approach I follow to generate the document is wrong? I was able to successfully generate the 990s and 214s, so I continued using this approach also for the 210.
from stupidedi.
Thanks for that, I'll try to take a look tomorrow. I'm not familiar with Rails lately, but I believe there is a way to configure Rails to print backtraces of exceptions... maybe even just running it in the "test" RAILS_ENV?
See also the Rails documentation on debugging. If you can't work it out, in a pinch, you can wrap your code in a begin
.. rescue => e; logger.error(e); end
.
from stupidedi.
I'm not able to reproduce this, but your example code fails at generating the B3
segment with the error. This makes some sense because you have nil
for that element in the example:
required element B310 Date/Time Qualifier is blank at file test.rb, line 11 (Stupidedi::Exceptions::ParseError)
Perhaps we have unreleased code in master
, or maybe you're using an old version and this was fixed previously? Could you ensure you are using version 1.4.0 or are using gem "stupidedi", git: "irobayna/stupidedi", branch: "master"
if using Bundler?
from stupidedi.
Hi @kputnam, thank you! The problem really was in the version of stupidedi
I had in my Gemfile. My version was 1.2.15
and from some reason was causing problems with generating 210 files.
After upgrading to 1.4.0
, everything works fine.
from stupidedi.
Related Issues (20)
- Question: Is it possible to override or monkey patch validations? HOT 2
- Need help for parsing a very simple piece of file HOT 2
- Easy Guide HOT 3
- Support for pattern matching (Ruby 2.7+)
- Unable to set CSH segment HOT 2
- non-deterministic machine state revisitied HOT 4
- problems customizing a transaction set HOT 3
- Transaction splitting using notes/split.rb script: out of date? HOT 3
- iterating over files with multiple ISAs HOT 3
- 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
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.