indice-co / EDI.Net

EDI Serializer/Deserializer. Supports EDIFact, X12 and TRADACOMS formats
MIT License
447 stars 170 forks source link

834 Sample interchange ONLY parsing INS segment into MemberDetail #269

Open chowell1337 opened 3 weeks ago

chowell1337 commented 3 weeks ago

When using the BenefitEnrollmentAndMaintenance_834 class in X12_834.cs, the Headers' MemberDetails List DOES get a single entry for every single INS segment, but the only data getting parsed into each MemberDetail object is what's in the INS segment: image

Sample file used (sourced from here): x12.834.txt

I managed to get it working by changing the [EdiSegment, EdiPath()] attributes on the "multi-segment" classes into [EdiSegmentGroup] attributes. For MemberDetails, I'm doing [EdiSegmentGroup("INS", SequenceEnd = "INS")] since it's meant to include all segments from one INS segment til the next encountered (until the end of the set). Similar need to be done for the other "multi-segment" classes, like Benefit, ProviderInformation, AdditionalReportingCategories, and MemberReportingCategory

Additionally, there is nothing to handle COB or LUI segments.

As a sidenote, this is the only sample interchange that has Hashtable properties, but they don't seem to work. I assume it's to allow referencing the Lists by their first element in a Dictionary-like way; is that true?

cleftheris commented 2 weeks ago

Hi @chowell1337, in general avoid the use of SequenceEnd to break out of loops. It is a simplistic way to quickly define loops that will not get you too far. Prefer the explicit segment list alternative constructor (for example [EdiSegmentGroup("NAD", "FII", "RFF", "CTA")]).

You can see it in action in other answers regarding segment groups like https://github.com/indice-co/EDI.Net/issues/201#issuecomment-899293225.

chowell1337 commented 2 weeks ago

@cleftheris I see! I did use that explicit segment list syntax when correcting the wrapper classes of all the other loops; I was only hesistant to do so for MemberDetail because it includes so many segments that the Attribute parameter list would be absurdly long.

In fact, out of curiosity I just tested just removing the SequenceEnd parameter (i.e. [EdiSegmentGroup("INS")]), and to my surprise it actually still correctly parsed everything! Is that MORE valid than [EdiSegmentGroup("INS", SequenceEnd = "INS")]? or do you equally discourage that?