Referencing FHIR Resources
The method by which other FHIR resources, e.g. Medication
or Patient
, can be done ine several ways:
There are three options;
- Identifier or CodeableConcept Reference
- Resource Reference to a resource within the FHIR Bundle or a remote server
- Resource Reference to a “contained” resource within the resource
Identifier and CodeableConcept Reference
Using references by identifier is the preferred option in FHIR Messaging (and EPS). This is focused on using codes from either NHS Data Dictionary or SNOMED CT.
It is recommended that the reference.display
is populated with appropriate text as per the guidance within this document.
<MedicationRequest xmlns="http://hl7.org/fhir"> <subject> <identifier> <system value="https://fhir.nhs.uk/Id/nhs-number" /> <value value="2245386903" /> </identifier> <!-- where 2245386903 is the NHS number for Joe Bloggs held as the 'id' --> <display value="Joe Bloggs" /> </subject> <medicationCodeableConcept> <coding> <system value="http://snomed.info/sct" /> <code value="323465006" /> <display value="Flucloxacillin 500mg capsules" /> </coding> </medicationCodeableConcept> </MedicationRequest>
Resource Reference to a resource
FHIR Message Bundles should be self contained and they should not require an external FHIR Server to process the message. In these cases referenced resources should be contained in the Bundle. It is suggested to use UUID references to navigate the resources in the Bundle, mainly to distinguish between resources within the Bundle and externally referenced resources.
<Bundle xmlns="http://hl7.org/fhir"> <entry> <fullUrl value="urn:uuid:5fe0dde7-2cdc-43c1-b346-11dda63b51d2" /> <resource> <Patient> <id value="2245386903" /> <!-- other patient details for Joe Bloggs --> </Patient> </resource> </entry> <entry> <fullUrl value="urn:uuid:3e2097b7-3b28-4954-bded-d6af82a10c40" /> <resource> <Medication> <id value="87652004" /> <code> <coding> <system value="http://snomed.info/sct" /> <code value="87652004" /> <display value="Atenolol" /> </coding> </code> <!-- other medication details for Atenolol --> </Medication> </resource> </entry> <entry> <resource> <MedicationRequest> <subject> <reference value="urn:uuid:5fe0dde7-2cdc-43c1-b346-11dda63b51d2" /> <display value="Joe Bloggs" /> </subject> <medicationReference> <reference value="urn:uuid:3e2097b7-3b28-4954-bded-d6af82a10c40" /> <display value="Atenolol" /> </medicationReference> <!-- other medication request details --> </MedicationRequest> </resource> </entry> </Bundle>
Within EPS the preference is to move to identifer references as this provides the key information a consumer requires. This also avoids large messages exchanging a considerable of reference data. The exception to this is likely to be the Patient
resource which will normally be included in the FHIR Message Bundle.
FHIR RESTful API's may make references to resources held on FHIR Servers.
<MedicationRequest> <subject> <reference value="https://fhir.midyorks.nhs.uk/Patient/2245386903" /> <display value="Joe Bloggs" /> </subject> <medicationReference> <reference value="https://fhir.midyorks.nhs.uk/Medication/87652004" /> <display value="Atenolol" /> </medicationReference> <!-- other medication request details --> </MedicationRequest>
Not the use of baseUrl
/ resource
/ resource.id
. Local references, i.e. referencing a resource on the same server, may omit the baseUrl
.
<MedicationRequest> <subject> <reference value="Patient/2245386903" /> <display value="Joe Bloggs" /> </subject> <medicationReference> <reference value="Medication/87652004" /> <display value="Atenolol" /> </medicationReference> <!-- other medication request details --> </MedicationRequest>
Resource reference to contained resource
This SHOULD NOT be used as an alternative to FHIR RESTful API using resources. This should only be used when the resource is not complete, for example only the name of the patient or medication is known. This is not used in EPS.
The use of a contained FHIR resource should be the last option considered. The use of the #
character.
<MedicationRequest xmlns="http://hl7.org/fhir"> <contained> <Patient> <id value="#1"/> <!-- patient details for Joe Bloggs --> </Patient> </contained> <contained> <Medication> <id value="#2"/> <!-- medication details for Atenolol --> </Medication> </contained> <subject> <reference value="#1"/> <display value="Joe Bloggs"/> </subject> <medicationReference> <reference value="#2"/> <display value="Atenolol"/> </medicationReference> </MedicationRequest>
Identifier and Resource References
The two approaches to referencing can be used together. E.g.
An identifier reference such as
<MedicationRequest xmlns="http://hl7.org/fhir"> <subject> <identifier> <system value="https://fhir.nhs.uk/Id/nhs-number" /> <value value="2245386903" /> </identifier> <display value="Joe Bloggs" /> </subject> </MedicationRequest>
can be combined with a resource reference
<MedicationRequest> <subject> <reference value="https://fhir.midyorks.nhs.uk/Patient/2245386903" /> <display value="Joe Bloggs" /> </subject> </MedicationRequest>
Resulting in this example
<MedicationRequest> <subject> <reference value="https://fhir.midyorks.nhs.uk/Patient/2245386903" /> <identifier> <system value="https://fhir.nhs.uk/Id/nhs-number" /> <value value="2245386903" /> </identifier> <display value="Joe Bloggs" /> </subject> </MedicationRequest>
In this example a receiving system has a choice.
If NHS Number and patient name is sufficient they can process the MedicationRequest without any further API calls or have to resolve the reference within the Bundle.
If they need more Patient details, they can either follow the reference
https://fhir.midyorks.nhs.uk/Patient/2245386903
, or use the NHS Number to query a local such as PAS/MPI or Patient Demographic Service(PDS).