Receive the MDM^T02 message (Medical Document Management — Original Document Notification with Content) via your MLLP listener; T02 indicates the document content is embedded in the message as opposed to T01 which is a pointer-only notification
Parse the EVN segment for event date/time and TXA segment for document metadata: document type code in TXA-2, activity date/time in TXA-4, originating provider in TXA-9, document status in TXA-17 (AU for authenticated, DI for dictated), and unique document ID in TXA-12
Extract the OBX segments that follow the TXA segment; for embedded documents OBX-2 will typically be 'ED' (encapsulated data) or 'TX' (text); for ED type, OBX-5 contains the document encoded as base64 (or plain text for TX) along with the encoding type and MIME type
Decode the document content from base64 if applicable; the document may be a CDA (Clinical Document Architecture) XML document, plain text, or a PDF depending on the sending system
Correlate the document to the patient using the PID segment in the MDM message and the visit using PV1 if present; store the document with appropriate indexing by document type, date, and provider
Send an ACK and, if your system requires document management workflow, track authentication status using TXA-17 — documents in dictated or transcribed status may need to be updated via subsequent MDM messages as they move through the authentication workflow
Known gotchas
MDM message handling is often overlooked in interface implementations but is a primary mechanism for delivering transcribed notes, operative reports, and discharge summaries from transcription systems and EHRs
TXA-2 document type codes vary by sending system and may be local codes rather than standard HL7 table values; maintain a mapping from the sender's local document type codes to your internal document categories
Large documents (lengthy operative reports, multi-page CDAs) embedded in OBX-5 as base64 can produce very large HL7v2 messages that exceed default MLLP buffer sizes on some interface engines; configure maximum message size settings appropriately
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp