The Path
Module 3 · Message types·10 min
Documents: MDM and embedded PDF
How a whole report travels inside a message, encoded in base64.
A polysomnography report is not just three numbers. It is a multi-page document with charts, tables and the doctor’s signature. To get it into the patient record in one piece, HL7 v2 offers the MDM family: Medical Document Management.
Here is Marie Dubois’s PDF report, signed on Tuesday, June 30 and sent by the sleep lab to the patient record.
The sleep lab sends Marie Dubois’s signed report. The PDF travels in OBX-5, base64-encoded. The string is deliberately shortened: a real PDF runs to tens of thousands of characters.
A message in three layers
An MDM reads like this:
MSH,EVN,PID,PV1: the usual context. Which message, which event, which patient, which visit.TXA: the document’s ID card. Its type, author, number and status.OBX: the document’s content. One or more.
Same logic as an ORU: a header, then OBXs. Except here the header describes a document, not a test.
The events: announce, carry, correct
The event (in MSH-9 and EVN-1) says what is happening to the document. They often come in pairs: the odd one announces, the next one announces and carries the content.
| Event | What happens |
|---|---|
T01 |
a new document exists (notification only, no OBX) |
T02 |
a new document exists, here it is |
T03 / T04 |
its status changes (without / with content) |
T05 / T06 |
an addendum is added: a new document, linked to the original (without / with content) |
T07 / T08 |
it was edited before being made available (without / with content) |
T09 / T10 |
it is replaced by another one, which gets a new number (without / with content) |
T11 |
it is canceled |
The standard reserves T11 for a document that has not yet been made available to clinicians. Once a doctor could have read it, you replace it rather than erase it.
TXA: the document’s ID card
TXA has more than twenty fields. These do the work:
| Field | Name | In our example |
|---|---|---|
TXA-2 |
Document type | PSG |
TXA-3 |
Content presentation | AP, application data (binary) |
TXA-4 |
Activity date/time | June 30, 8:55 am |
TXA-5 |
Primary author | 1234^MARTIN^Thomas |
TXA-12 |
Unique document number | DOC-2026-0042 |
TXA-14 / TXA-15 |
Order numbers | the PSG order |
TXA-17 |
Completion status | LA, legally authenticated (signed) |
TXA-19 |
Availability | AV, available for patient care |
TXA-2 uses a site-defined table (0270). HL7 suggests a few values, such as DS for a discharge summary or CN for a consultation. There is no code for a polysomnography, so the Leleux Clinic added PSG.
TXA-12 matters most for what comes next. A T11 arriving later points to the document by this number. An addendum (T06) or a replacement (T10) gets its own number and quotes this one in TXA-13, the parent document number.
OBX with type ED: the PDF inside the message
When OBX-2 is ED (Encapsulated Data), OBX-5 is no longer a single value. It splits into five components:
| Component | Role | Example |
|---|---|---|
| 1 | source application | empty |
| 2 | type of data | AP |
| 3 | subtype | PDF |
| 4 | encoding | Base64 |
| 5 | the data | JVBERi0xLjcK and the rest |
Click OBX-5 in the message at the top and spot these five pieces.
Why base64? A PDF is a binary file. Its bytes can hold any character, including | or ^, which would blow up the message parsing. Base64 turns every three bytes into four characters taken from a safe alphabet: letters, digits, +, / and =. None of them is an HL7 delimiter.
A handy reflex: a base64 string starting with JVBERi0 is a PDF. Those are the characters “%PDF-” encoded.
The subtype is not a closed list: table 0291 points to MIME types. Check your partner’s specification for the value it expects, most often PDF.
The alternative: RP, the pointer
Sometimes the document stays on its server and the message only carries an address. That is the RP type (Reference Pointer): a pointer, the application that holds it, the type and the subtype.
Instead of the whole PDF, the lab sends a pointer to the document stored on its server.
The message is light, but the receiver must be able to reach that server, with the right permissions, for as long as the record is kept. ED makes the record self-contained. RP makes it depend on another system.
Watch out for reserved characters: a web address often contains an & (in its query parameters), which is also the subcomponent separator. It has to be escaped as \T\, or the receiver cuts the URL short. The lesson on delimiters and escaping covers the mechanism.
And in FHIR?
The document becomes a DocumentReference resource. Its content.attachment holds either the base64 PDF in data or an address in url, with contentType set to application/pdf. The same ED or RP choice, one to one.
Check your understanding
1 of 5What is the difference between MDM^T01 and MDM^T02?
+50 XPPass the quiz (4 correct answers) to complete the lesson.
Reviewed and checked on 27 September 2026