$reference
$reference(resource?) -> stringCompact type signature
<o-:s>If resource is omitted, the current context value is used.
Documentation
Builds a deterministic urn:uuid: reference string from a FHIR resource object.
The same resource identity produces the same UUID, which makes this helper useful when you need stable internal references during Bundle assembly. This matches the automatic fullUrl created for that entry in the Bundle. If the input is not a FHIR resource, $reference() throws an error.
Examples
Create a urn:uuid: reference from a FHIR resource
Input
Example input
JSON
{
"resourceType": "Patient",
"id": "pat-0001",
"gender": "female",
"identifier": [
{
"system": "urn:examplecare:member-id",
"value": "mbr-3001"
}
],
"name": [
{
"use": "official",
"family": "Reed",
"given": [
"Avery"
]
}
],
"managingOrganization": {
"reference": "Organization/org-0001",
"display": "ExampleCare Clinic"
}
}
Expression
$reference($)
Result
"urn:uuid:b7f6323f-7ab3-504e-93cc-330411da9ed5"