The X12 messages are all in ASCII text, with the single exception that the BIN segment is binary. Each X12 message is made up of a combination of the following elements:
Data
Segments
Loops
Elements are separated by delimiters. The remainder of this section explains these elements.
The data element is the smallest named unit of information in the X12 standard. Data elements can be broken down into types. The distinction between the types is strictly a matter of how they are used. The types are:
Simple – If a data element occurs in a segment outside the defined boundaries of a composite data structure, it is called a simple data element.
Composite – If a data element occurs as an ordinally positioned member of a composite data structure, it is called a composite data element. A telephone number is a simple example of a composite. It has a three-digit area code, which must precede the three-digit central office code, which must precede the final four digits.
Each data element has a unique reference number, and it also has a name, description, data type, and minimum and maximum length.
A segment is a logical grouping of data elements. In X12, the same segment can be used for different purposes. This means that a field’s meaning can change based on the segment. For example:
The NM1 segment is for any name (patient, provider, organization, doctor)
The DTP segment is for any date (date of birth, discharge date, coverage period)
For more information on the X12 enveloping segments, refer to Structure of X12 Envelopes.
Loops are sets of repeating ordered segments. In X12 you can locate elements by specifying:
Transaction Set, for example 270 or 271
Loop, for example “info. receiver loop”
Occurrence of the loop
Segment, for example BGN
Field number, for example 01
Occurrence of the segment (if it is a repeating segment)
In an X12 message, the various delimiters are part of the syntax, dividing up the different elements of a message. The delimiters used in a message are defined in the interchange control header, the outermost layer enveloping the message.
For this reason, there is flexibility in the delimiters that are used. No suggested delimiters are recommended as part of the X12 standards, but the industry-specific implementation guides do have recommended delimiters.
The default delimiters used by the X12 OTD Library are the same as those recommended by the industry-specific implementation guides. The default delimiters in the X12 OTD Library are:
~ (tilde)
* (asterisk)
: (colon)
+ (plus sign)
Within eXchange, delimiters are specified at the enveloping level. The delimiters defined for an envelope apply to all transactions in the same business service (a predefined dialog between the two parties).
It is important to note that errors could result if the transmitted data includes any of the characters that have been defined as delimiters. Specifically, the existence of asterisks within transmitted application data is a known issue in X12 and can cause problems with translation.
See Element Separator for information on the ePM delimiter parameter.