HL7 MessageTypeLanguage
HL7 MessageTypeLanguage
34 Context
35 Figure 1, reproduced from MDF-98, helps to place this discussion in context. (As discussed below, the caption for
36 the gray area will change from “Defining a Message Structure” to “Defining a Message Type” in MDF-99). XML is
37 an ITS. There may be other ITSs. One of the primary benefits of XML is that the small boxes at the bottom labeled
38 HL7 Message Creation and HL7 Message Parsing can rely on ubiquitous standard programs when the message
39 instance is an XML document.
Message
Object
Message Diagram
Information
Model
Common
Hierarchical
Message
Message
Element
Description
Definition
ITS
HL7 HL7
Message
Message Message
Data Data
Creation Instance Parsing
Implementation
Technology HL7-Conformant HL7-Conformant
Specifications Application Application
1
2 Figure 1. Version 3 process.
3 Definitions
4 An italicized term in the definitions is the subject of another definition. This section does not repeat the definition of
5 terms from MDF-98 that have not changed, unless important to the exposition.
choice message element A composite message element type for which only one of the components
type will be sent in an instance.
common message element Certain message element types are defined in Common Message Element
type Definitions. These are defined separately from their use as the type of a
Component in their HMD.
composite message A message element type that contains other message elements (components).
element type Each component message element has a name and a type. Each component
of an element must have a different name, although many may be of the
same type.
Hierarchical Message A metaobject that defines message types. It also defines the linkages of the
Definition (HMD) message types to Interactions and the linkages of certain message element
types to attributes of the Reference Information Model.
instance An utterance that conforms to a type. See message instance, message
element instance, etc.
MDF-98 The Message Development Framework for Version 3, published by HL7 in
January, 1998.
Ve rsi o n 1 .3 -
Ja n u a ry 2 5 , 1 9 9 9
+Bra nc hTy pe
Me s s a ge_e lem e nt_ ty pe
+C om pon ent Ty pe 1 1
nam e : String
is _ c om m on_ ty p e : b oolean 1
is _o f_t y pe
C o m pos it eMET
Prim it iv eMET C h oic eMET Lis tMET
is _ s eg m e nt : bo ole an
dat a t y pe : I D m in_ c ard : Int ege r
1 m a x _c a rd : I nte ger
+Bra nc h 1.. *
C h oic eBranc hD es c ript or
1.. *
C o m pone ntD e s c rip tor
+C om pon ent tag _v alue : St ring
nam e : String is _ of _ty pe
is _ opt ional : boolea n
0.. *
is _o f_t y pe s equ enc e : int eger Me s s a geMet
loc ale : ID
5
6 Figure 3. Message Element Type Metamodel.
36 The message comprises two components. Each has a name, a short name, and is "of a type". Note that in this
37 example the short name and the type name are the same. This is very common in HL7. There are not likely to be two
38 different components of a message, both of type MSGH (message header) so it doesn't make much sense to waste
39 brainpower trying to find an original name. As we will soon see, this is a common occurrence, but it does not
40 happen all the time.
25 METL Syntax
26 Lexical notes: any white space is allowed between any syntax elements. This includes newlines. Newlines are
27 required, however, where they appear in the syntax.
28 “<include filepath>” appearing in column 1 (with the angle brackets) terminates processing of the current file and
29 continues with the file at filepath.
26 A Naming Anomaly
27 Arguably, an XML element definition defines a type. The element so defined will be used in many message
28 instances where the contents will vary. It is surprising, then, that the names of XML elements do not correspond
29 with Message Element Types. Many XML element names are not the names of message element types: sndApp and
30 rcvgApp, above, are examples of this. Many message element types are not the names of XML elements. CE, XTN,
31 and ST are examples.
32 Most XML elements names are actually component names in METL. In fact, there are only three ways that the name
33 of a message element type becomes the name of an XML element:
34 • it is the name of a 'message' message element type
35 • it is the name of a list message element type
36 • it happens to have the same name as a component that is in the message.
37
38 Because of the Indiana dot notation, however, message element names frequently appear as the prefix for XML
39 element names.
40 For me, this was the hardest thing to grasp in the entire process: except for the message itself, it is only component
41 names that become the names of message elements.
42 Parameter Entities
43 The primary reflection of a message element type in a DTD is in the content model of an element. Whenever more
44 than one component in a message has the same type, each component will be generated with the same content
45 model. The DTD compiler generates a parameter entity for such types, and invokes it wherever it is used. The entity
46 name is DT_<short name of message element that defines the data type>.
47 For example, there are several elements in the toy message of type CE.
48
4 Full DTD and XML Instance Example for the Toy Message
5 Figure 7. DTD for the Toy Message
6 <!--=======================================================================
7 HL7 Version 3 Prototype Message: QRYNam_Patient_Reg [QRgNamv3P00]
8 =======================================================================-->
9
10 <!ENTITY % DT_CE "cd, tx?, cs, acd?, atx?, acs?">
11
12 <!ELEMENT QRgNamv3P00 (QRgNamv3P00.MSGH, QRgNamv3P00.QPTNAM)>
13
14 <!ELEMENT QRgNamv3P00.MSGH (sndApp?, rcvgApp?, msgDt?, msgTyp)>
15
16 <!ELEMENT QRgNamv3P00.QPTNAM (QPTNAM.primrNamType, QPTNAM.primrPrsnm,
17 QPTNAM.StkID?, QPTNAM.PhonNmbr_L?)>
18
19 <!ELEMENT QPTNAM.primrNamType (%DT_CE;)>
20
21 <!ELEMENT QPTNAM.primrPrsnm (fmn, gvn?, mdn?, sfx?)>
22
23 <!ELEMENT QPTNAM.StkID (StkID.id, StkID.idType)>
24
25 <!ELEMENT QPTNAM.PhonNmbr_L (PhonNmbr_L.item+)>
26
27 <!ELEMENT StkID.id (#PCDATA)>
28 <!ELEMENT StkID.idType (#PCDATA)>
29
30 <!ELEMENT sndApp (#PCDATA)>
31 <!ELEMENT rcvgApp (#PCDATA)>
32 <!ELEMENT msgDt (#PCDATA)>
33 <!ELEMENT msgTyp (msgID, intrId?)>
34
35 <!ELEMENT msgID (#PCDATA)>
36 <!ELEMENT intrId (#PCDATA)>
37
38 <!ELEMENT fmn (#PCDATA)>
39 <!ELEMENT gvn (#PCDATA)>
40 <!ELEMENT mdn (#PCDATA)>
41 <!ELEMENT sfx (#PCDATA)>
42
43 <!ELEMENT cd (#PCDATA)>
44 <!ELEMENT tx (#PCDATA)>
45 <!ELEMENT cs (#PCDATA)>
46 <!ELEMENT acd (#PCDATA)>
47 <!ELEMENT atx (#PCDATA)>
48 <!ELEMENT acs (#PCDATA)>
49
50 <!ELEMENT PhonNmbr_L.item (XTN_C.emailAddr| XTN_C.ExtndTelId)>
51 <!ELEMENT XTN_C.emailAddr (#PCDATA)>
52 <!ELEMENT XTN_C.ExtndTelId (tlcmnUse, tlcmnEqpTyp, cntryCode?, areaCityCode?,
53 phonNmbr, xtnsn?, anytxt?)>
54
55 <!ELEMENT tlcmnUse (%DT_CE;)>
56
57 <!ELEMENT tlcmnEqpTyp (%DT_CE;)>
58
59 <!ELEMENT cntryCode (#PCDATA)>
60 <!ELEMENT areaCityCode (#PCDATA)>