Each segment of an HL7 message consists of one or more composites (also known as fields). By default, the | (pipe) character is used to separate one composite from another.
A composite can be a primitive data type (such as a character string or a number), or can contain other composites.
If a composite contains other composites, these sub-composites (or sub-fields) are normally separated by ^ characters. If a sub-composite also contains composites, these sub-sub-composites are normally separated by & characters. Sub-sub-composites must be primitive data types.
For an example of a typical composite, consider the PID segment of the sample message that you have seen in the previous sections:
PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203|M||B|254 MYSTREET AVE^^MYTOWN^OH^44123^USA||(216)123-4567|||M|NON|400003403~1129086|
In this segment, the fifth composite is the patient name, which is DOE^JOHN^^^^. (The four ^^^^ characters at the end of this composite indicates that it has a total of six sub-composites, and that only the first two of the sub-composites are defined.) In this composite, DOE represents the family name of the patient, and JOHN is the patient’s given name.
In order to be as flexible as possible and achieve a consensus, the HL7 committees were forced to define many segment fields as optional. The downside of this decision is that you cannot be certain that particular information will be present in a given message. This is one of the reasons why the same message may vary significantly from vendor to vendor.