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.
The general FHIR principle that resources MUST be self contained still applies. FHIR Messaging should not be used to send highly coupled complex interactions, the message SHOULD be easily converted into resource based interactions. A FHIR Message bundle is not a storage based concept, it should be expected that all the resources in the Bundle can be processed individually. Should this be required consider using FHIR Documents
FHIR Messaging should only be used for defined interactions/messages, ad-hoc interactions/collections should use transactions
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).
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 |
Bundle | I | Bundle | There are no (further) constraints on this element Element IdBundle Contains a collection of resources DefinitionA container for a collection of resources.
| |
identifier | S Σ | 1..1 | Identifier | There are no (further) constraints on this element Element IdBundle.identifier Persistent identifier for the bundle DefinitionA persistent identifier for the bundle that won't change as a bundle is copied from server to server. Persistent identity generally only matters for batches of type Document, Message, and Collection. It would not normally be populated for search and history results and servers ignore Bundle.identifier when processing batches and transactions. For Documents the .identifier SHALL be populated such that the .identifier is globally unique.
|
use | Σ ?! | 0..1 | codeBinding | There are no (further) constraints on this element Element IdBundle.identifier.use usual | official | temp | secondary | old (If known) DefinitionThe purpose of this identifier. Allows the appropriate identifier for a particular context of use to be selected from among a set of identifiers. Applications can assume that an identifier is permanent unless it explicitly says that it is temporary. Identifies the purpose for this identifier, if known . IdentifierUse (required)Constraints
|
type | Σ | 0..1 | CodeableConceptBinding | There are no (further) constraints on this element Element IdBundle.identifier.type Description of identifier DefinitionA coded type for the identifier that can be used to determine which identifier to use for a specific purpose. Allows users to make use of identifiers when the identifier system is not known. This element deals only with general categories of identifiers. It SHOULD not be used for codes that correspond 1..1 with the Identifier.system. Some identifiers may fall into multiple categories due to common usage. Where the system is known, a type is unnecessary because the type is always part of the system definition. However systems often need to handle identifiers where the system is not known. There is not a 1:1 relationship between type and system, since many different systems have the same type. A coded type for an identifier that can be used to determine which identifier to use for a specific purpose. Identifier Type Codes (extensible)Constraints
|
system | S Σ | 1..1 | uri | There are no (further) constraints on this element Element IdBundle.identifier.system The namespace for the identifier value DefinitionEstablishes the namespace for the value - that is, a URL that describes a set values that are unique. There are many sets of identifiers. To perform matching of two identifiers, we need to know what set we're dealing with. The system identifies a particular set of unique identifiers. Identifier.system is always case sensitive.
General http://www.acme.com/identifiers/patient Mappings
|
value | S Σ | 1..1 | string | There are no (further) constraints on this element Element IdBundle.identifier.value The value that is unique DefinitionThe portion of the identifier typically relevant to the user and which is unique within the context of the system. If the value is a full URI, then the system SHALL be urn:ietf:rfc:3986. The value's primary purpose is computational mapping. As a result, it may be normalized for comparison purposes (e.g. removing non-significant whitespace, dashes, etc.) A value formatted for human display can be conveyed using the Rendered Value extension. Identifier.value is to be treated as case sensitive unless knowledge of the Identifier.system allows the processer to be confident that non-case-sensitive processing is safe.
General 123456 Mappings
|
period | Σ I | 0..1 | Period | There are no (further) constraints on this element Element IdBundle.identifier.period Time period when id is/was valid for use DefinitionTime period during which identifier is/was valid for use. A Period specifies a range of time; the context of use will specify whether the entire range applies (e.g. "the patient was an inpatient of the hospital for this time range") or one value from the range applies (e.g. "give to the patient between these two times"). Period is not used for a duration (a measure of elapsed time). See Duration.
|
assigner | Σ I | 0..1 | Reference(Organization) | There are no (further) constraints on this element Element IdBundle.identifier.assigner Organization that issued id (may be just text) DefinitionOrganization that issued/manages the identifier. The Identifier.assigner may omit the .reference element and only contain a .display element reflecting the name or other textual information about the assigning organization.
|
type | S Σ | 1..1 | codeBindingFixed Value | Element IdBundle.type document | message | transaction | transaction-response | batch | batch-response | history | searchset | collection DefinitionIndicates the purpose of this bundle - how it is intended to be used. It's possible to use a bundle for other purposes (e.g. a document can be accepted as a transaction). This is primarily defined so that there can be specific rules for some of the bundle types. Indicates the purpose of a bundle - how it is intended to be used. BundleType (required)Constraints
message
|
timestamp | S Σ | 1..1 | instant | There are no (further) constraints on this element Element IdBundle.timestamp When the bundle was assembled DefinitionThe date/time that the bundle was assembled - i.e. when the resources were placed in the bundle. For many bundles, the timestamp is equal to .meta.lastUpdated, because they are not stored (e.g. search results). When a bundle is placed in a persistent store, .meta.lastUpdated will be usually be changed by the server. When the bundle is a message, a middleware agent altering the message (even if not stored) SHOULD update .meta.lastUpdated. .timestamp is used to track the original time of the Bundle, and SHOULD be populated. Usage:
The timestamp value should be greater than the lastUpdated and other timestamps in the resources in the bundle, and it should be equal or earlier than the .meta.lastUpdated on the Bundle itself.
|
total | Σ I | 0..1 | unsignedInt | There are no (further) constraints on this element Element IdBundle.total If search, the total number of matches DefinitionIf a set of search matches, this is the total number of entries of type 'match' across all pages in the search. It does not include search.mode = 'include' or 'outcome' entries and it does not provide a count of the number of entries in the Bundle. Only used if the bundle is a search result set. The total does not include resources such as OperationOutcome and included resources, only the total number of matching resources.
|
link | Σ | 0..0 | BackboneElement | There are no (further) constraints on this element Element IdBundle.link Links related to this Bundle DefinitionA series of links that provide context to this bundle. Both Bundle.link and Bundle.entry.link are defined to support providing additional context when Bundles are used (e.g. HATEOAS). Bundle.entry.link corresponds to links found in the HTTP header if the resource in the entry was read directly. This specification defines some specific uses of Bundle.link for searching and paging, but no specific uses for Bundle.entry.link, and no defined function in a transaction - the meaning is implementation specific.
|
entry | S Σ I | 1..* | BackboneElement | Element IdBundle.entry Entry in the bundle - will have a resource or information DefinitionAn entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only). Unordered, Open, by resource.resourceType(Value) Constraints
|
(All Slices) | There are no (further) constraints on this element | |||
link | Σ | 0..0 | see (link) | There are no (further) constraints on this element Element IdBundle.entry.link Links related to this entry DefinitionA series of links that provide context to this entry. |
fullUrl | Σ | 1..1 | uri | There are no (further) constraints on this element Element IdBundle.entry.fullUrl URI for resource (Absolute URL server address or URI for UUID/OID) DefinitionThe Absolute URL for the resource. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that:
fullUrl might not be unique in the context of a resource. Note that since FHIR resources do not need to be served through the FHIR API, the fullURL might be a URN or an absolute URL that does not end with the logical id of the resource (Resource.id). However, but if the fullUrl does look like a RESTful server URL (e.g. meets the regex, then the 'id' portion of the fullUrl SHALL end with the Resource.id. Note that the fullUrl is not the same as the canonical URL - it's an absolute url for an endpoint serving the resource (these will happen to have the same value on the canonical server for the resource with the canonical URL).
|
resource | Σ | 0..1 | Resource | There are no (further) constraints on this element Element IdBundle.entry.resource A resource in the bundle DefinitionThe Resource for the entry. The purpose/meaning of the resource is determined by the Bundle.type.
|
search | Σ I | 0..1 | BackboneElement | There are no (further) constraints on this element Element IdBundle.entry.search Search related information DefinitionInformation about the search process that lead to the creation of this entry.
|
mode | Σ | 0..1 | codeBinding | There are no (further) constraints on this element Element IdBundle.entry.search.mode match | include | outcome - why this is in the result set DefinitionWhy this entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process. There is only one mode. In some corner cases, a resource may be included because it is both a match and an include. In these circumstances, 'match' takes precedence. Why an entry is in the result set - whether it's included as a match or because of an _include requirement, or to convey information or warning information about the search process. SearchEntryMode (required)Constraints
|
score | Σ | 0..1 | decimal | There are no (further) constraints on this element Element IdBundle.entry.search.score Search ranking (between 0 and 1) DefinitionWhen searching, the server's search ranking score for the entry. Servers are not required to return a ranking score. 1 is most relevant, and 0 is least relevant. Often, search results are sorted by score, but the client may specify a different sort order. See Patient Match for the EMPI search which relates to this element.
|
request | Σ I | 0..1 | BackboneElement | There are no (further) constraints on this element Element IdBundle.entry.request Additional execution information (transaction/batch/history) DefinitionAdditional information about how this entry should be processed as part of a transaction or batch. For history, it shows how the entry was processed to create the version contained in the entry.
|
method | Σ | 1..1 | codeBinding | There are no (further) constraints on this element Element IdBundle.entry.request.method GET | HEAD | POST | PUT | DELETE | PATCH DefinitionIn a transaction or batch, this is the HTTP action to be executed for this entry. In a history bundle, this indicates the HTTP action that occurred. Note that FHIR strings SHALL NOT exceed 1MB in size HTTP verbs (in the HTTP command line). See [HTTP rfc](https://tools.ietf.org/html/rfc7231) for details. HTTPVerb (required)Constraints
|
url | Σ | 1..1 | uri | There are no (further) constraints on this element Element IdBundle.entry.request.url URL for HTTP equivalent of this entry DefinitionThe URL for this entry, relative to the root (the address to which the request is posted). E.g. for a Patient Create, the method would be "POST" and the URL would be "Patient". For a Patient Update, the method would be PUT and the URL would be "Patient/[id]".
|
ifNoneMatch | Σ | 0..1 | string | There are no (further) constraints on this element Element IdBundle.entry.request.ifNoneMatch For managing cache currency DefinitionIf the ETag values match, return a 304 Not Modified status. See the API documentation for "Conditional Read". Note that FHIR strings SHALL NOT exceed 1MB in size
|
ifModifiedSince | Σ | 0..1 | instant | There are no (further) constraints on this element Element IdBundle.entry.request.ifModifiedSince For managing cache currency DefinitionOnly perform the operation if the last updated date matches. See the API documentation for "Conditional Read". Note: This is intended for where precisely observed times are required, typically system logs etc., and not human-reported times - for them, see date and dateTime (which can be as precise as instant, but is not required to be) below. Time zone is always required
|
ifMatch | Σ | 0..1 | string | There are no (further) constraints on this element Element IdBundle.entry.request.ifMatch For managing update contention DefinitionOnly perform the operation if the Etag value matches. For more information, see the API section "Managing Resource Contention". Note that FHIR strings SHALL NOT exceed 1MB in size
|
ifNoneExist | Σ | 0..1 | string | There are no (further) constraints on this element Element IdBundle.entry.request.ifNoneExist For conditional creates DefinitionInstruct the server not to perform the create if a specified resource already exists. For further information, see the API documentation for "Conditional Create". This is just the query portion of the URL - what follows the "?" (not including the "?"). Note that FHIR strings SHALL NOT exceed 1MB in size
|
response | Σ I | 0..1 | BackboneElement | There are no (further) constraints on this element Element IdBundle.entry.response Results of execution (transaction/batch/history) DefinitionIndicates the results of processing the corresponding 'request' entry in the batch or transaction being responded to or what the results of an operation where when returning history.
|
status | Σ | 1..1 | string | There are no (further) constraints on this element Element IdBundle.entry.response.status Status response code (text optional) DefinitionThe status code returned by processing this entry. The status SHALL start with a 3 digit HTTP code (e.g. 404) and may contain the standard HTTP description associated with the status code. Note that FHIR strings SHALL NOT exceed 1MB in size
|
location | Σ | 0..1 | uri | There are no (further) constraints on this element Element IdBundle.entry.response.location The location (if the operation returns a location) DefinitionThe location header created by processing this operation, populated if the operation returns a location. see http://en.wikipedia.org/wiki/Uniform_resource_identifier
|
etag | Σ | 0..1 | string | There are no (further) constraints on this element Element IdBundle.entry.response.etag The Etag for the resource (if relevant) DefinitionThe Etag for the resource, if the operation for the entry produced a versioned resource (see Resource Metadata and Versioning and Managing Resource Contention). Etags match the Resource.meta.versionId. The ETag has to match the version id in the header if a resource is included.
|
lastModified | Σ | 0..1 | instant | There are no (further) constraints on this element Element IdBundle.entry.response.lastModified Server's date time modified DefinitionThe date/time that the resource was modified on the server. This has to match the same time in the meta header (meta.lastUpdated) if a resource is included.
|
outcome | Σ | 0..1 | Resource | There are no (further) constraints on this element Element IdBundle.entry.response.outcome OperationOutcome with hints and warnings (for batch/transaction) DefinitionAn OperationOutcome containing hints and warnings produced as part of processing this entry in a batch or transaction. For a POST/PUT operation, this is the equivalent outcome that would be returned for prefer = operationoutcome - except that the resource is always returned whether or not the outcome is returned. This outcome is not used for error responses in batch/transaction, only for hints and warnings. In a batch operation, the error will be in Bundle.entry.response, and for transaction, there will be a single OperationOutcome instead of a bundle in the case of an error.
|
messageHeader | S Σ I | 1..* | BackboneElement | There are no (further) constraints on this element Element IdBundle.entry:messageHeader Entry in the bundle - will have a resource or information DefinitionAn entry in a bundle resource - will either contain a resource or information about a resource (transactions and history only).
|
link | Σ | 0..* | see (link) | There are no (further) constraints on this element Element IdBundle.entry:messageHeader.link Links related to this entry DefinitionA series of links that provide context to this entry. |
fullUrl | Σ | 0..1 | uri | There are no (further) constraints on this element Element IdBundle.entry:messageHeader.fullUrl URI for resource (Absolute URL server address or URI for UUID/OID) DefinitionThe Absolute URL for the resource. The fullUrl SHALL NOT disagree with the id in the resource - i.e. if the fullUrl is not a urn:uuid, the URL shall be version-independent URL consistent with the Resource.id. The fullUrl is a version independent reference to the resource. The fullUrl element SHALL have a value except that:
fullUrl might not be unique in the context of a resource. Note that since FHIR resources do not need to be served through the FHIR API, the fullURL might be a URN or an absolute URL that does not end with the logical id of the resource (Resource.id). However, but if the fullUrl does look like a RESTful server URL (e.g. meets the regex, then the 'id' portion of the fullUrl SHALL end with the Resource.id. Note that the fullUrl is not the same as the canonical URL - it's an absolute url for an endpoint serving the resource (these will happen to have the same value on the canonical server for the resource with the canonical URL).
|
resource | S Σ I | 0..1 | NHSDigitalMessageHeader | Element IdBundle.entry:messageHeader.resource A resource that describes a message that is exchanged between systems DefinitionThe header for a FHIR Message exchange that is either requesting or responding to an action. The reference(s) that are the subject of the action as well as other information related to the action are typically transmitted in a bundle in which the MessageHeader resource instance is the first resource in the bundle. Messaging middleware systems are expected to use this This profile is not tied to any specific transport/API requirement or clinical requirement. Intermediaries are not expected to perform detailed routing on clinical content.
Some clinical information will be required for routing purposes and this will be held within Systems involved in NHSDigital/UKCore messaging are expected to support this profile only, extensions or derived profiles are permitted but they may only have limited (internal) scope and will not be supported outside of this scope (e.g. externally). This resource SHOULD NOT be profiled to further define the contents of the resources and FHIR MessageDefinition MUST be used instead. identifiers and message timingsFHIR messages have two identifiers: the messageIdentifier of the Message ( The Systems may chose to map X-Request-ID header to the MessageHeader can hold previous and extra messageId's in the {{link:https://fhir.nhs.uk/StructureDefinition/Extension-MessageHeader-messageId}} Local Part/Addressing (sender and/or destination.receiver)When exchanging messages between organisations, local references SHOULD NOT be used for This concept is similar to email addresses In the example below, the destination is a clinic (A99968) which part of NHS Trust (RBA). Note also the destination endpoint is for the NHS Trust, who will route the message as required.
example - Prescription, Pharmacy known{{render:nominatedPharmacy}} In the example below, the prescriber Taunton and Somerset Foundation Trust (RBA), is sending a message to The Simple Pharmacy (VNE51). The This message is to be sent via the Electronic Prescription Service, the http address of EPS is held in
EPS will now send this message to the pharmacy. This message is collected by the pharmacy using MESH and so the
example - Prescription, Pharmacy not known{{render:noNominatedPharmacy}} In this example the destination is not known and the message is sent to NHS Digital (X26).
From (source and sender) and To (destination)The From is contained in both the Messages may be sent over multiple transmission legs (i.e. the first leg uses http and the second MESH). The contents of elements SHOULD reflect the current leg only.
Endpoints MUST point to valid endpoint uri's on each leg of the messages journey, they may not refer to inaccessible endpoints on other legs. See also the destination section below.
|
search | Σ I | 0..0 | BackboneElement | There are no (further) constraints on this element Element IdBundle.entry:messageHeader.search Search related information DefinitionInformation about the search process that lead to the creation of this entry.
|
request | Σ I | 0..0 | BackboneElement | There are no (further) constraints on this element Element IdBundle.entry:messageHeader.request Additional execution information (transaction/batch/history) DefinitionAdditional information about how this entry should be processed as part of a transaction or batch. For history, it shows how the entry was processed to create the version contained in the entry.
|
response | Σ I | 0..0 | BackboneElement | There are no (further) constraints on this element Element IdBundle.entry:messageHeader.response Results of execution (transaction/batch/history) DefinitionIndicates the results of processing the corresponding 'request' entry in the batch or transaction being responded to or what the results of an operation where when returning history.
|
signature | Σ | 0..1 | Signature | There are no (further) constraints on this element Element IdBundle.signature Digital Signature DefinitionDigital Signature - base64 encoded. XML-DSig or a JWT. A Signature holds an electronic representation of a signature and its supporting context in a FHIR accessible form. The signature may either be a cryptographic type (XML DigSig or a JWS), which is able to provide non-repudiation proof, or it may be a graphical image that represents a signature or a signature process. This element allows capturing signatures on documents, messages, transactions or even search responses, to support content-authentication, non-repudiation or other business cases. This is primarily relevant where the bundle may travel through multiple hops or via other mechanisms where HTTPS non-repudiation is insufficient. The signature could be created by the "author" of the bundle or by the originating device. Requirements around inclusion of a signature, verification of signatures and treatment of signed/non-signed bundles is implementation-environment specific.
|
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/dispense-notification
{ "resourceType": "MessageDefinition", "id": "bf729ea8-280b-4109-b2f5-02ce8e51d870", "url": "https://fhir.nhs.uk/MessageDefinition/dispense-notification", "identifier": [ { "system": "https://tools.ietf.org/html/rfc4122", "value": "bf729ea8-280b-4109-b2f5-02ce8e51d870" } ], "version": "1.0.0", "name": "NHSDigitalDispenseNotification", "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" }, "description": "Notification of dispensed medication", "category": "notification", "focus": [ { "code": "MedicationDispense", "profile": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-MedicationDispense-Message", "min": 1, "max": "*" } ] }
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 focus 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).