MessageHeader — Messaging routing header
The FHIR equivalent of HL7 v2's MSH segment. Always the first entry of a Bundle of
type message, it carries sender, receiver, event and routing data.
Purpose
FHIR messaging is one of the four interoperability paradigms (alongside REST,
documents, services). It consists of carrying a Bundle of type message
containing a business event — typically clinical or administrative — from a sending
system to a receiver, with asynchronous acknowledgment.
MessageHeader is required to be the first entry of that Bundle. It carries the routing semantics: event code, source, destination, focus (subject), reason, and optionally the asynchronous response to a previous message.
Key fields
| Field | Type | Cardinality | Role |
|---|---|---|---|
event[x] | Coding | canonical(MessageDefinition) | 1..1 | Mandatory. Event code (MSH-9 equivalent). |
destination | BackboneElement[] | 0..* | Recipient(s). |
destination.endpointUrl | url | 0..1 | FHIR URL of the recipient. |
destination.receiver | Reference(Organization | Device | Practitioner | PractitionerRole) | 0..1 | Receiver Organization/Device. |
sender | Reference(Practitioner | PractitionerRole | Organization) | 0..1 | Logical sender. |
author | Reference(Practitioner | PractitionerRole | Device | Organization) | 0..1 | Author (clinician driving the event). |
source | BackboneElement | 1..1 | Mandatory. Technical source system. |
source.endpointUrl | url | 1..1 | Technical URL of the sender. |
responsible | Reference(Practitioner | PractitionerRole | Organization) | 0..1 | Legally responsible for the content. |
reason | CodeableConcept | 0..1 | Reason of the message (e.g. admit, transfer). |
response | BackboneElement | 0..1 | For response messages: ack of the original. |
response.identifier | Identifier | 1..1 | ID of acknowledged message. |
response.code | code | 1..1 | ok | transient-error | fatal-error. |
response.details | Reference(OperationOutcome) | 0..1 | Error detail. |
focus | Reference(Any)[] | 0..* | Resources concerned by the event (Patient, Encounter...). |
definition | canonical(MessageDefinition) | 0..1 | MessageDefinition describing this event. |
FHIR messaging pattern
The typical FHIR messaging exchange:
- System A builds a Bundle
type=messagewith MessageHeader as the first entry and clinical resources following. - A POSTs the Bundle to
[base]/$process-messageon receiver B. - B answers either:
- Synchronous: an immediate message-response Bundle with MessageHeader
response.code=ok. - Asynchronous: 202 Accepted, then later B POSTs a response Bundle to A's
source.endpointUrl.
- Synchronous: an immediate message-response Bundle with MessageHeader
JSON example
A MessageHeader notifying a patient admission (admin-notify) with an
Encounter in focus:
{
"resourceType": "MessageHeader",
"id": "example",
"eventCoding": {
"system": "http://example.org/fhir/message-events",
"code": "admin-notify"
},
"destination": [{
"name": "PMS",
"endpointUrl": "https://pms.example.org/fhir/messaging",
"receiver": { "reference": "Organization/pms-org" }
}],
"sender": { "reference": "Organization/hospital-1" },
"author": { "reference": "Practitioner/dr-jones" },
"source": {
"name": "HIS",
"software": "Acme HIS v3.4",
"version": "3.4.1",
"endpointUrl": "https://hospital-1.example.org/fhir/messaging"
},
"responsible": { "reference": "Organization/hospital-1" },
"reason": {
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/message-reasons-encounter",
"code": "admit"
}]
},
"focus": [{ "reference": "Encounter/example" }]
} Common pitfalls
- MessageHeader not in first position — a Bundle
type=messagemust have MessageHeader asentry[0].resource. Otherwise rejected. - No
source.endpointUrl— without a technical return URL, asynchronous acknowledgment is impossible. - Untyped
event[x]— the event code must be typed by a Coding or canonical MessageDefinition. - Unresolvable
focus— every Reference infocusmust be present in the same Bundle. - Mixing REST and messaging — the messaging pattern is asynchronous and event-driven. Don't use it for routine CRUD: prefer REST.
Related resources
- Bundle — mandatory
type=messageenvelope. - MessageDefinition — describes the event and expected content.
- OperationOutcome — error detail in
response.details. - HL7 v2 ADT^A01 — legacy pipe-delimited equivalent.