fhirlab
The glue that holds FHIR together· 9 min read

References — the hyperlinks of healthcare

Why `Patient/893082` matters more than you think.

The hyperlink, applied to healthcare

The web works because pages don't copy each other — they link. A Wikipedia article about Marie Curie doesn't paste the full text of "radioactivity" inside itself; it points at another page with an <a href>. Update the target page once and every link in the world reflects the change.

FHIR takes the same bet with clinical data. An Observation for a body-temperature reading does not carry a copy of the patient's name, date of birth, or address. It carries a pointer: "the subject of this reading is Patient/893082." Fix a typo in the patient's name tomorrow, and every one of their past observations, encounters, medication requests, and lab reports automatically tells the correct story. That tiny design choice — link, don't embed — is what makes FHIR data stay consistent at scale.

Three ways to write a reference

A reference is a string that tells the server where the target lives. FHIR R4 allows three flavours.

Relative reference

The one you'll see 95% of the time. Just the resource type and id, relative to the server's base URL.

"subject": { "reference": "Patient/893082" }

Absolute reference

A full URL. Useful when the target lives on a different server — for example, a hospital Observation that points at a patient held by a national identity service.

"subject": { "reference": "https://nhi.example.org/fhir/Patient/893082" }

Contained reference

A hash-prefixed id like "#p1" points at a resource bundled inside the same parent in a contained array. Use it sparingly — for anonymous helper resources that have no independent life (a one-off Practitioner referenced only by this one DiagnosticReport). Most real systems avoid contained resources; prefer relative references to things the server actually stores.

Reference is an object, not a string

A common surprise for newcomers: the subject field above is not the string "Patient/893082". It is an object whose reference field holds that string. That's because FHIR's Reference datatype has four useful sub-fields, and you'll meet all of them in real data:

"subject": {
  "reference": "Patient/893082",
  "type": "Patient",
  "display": "Marie Curie (b. 1867)",
  "identifier": {
    "system": "https://hospital.example.org/mrn",
    "value": "MRN-42"
  }
}
  • reference — the URL. Relative, absolute, or contained. This is the only field most servers resolve.
  • type — a hint about the target resource type. Redundant when reference starts with Patient/, but useful when the pointer is an identifier instead of a URL.
  • display — a human-readable label so a viewer can show "Marie Curie" without a second HTTP round-trip. Never trust it for logic — it's a cached snapshot and can go stale.
  • identifier — a business identifier (MRN, national ID) to use when you don't yet have a server-assigned id. Common in bundles posted before the server has assigned ids, and in cross-system integrations.

Why this matters

Three big wins fall out of the link-don't-embed design. Consistency: the patient's legal name lives in exactly one record, so it can't drift between the lab result and the discharge summary. Deduplication: ten years of observations for one patient reference the same Patient row, not ten thousand copies. Auditability: when someone updates a demographic, there's one history to audit, not a scavenger hunt across every resource that ever mentioned the person.

Contrast this with HL7v2, where every message re-states the patient's name, date of birth, gender, MRN, address inline. If the ward clerk fixed a typo in the EMR this morning, the lab system downstream might not learn about it for weeks — and even then, only for new messages. FHIR's references eliminate that entire category of silent drift.

Chained search — the payoff

References would be a quiet convenience if that were the end of the story. The reason they're a feature is that FHIR's search grammar lets you reach through a reference into the target resource's fields, in a single HTTP call.

The query below reads: "find Observations whose subject is a Patient whose name contains Curie." The colon narrows the reference to a specific target type (subject:Patient) and the dot chains into one of that target type's search parameters (.name).

GET /Observation?subject:Patient.name=Curie
Chained search: filter Observations by a field on their referenced Patient. Results are from the whole public sandbox, not just resources you created.
GET
https://hapi.fhir.org/baseR4

Chaining is not limited to one hop — you can chain encounter:Encounter.subject:Patient.name=Curie if the server supports it — but one hop handles the overwhelming majority of real queries.

_include — pulling the referenced resource back

Chained search filters by a reference. A different need: "give me the Observations and their Patients in one Bundle so my UI doesn't have to fire a second request for every row." That's _include. The syntax is _include=ResourceType:searchParam.

GET /Observation?_include=Observation:subject
Return each Observation together with the Patient it references. The response Bundle will contain both resource types.
GET
https://hapi.fhir.org/baseR4

Flip the response to the JSONPath tab and try $.entry[*].resource.resourceType. You'll see a mix of Observation and Patient entries — the Patients came along for the ride. Each included entry carries search.mode = "include" so a client can tell primary matches apart from supporting data.

What just happened

  • A FHIR Reference is an object with up to four fields; the reference URL is the one that does the work.
  • Relative, absolute, and contained are the three legal forms — you'll write relative references almost every time.
  • Chained search (field:TargetType.param=value) filters the current resource by a property of what it points at.
  • _include ships the pointed-at resources back in the same Bundle, so one round-trip is enough.

The container holding those mixed results — Observations and Patients riding in the same envelope — is a Bundle, and it deserves a lesson of its own. That's what you'll meet next.