X12 Node Path Syntax¶
The Accredited Standards Committee X12 (also known as ASC X12) develops and maintains EDI and CICA standards along with XML schemas which drive business processes globally. An X12 node path is used to reference segments and fields in an X12 message. The X12 node path syntax conforms to the following pattern.
Node paths in this section can be used with getNode, getAllNodes, and other QIE functions that accept a nodePath parameter. See How Node Paths Resolve for behavior details and the Node Path Lookup Dialog to build and validate them interactively against a sample message.
| Segment ID [ Instance ] /Sub-Segment Node Path – Field | ||
|---|---|---|
| Element | Required | Description |
| Segment ID | Required * | The 2 or 3-character X12 segment identifier (e.g. ISA or GS or BPR) |
| Instance | Optional |
|
| Sub-Segment Node Path | Optional | A Sub-Segment Node Path value can be appended to the Segment ID and Instance which identifies a sub-segment and field to select where the parent segment matches the Segment and Instance ID specified (TRN[@1=2]/N1[@3=XX]-4) |
| Field | Optional | The field index associated with the segment (1 or 2 or 3) |
* Segment ID is not required when specifying the root node identifier (/) as the node path
The partial X12 message below is used with the X12 node path examples that follow. The default X12 segment delimiter (~) is shown explicitly at the end of each segment.
ISA*00* *00* *ZZ*ABCCOM *ZZ*99999999 *040315*1005*U*00401*004075123*0*P*:~
GS*HP*ABCCOM*01017*20110315*1005*1*X*004010X091A1~
ST*835*07504123~
BPR*H*5.75*C*NON***********20110315~
TRN*1*A04B001017.07504*1346000128~
DTM*405*20110308~
N1*PR*ASHTABULA COUNTY ADAMH BD*XX*6457839886~
N3*4817 STATE ROAD SUITE 203~
N4*ASHTABULA*OH*44004~
N1*PE*LAKE AREA RECOVERY CENTER *FI*346608640~
N3*2801 C. COURT~
N4*ASHTABULA*OR*97004~
| X12 Node Path | Description |
|---|---|
| / | Returns the entire X12 message |
| ST | Returns the ST segment: ST*835*07504123 |
| N4[1] | Returns the first N4 segment: N4*ASHTABULA*OH*44004 |
| N4-2 | Returns the second field of the first N4 segment: OH |
| N4[2]-2 | Returns the second field of the second N4 segment: OR |
| N1[@1=PR]-3 | Returns the third field of the first N1 segment where field-1 = PR: XX |
Filter Operators and Predicates¶
X12 segment filters support the same comparison operators (=, !=, >, <), predicate functions (contains, starts-with, ends-with, equals), group filters (group=), and two-filter compound syntax (;) as HL7 HPath. See Filter Operators and Predicates under the HL7 section for full descriptions and function signatures. The optional caseSensitive argument defaults to false (case-insensitive).
The examples below use the X12 sample message shown above.
| X12 Node Path | Returns |
|---|---|
N1[@1=PE]-2 |
Equals, the 2nd field of the first N1 where field-1 = PE: LAKE AREA RECOVERY CENTER |
N1[@1!=PR]-2 |
Not equals: LAKE AREA RECOVERY CENTER |
N4[@3>50000]-2 |
Greater than (numeric), the 2nd field of the first N4 where field-3 (ZIP) is greater than 50000: OR |
N4[@3<50000]-2 |
Less than (numeric): OH |
N1[contains(@2, 'CENTER')]-2 |
Contains: LAKE AREA RECOVERY CENTER |
N1[starts-with(@2, 'LAKE')]-2 |
Starts with: LAKE AREA RECOVERY CENTER |
N1[ends-with(@2, 'BD')]-2 |
Ends with: ASHTABULA COUNTY ADAMH BD |
N1[equals(@1, 'pe')]-2 |
Equals function form (case-insensitive by default, matches PE): LAKE AREA RECOVERY CENTER |
N1[1;group=N3,N4] |
The first N1 grouped with its following N3 and N4 segments (the payer loop) |
N1[@1=PE;group=N3,N4] |
Compound filter, the N1 where field-1 = PE, grouped with its following N3 and N4 segments (the payee loop) |