aaronhuggins / node-x12

ASC X12 parser, generator, query engine, and mapper; now with support for streams.
https://aaronhuggins.github.io/node-x12/
MIT License
49 stars 14 forks source link

X12 EDI Loop Schema Possibilities #45

Open Elijah-Smith96 opened 8 months ago

Elijah-Smith96 commented 8 months ago

Hi Aaron, I was wanting to know if there is a way to generate a JSON object containing all of the appropriate loops within the parsed EDI. Im very interested in the 837 capabilities, so far all I have been able to produce are objects containing the segments and elements. What I would like to produce would be nested objects containing the actual 837 loops.

aaronhuggins commented 8 months ago

Do you have sample documents? I think the query language may be the best place to start, but if you can share some samples, I'd be able to provide a more clear answer.

aaronhuggins commented 8 months ago

@Elijah-Smith96 I'm pretty sure the query language will be your path forward. X12 does not specify loop behaviors natively; they provide semantic constructs for defining loops in an X12 interchange, but beyond that how a loop behaves and/or how you get information about a loop is rather undefined.

The purpose of the query language is to overcome limitations in the X12 schema, among those limitations being loops. The FOREACH macro in the query language will be your best friend. More detail about how to leverage the query language can be found in the transaction mapping guide, the test suite, and the test suite map sample which is used for validation.