Message structure
The structure of the message is defined by message type and trigger event. For example, message type ACK and trigger event is A01. A message type may specify more than one trigger event code, but a trigger event may only be specified for a specific message type. The message type and trigger event are identified in the MSH segment. All components of a message may be defined as required, or optional.
A segment is a logical grouping of data fields. Segments might be either required, or optional in a message. Segments can occur only once in a message, or they may be allowed to repeat. A unique three-character code is used to identify each segment. A segment terminator is used to identify the end of a segment. This segment terminator is the carriage return character for HL7. Segments can repeat, and they might be logically grouped together to form a loop within the message.
Data fields
The data fields represent individual units of data found in the message. These fields are defined and re-used within segments and are given a data type. For example, the DateTimeOfMessage DTM Element Field is HL7 data type DTM. The data type identifies the characteristics of the data value and is used to validate the data. Data fields can be either required, or optional in a segment. Each field is delimited within the segment using the Field Separator Message control value which is the fourth character position in the MSH segment.