The object oriented programming technique as provided by C++ allows a very natural view on the HL7 data items. Any data item is an object of HL7 (HL7 object). Individual data types, segments or messages are special objects, which share common properties. We define the properties that are common to all HL7 objects as the class "HL7Object". The class "HL7Object" is an abstract base class which still contains some method and data instances including the flag that shows if an object is present or not.
Figure 4: The hierarchy of HL7 objects
There is a hierarchy of objects as shown in figure 4. Basically there is the HL7Object, which is inherited by any other data object. Then come the basic HL7 types and the set of delimiters, which could be regarded as a special data type as well. These basic types have been implemented manually since the basic types are quite heterogeneous but only a few in all. It doesn't seem appropriate to implement them automatically from some kind of a data base. Moreover, the description of data types in the HL7 standard is presented in a narrative form which is hard to scan for specifying data.
The composite objects are however generated from a simple relation that describes their contents. Normally a component is a basic data type (with some exceptions, when a component is itself a composite, see below (see section I/O methods)), which reduces the organization in a composite data type to just collect the basic data types. The relation that describes the composites is manually edited.
Segments are described in the HL7 standard by tables, which we have brought in the form of a data base. The implementations of segments are generated from this data base. So are the implementations of messages. There is a need for an abstraction of segments to be introduced: the ANY segment. This is a segment, that can be of any type. Since segments are encoded as tagged data, i.e. data that is preceded by some identifying code, we can exactly discriminate the types of segments by the tag (the segment id). This is not possible with data types, since there are ambiguities and no tag.
What we just told about the ANY segment applies for the ANY message as well. However, to discriminate messages is more complex than it is with segments, since the information about message types is scattered throughout several segments.
There are several qualities which are common to all HL7 objects, we present these during the following subsections.