Skip to main content

Import an EDI X12 interchange

ANSI ASC X12 is the EDI standard North American supply chains, retailers and health plans run on: a purchase order (850), an invoice (810), a ship notice (856), a health care claim (837), a benefit enrollment (834) and the functional acknowledgement that answers them (997). Apiome imports an X12 interchange into the Catalog beside its twin, UN/EDIFACT. The transaction set becomes a schema you can search, version, diff and convert. Apiome lints the envelopes the way a trading partner's translator checks them, and keeps the whole interchange as a native analysis on the item's Format details tab.

What you can import​

You haveWhat Apiome makes of it
One interchange file (.edi, .x12): ISA … IEA, with GS … GE groups and ST … SE transaction setsOne catalog item
An interchange with several groups or transaction setsOne catalog item; every group and set is in the analysis
An archive (.zip, .tar.gz) whose root member is an interchangeOne catalog item read from the root interchange
The interchange on your clipboardA paste

A UN/EDIFACT interchange (UNB / UNH) shares the .edi extension but is a different syntax: Apiome detects it as UN/EDIFACT instead.

Import it​

  1. Go to Bring in → Catalog and click "Import to catalog" (see the import wizard).
  2. On Source, choose File and drop the interchange (try apiome-ui/examples/edi-x12/01-850-purchase-order.edi), or choose Paste and paste it.
  3. On Detect & route, Apiome reports Auto-detected: EDI X12 (edix12) and routes it to the Catalog.
  4. On Quality, review the lint findings and click "Import".

Over the API, send the interchange to the import endpoints with the source kind edix12 (aliases x12, edi); see Import sources. From the CLI:

apiome import edix12 ./01-850-purchase-order.edi

The examples in apiome-ui/examples/edi-x12/ cover an 850, an 810, a 997, an interchange with two groups, an 856 with an HL hierarchy, an 834 and an 837 with composite elements.

What Apiome reads​

In the interchangeBecomes
The first group's first transaction setThe canonical model: a record type named for the set (TransactionSet850)
A segment that occurs once in that setFields of the set's type, named by reference designator (BEG03: segment BEG, element 03)
A segment that repeats (PO1, N1, HL)Its own record type, listed from the set's type
Element valuesThe fields' sample values: what this interchange carried, not a definition
ISA, GS, ST and their trailersThe item's envelope record (x12_envelope), the controls the lint pack checks (x12_controls) and the native analysis

When an interchange carries more than one transaction set, the analysis says which one the model came from. See The X12 inspector for how to read the Format details tab.

Lint rules​

The edix12 lint pack runs on every X12 item with the common pack, and its findings count toward the item's score and grade. It checks the envelopes, and checks nothing an implementation guide decides:

RuleSeverityFires when
edix12.control-numbers-matcherrorA trailer does not repeat its header's control number: SE02 ≠ ST02, GE02 ≠ GS06, or IEA02 ≠ ISA13
edix12.control-totals-matcherrorA trailer's total is not what it closes: SE01 ≠ the segments from ST to SE, GE01 ≠ the group's transaction sets, or IEA01 ≠ the interchange's groups
edix12.control-numbers-uniquewarningTwo transaction sets in a group, or two groups in the interchange, share a control number
edix12.functional-id-matches-setwarningGS01 is not the functional identifier X12 assigns the set (PO for an 850, IN for an 810, HC for an 837)
edix12.version-declaredwarningGS08 is empty
edix12.usage-indicator-validwarningISA15 is not P (production), T (test) or I (information)
edix12.test-interchangeinfoISA15 is T

An interchange whose trailers disagree still imports. The two errors fail a quality gate, and the Format details tab shows the declared and observed figures side by side. Every rule's rationale is on Built-in lint rules.

Versions and diffs​

An X12 item is a sample, so its diff is graded as one. A new interchange with the same structure and other values is a safe version, not a dangerous one:

Change between two versionsGradeRule
Another transaction set (ST01 850 → 855)breakingedix12.transaction-set-changed
A segment is no longer sentbreakingedix12.segment-removed
A segment no longer carries an elementbreakingedix12.element-removed
A segment is now sentdangerousedix12.segment-added
A segment now carries another elementdangerousedix12.element-added
A segment repeats in one version and occurs once in the otherdangerousedix12.segment-repetition-changed
An element's position in the flattened record moved, because a segment before it was added or removedsafeedix12.ordinal-shifted
Only the values changedsafeedix12.sample-value-changed

A receiver that validates against an implementation guide rejects a segment or element the guide does not list, so an addition is dangerous, not safe. Whether a segment may repeat is the guide's maximum use, which Apiome does not read, so a change in repetition is dangerous too.

What Apiome does not check​

  • No implementation guide is consulted. Apiome reads the X12 syntax only, not the 004010 or 005010 guides, so segment usage, element lengths and code lists are not checked. A structurally valid interchange is not claimed to be a conformant one.
  • HL loops are read as the segments they are, not as the hierarchy they encode.
  • Values are samples. Two interchanges of one transaction set can differ in every value and still follow the same definition; the diff grades them that way.