HEALTHCARE COST & UTILIZATION PROJECT

User Support

Do Your own analysis
Explore Expert Research & Limited Datasets

Templates for using HL7 v2.5 messages

NOTE: THIS DOCUMENT CONTAINS FIELD SEPARATORS SYMBOLIZED BY VERTICAL BARS. "[BAR]" INDICATES THE USE OF A BAR.

Templates for using HL7 v2.5 messages

W. Ed Hammond
March 23, 2008

This document includes a set of templates for using HL7 v2.5 messages for the exchange of data from participating hospitals and clinics and a central repository.

An HL7 message is composed of segments designed for a specific purpose to carry data related to patient demographics, the encounter, and data created during the encounter. Each segment begins with a 3 letter mnemonic which identifies the segment. Some segments are repeating. If a data field is not used, the field delimiter is inserted so the position count in the segment is maintained.

Although I have included a few templates for segments you may not use at the beginning, they will be used shortly. There are many more segments that I will not include in this document at the present time for simplicity. If a need later arises for data included in these other segments, I will add to this document. The HL7 v2.n series of messages have grown over the past 20 years and are rather complete in content.

All messages begin with the MSH, or Message Header, segment. This segment identifies the sender and the receiver and includes a date/time stamp. Most messages will include also the Patient Identifier Segment (PID), the Patient Visit Segment (PV1), and a repeating number of OBX segments for the lab results and later for vital signs and other physical exam data elements. There is a segment for procedures and a segment for visit diagnoses that are not included at this time.

Each of the following tables is a segment. The column headings include the sequence number of field position within the segment, the maximum length, the data type , whether required or not, whether repeating or not, the element name, and which fields must be populated for your use. I will explain data types for those fields you will use. The tables are not complete. I did not define any fields beyond those currently required.

MSH - Message Header

SEQ LEN DT OPT RP/# ELEMENT NAME Comment Site Content
1 1 ST R   Field Separator Filter bar ([BAR]) [BAR]
2 4 ST R   Encoding Characters -Component separator ˆ
-Sub-component separator ~
-Repetition separator \
-Escape character &
ˆ~\&
3 227 HD Ο   Sending Application    
4 227 HD Ο   Sending Facility   Create a table of sending facilities
5 227 HD Ο   Receiving Application    
6 227 HD Ο   Receiving Facility   Create a name for receiving
7 26 TS R   Date/Time Of Message CCYYMMDDHHMM 200803231435
8 40 ST Ο   Security    
9 15 MSG R   Message Type TypeˆTrigger CSUˆZ01
10 20 ST R   Message Control ID   You may want to create a numbering scheme 12345
11 3 PT R   Processing ID Production (P), Training (T) or Debug (D) P
12 60 VID R   Version ID   2.5

Example:

MSH[BAR]ˆ~\&[BAR][BAR]DukeHosp[BAR][BAR]VDC[BAR]200803231435[BAR][BAR]GENˆA05[BAR]12345[BAR][BAR]2.5

Notes:

  1. HD (Hierarchical Designator) is a unique name that identifies the system that is either the source or the receiver of the data. It is a user defined name.
  2. I suggest using a message type of CSU for unsolicited study data message and a trigger of Z01 for locally defined. If we need more than one message type of trigger event, we can define them.

PID - Patient Identification

SEQ LEN DT OPT RP/# ELEMENT NAME COMMENT SITE CONTENT
1 4 SI Ο   Set ID - PID Always 1
2 20 CX B   Patient ID   Medical Record Number
3 250 CX R Y Patient Identifier List    
4 20 CX B Y Alternate Patient ID - PID   Patient Control Number
5 250 XPN R Y Patient Name    
6 250 XPN Ο Y Mother's Maiden Name    
7 26 TS Ο   Date/Time of Birth   CCYYMMDD
8 1 IS Ο   Administrative Sex Gender M,F,U M, F, or U
9 250 XPN B Y Patient Alias    
10 250 CE Ο Y Race    
11 250 XAD Ο Y Patient Address   ˆˆˆˆZIP
12 4 IS B   County Code    
13 250 XTN Ο Y Phone Number - Home    
14 250 XTN Ο Y Phone Number - Business    
15 250 CE Ο   Primary Language    
16 250 CE Ο   Marital Status    
17 250 CE Ο   Religion    
18 250 CX Ο   Patient Account Number    
19 16 ST B   SSN Number - Patient   SSN
20 25 DLN B   Driver's License Number - Patient    
21 250 CX Ο Y Mother's Identifier    
22 250 CE Ο Y Ethnic Group    
23 250 ST Ο   Birth Place    
24 1 ID Ο   Multiple Birth Indicator    
25 2 NM Ο   Birth Order    
26 250 CE Ο Y Citizenship    
27 250 CE Ο   Veterans Military Status    
28 250 CE B   Nationality    
29 26 TS Ο   Patient Death Date and Time    
30 1 ID Ο   Patient Death Indicator    

EXAMPLE

PID[BAR]1[BAR]MRN[BAR][BAR]PCN[BAR][BAR][BAR]19350109[BAR]M[BAR][BAR]27712[BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR]999-99-9999

Notes

  1. The address data type is XAD for extended address. It is a structure in which the address is broken into sub-components. The separator is the ˆ. The Zip code falls into the 5 position, hence the leading ˆ above.

PV1 - Patient Visit

SEQ LEN DT OPT RP/# ELEMENT NAME COMMENT SITE CONTENT
1 4 SI Ο   Set ID - PV1   1
2 1 IS R   Patient Class    
3 80 PL Ο   Assigned Patient Location    
4 2 IS Ο   Admission Type    
5 250 CX Ο   Preadmit Number    
6 80 PL Ο   Prior Patient Location    
7 250 XCN Ο Y Attending Doctor   Medicare Provider Number
8 250 XCN Ο Y Referring Doctor    
9 250 XCN B Y Consulting Doctor    
10 3 IS Ο   Hospital Service    
11 80 PL Ο   Temporary Location    
12 2 IS Ο   Preadmit Test Indicator    
13 2 IS Ο   Re-admission Indicator    
14 6 IS Ο   Admit Source    
15 2 IS Ο Y Ambulatory Status    
16 2 IS Ο   VIP Indicator    
17 250 XCN Ο Y Admitting Doctor    
18 2 IS Ο   Patient Type    
19 250 CX Ο   Visit Number    
20 50 FC Ο Y Financial Class    
21 2 IS Ο   Charge Price Indicator    
22 2 IS Ο   Courtesy Code    
23 2 IS Ο   Credit Rating    
24 2 IS Ο Y Contract Code    
25 8 DT Ο Y Contract Effective Date    
26 12 NM Ο Y Contract Amount    
27 3 NM Ο Y Contract Period    
28 2 IS Ο   Interest Code    
29 4 IS Ο   Transfer to Bad Debt Code    
30 8 DT Ο   Transfer to Bad Debt Date    
31 10 IS Ο   Bad Debt Agency Code    
32 12 NM Ο   Bad Debt Transfer Amount    
33 12 NM Ο   Bad Debt Recovery Amount    
34 1 IS Ο   Delete Account Indicator    
35 8 DT Ο   Delete Account Date    
36 3 IS Ο   Discharge Disposition    
37 47 DLD Ο   Discharged to Location    
38 250 CE Ο   Dist Type    
39 2 IS Ο   Servicing Facility    
40 1 IS B   Bed Status    
41 2 IS Ο   Account Status    
42 80 PL Ο   Pending Location    
43 80 PL Ο   Prior Temporary Location    
44 26 TS Ο   Admit Date/Time   CCYYMMDD
45 26 TS Ο Y Discharge Date/Time   CCYYMMDD
46 12 NM Ο   Current Patient Balance    
47 12 NM Ο   Total Charges    
48 12 NM Ο   Total Adjustments    
49 12 NM Ο   Total Payments    
50 250 CX Ο   Alternate Visit ID    
51 1 IS Ο   Visit Indicator    
52 250 XCN B Y Other Healthcare Provider    

EXAMPLE

PV1[BAR]1[BAR][BAR][BAR][BAR][BAR]MPN[BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR][BAR]20080315[BAR]20080318

OBX – Observation/Result

SEQ LEN DT OPT ITEM# ELEMENT NAME COMMENT SITE CONTENT
1 4 SI Ο 00569 Set ID – OBX   Sequential numbers starting with 11
2 2 ID C 00570 Value Type   Result type
NM = numeric
ST = char string
CE = coded element
3 250 CE R 00571 Observation Identifier   LOINC code
4 20 ST C 00572 Observation Sub-ID    
5 9999 varies C 00573 Observation Value   Value of test
  g1            
6 250 CE Ο 00574 Units   You need to agree on what units will be used
7 60 ST Ο 00575 References Range   Low value – high value
8 5 IS Ο 00576 Abnormal Flags    
9 5 NM Ο 00577 Probability    
10 2 ID Ο 00578 Nature of Abnormal Test    
11 1 ID R 00579 Observation Result Status    
12 26 TS Ο 00580 Effective Date of Reference Range    
13 20 ST Ο 00581 User Defined Access Checks    
14 26 TS Ο 00582 Date/Time of the Observation    
15 250 CE Ο 00583 Producer's ID    
16 250 XCN Ο 00584 Responsible Observer    
17 250 CE Ο 00936 Observation Method    
18 22 EI Ο 01479 Equipment Instance Identifier    
19 26 TS Ο 01480 Date/Time of the Analysis    

EXAMPLE:

OBX[BAR]1[BAR]33509-1[BAR][BAR]11.1[BAR]G/DL[BAR](12.5-16.0)


Internet Citation: Templates for using HL7 v2.5 messages. Healthcare Cost and Utilization Project (HCUP). December 2010. Agency for Healthcare Research and Quality, Rockville, MD. www.hcup-us.ahrq.gov/datainnovations/clinicaldata/TemplatesforusingHL7v2.jsp.
Are you having problems viewing or printing pages on this website?
If you have comments, suggestions, and/or questions, please contact hcup@ahrq.gov.
Privacy Notice, Viewers & Players
Last modified 12/15/10