NHS Digital FHIR Implementation Guide (Retired - 2.1.50)

This guidance is under active development by NHS Digital and content may be added or updated on a regular basis.

FHIR Messaging

This is the FHIR version of traditional messaging. It differs from FHIR RESTful in that all the resources are sent to the recipient in one interaction. This is particularly useful between organisations where all the FHIR resources can be sent in one interaction.

E.g. in the diagram below a prescription consists of one Patient resource and two MedicationRequests. Using FHIR Messaging all the resources are sent within one FHIR Message Bundle. Doing the same with FHIR RESTful would require at least three transactions (possibly more depending on the handling of the Patient resource).

rest vrs fhir 1

FHIR Message reduces the number of transactions and decouples the sending organisation from local rules. All the resources are handled in a single package and the receiving organisation can handle them according to local procedures.

FHIR Messaging is very similar to the messaging used in HL7 v2 and HL7 v3 (/ITK), hence the term traditional messaging.

FHIR Bundle (type=message)

Profile url
https://fhir.nhs.uk/StructureDefinition/NHSDigital-Bundle-FHIRMessage

idΣ0..1string
metaΣ0..1Meta
implicitRulesΣ ?!0..1uri
language0..1codeBinding
id0..1string
extensionI0..*Extension
useΣ ?!0..1codeBinding
typeΣ0..1CodeableConceptBinding
systemΣ1..1uri
valueΣ1..1string
periodΣ I0..1Period
assignerΣ I0..1Reference(Organization)
typeΣ1..1codeBindingFixed Value
timestampΣ1..1instant
totalΣ I0..1unsignedInt
id0..1string
extensionI0..*Extension
modifierExtensionΣ ?! I0..*Extension
fullUrlΣ1..1uri
resourceΣ0..1Resource
id0..1string
extensionI0..*Extension
modifierExtensionΣ ?! I0..*Extension
modeΣ0..1codeBinding
scoreΣ0..1decimal
id0..1string
extensionI0..*Extension
modifierExtensionΣ ?! I0..*Extension
methodΣ1..1codeBinding
urlΣ1..1uri
ifNoneMatchΣ0..1string
ifModifiedSinceΣ0..1instant
ifMatchΣ0..1string
ifNoneExistΣ0..1string
id0..1string
extensionI0..*Extension
modifierExtensionΣ ?! I0..*Extension
statusΣ1..1string
locationΣ0..1uri
etagΣ0..1string
lastModifiedΣ0..1instant
outcomeΣ0..1Resource
id0..1string
extensionI0..*Extension
modifierExtensionΣ ?! I0..*Extension
fullUrlΣ0..1uri
resourceΣ I0..1NHSDigitalMessageHeader
signatureΣ0..1Signature

This message consists of a Bundle identified by the type "message", with the first resource in the bundle being a MessageHeader resource. The MessageHeader resource has a code - the message event - that identifies the nature of the request message, and it also carries additional request metadata. The other resources in the bundle depend on the type of the request.

For example a dispense-notification message will be a FHIR Bundle consisting of

  • one MessageHeader resource with an eventCoding dispense-notification
  • one to four MedicationDispense resources
  • one (optional) Patient resource.

Example dispense-notifications can be found in the NHS Digital Medicines Guide Examples

These Bundles are send to a $process-message operation, e.g.

POST baseUrl/$process-message

In the example above we stated rules for the dispense-notification message, these will be contained in a FHIR MessageDefinition and the message definition for this is https://fhir.nhs.uk/MessageDefinition/pharmacy-dispense

{
    "resourceType": "MessageDefinition",
    "id": "pharmacy-dispense",
    "url": "https://fhir.nhs.uk/MessageDefinition/pharmacy-dispense",
    "identifier":  [
        {
            "system": "https://tools.ietf.org/html/rfc4122",
            "value": "bf729ea8-280b-4109-b2f5-02ce8e51d870"
        }
    ],
    "version": "1.0.0",
    "title": "Pharmacy/Treatment Dispense",
    "status": "active",
    "date": "2020-10-02",
    "eventCoding": {
        "system": "https://fhir.nhs.uk/CodeSystem/message-event",
        "code": "dispense-notification",
        "display": "Dispense Notification"
    },
    "category": "notification",
    "focus":  [
        {
            "code": "MedicationDispense",
            "profile": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-MedicationDispense",
            "min": 1,
            "max": "4"
        }
    ]
}

fhir-message-bundle

Some of the key points are:

  • element eventCoding This is the code that identifies the MessageDefinition and will match the eventingCode in the dispense-notification FHIR Message
  • element focus This lists the principal resources; in the example this is FHIR MedicationDispense resources which follows the NHSDigital-MedicationDispense profile. One and up to four resources can be supplied.
  • Patient resource is not in the focus section. The rule that a Patient resource is required is contained in the FHIR MedicationDispense profile.
  • MessageHeader resource is not in the focuse section. It is mandatory in all FHIR Messages.

The FHIR MessageHeader contains the message metadata only and is designed to support message handling without having to process the full message. The use of FHIR MessageHeader with NHSDigital API's is discussed in NHSDigital-MessageHeader. Note this FHIR R4 NHSDigital-MessageHeader is designed to handle all message types and contains rules from both previous MessageHeaders used in Transfer of Care (point to point messages) and National Event Messaging System (pub/sub messages).

back to top