Comments (3)
Hey Alex, I'm going to close this issue. It sounds like you're okay with the proposed solution and I think a better looking solution will take more time than it's worth. I agree on having a guide that walks through various configuration scenarios, but I don't know that I'll be able to set aside time for that in the near future.
from stupidedi.
Hey Alex,
Thanks for the detailed report, especially the code. Now that I've actually read the full example, I can delete my very long response, and the issue is trickier than I anticipated! :-)
There's nothing wrong with your definition. I think the problem is how Stupidedi looks up the segment definitions when reading a file or building one with BuilderDsl
. My recollection is that it goes like this: you call b.N1
then BuilderDsl looks up the definition for N1 in the SegmentDefs module for the version you're using (FortyTen). That association is made when you register the 4010 functional group in the Config
. That FunctionalGroupDef refers to the N1 defined by Stupidedi, so your custom N1 definition isn't used.
Ideally you wouldn't need to do anything beyond what you've already written, and it would be handled behind the scenes. I need to do some thinking about how/if this could be possible though. The underlying assumption currently is that there's a single definition of a segment for each X12 version. Removing that assumption might be possible but tricky to do correctly.
But in the mean time, I think you can define your own FunctionalGroupDef
with something like this:
module MySegmentDefs
include Stupidedi::Versions::FortyTen::SegmentDefs
N1 = ...
end
# Despite the capitalization, this is actually a singleton instance of an anonymous class
# that inherits from Values::FunctionalGroupDef. We need to override one method.
MyFunctionalGroupDef = Stupidedi::Versions::FortyTen::FunctionalGroupDef.clone
class << MyFunctionalGroupDef
def segment_dict
MySegmentDefs
# You can also not use `include` in the module above and do this instead
# Stupidedi::Reader::SegmentDict.build(super).push(MySegmentDefs)
end
end
config.functional_group.register("004010") { MyFunctionalGroupDef }
There are a few different ways to write that, but I think that's clearest. Sorry that you need to write that to get it to work, it annoys me just looking at it... at least it's not a lot of code 🤷♂️. If I figure out a better way to handle it and I'll let you know, but it probably won't be soon.
from stupidedi.
@kputnam thanks a million for this input. i've tried out your suggestions and it seems to behave just as i'd expect. i can add/remove elements from segments with a minimum of fuss. this is excellent. (Much better than the dirty hacks we've been doing (like modifying Stupidedi::TransactionSets::FortyTen::Implementations::IM210.table_defs
at runtime to patch in our modified segment definition...)
I think the problem is how Stupidedi looks up the segment definitions when reading a file or building one with BuilderDsl.
yes, and this was part of the stupidedi code i was never able to piece together on my own. your explanation clears it up nicely.
Ideally you wouldn't need to do anything beyond what you've already written, and it would be handled behind the scenes.
Perhaps, but so far it seems like the alternative you've offered here will serve nicely. I'll try unwinding some of our current hacks and see if I can straighten things out using the approach you describe here. Assuming that goes OK I don't see any need for further action - though a "how to customize segment definitions" guide might be a useful addition.
from stupidedi.
Related Issues (20)
- 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
- 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.