Skip to content
  • Tuesday, 14 July 2026
  • 2:15 am
  • Follow Us
Wattman
  • Intake form
  • Master patient index
  • Dermatology
  • Services
  • EHR software
  • Home
  • Reference vs Contained: When to Embed and When to Link
Reference corner

Reference corner

Whenever a colleague asks which fields a Practitioner resource actually needs, I point them at the R4 resource atlas I maintain here.

FHIR Server & API Solutions
  • Profiles and Slicing at a Glance
  • Reference vs Contained: When to Embed and When to Link
  • Top 5 MPI Engines for Payer-Driven Patient Reconciliation in 2026
  • The Ten FHIR Resources You Should Learn First
  • Navigating FHIR R4 Resources When You Know DomainResource But Not Much Else
R4 Resource Atlas

Reference vs Contained: When to Embed and When to Link

Jasmine Ward Jul 13, 2026 0
Editorial illustration in cyberpunk-neon style depicting a cyberpunk-neon side-by-side of Reference between resources vs a contained child resource

Editorial illustration in cyberpunk-neon style depicting a cyberpunk-neon side-by-side of Reference between resources vs a contained child resource

FHIR R4 gives two ways to connect one resource to another. Reference points at a resource by URL or logical id. Contained embeds a full resource inside the parent. Both are valid, and choosing between them is a small design decision with a large downstream effect. The site's R4 resource atlas marks each element's reference type explicitly. For the wider FHIR framing, the FHIR comparison index has related pieces.

Reference: The Default

A Reference points at another resource by:

  • Relative URL Patient/123
  • Absolute URL https://server.example.org/Patient/123
  • Logical identifier via Reference.identifier when the id is unknown
  • URN in a transaction Bundle via urn:uuid:...

Reference is the default because it preserves resource identity, keeps payloads small, and lets the referenced resource live and change on its own. A Practitioner referenced from a hundred Observations is one Practitioner, not a hundred copies. That is the interoperability model FHIR is built around.

Contained: The Escape Hatch

Contained embeds a full resource inside the parent's contained array. The contained resource has no independent existence — it lives only inside its parent. Use contained when:

  • The child has no identity outside the parent context
  • The child is generated on the fly and not persisted independently
  • The receiver has no meaningful way to look up the child by id

A Medication resource contained inside a MedicationRequest is a common example, when the medication is a one-off compound with no independent catalog entry.

Do Not Contain Reusable Entities

Patients, Practitioners, and Organizations should almost never be contained. They have identity, they get referenced from many places, and containing them fragments that identity across parent resources. A Patient contained inside an Encounter is the same person as the Patient contained inside a different Encounter — but from the FHIR resource-identity perspective, they are two distinct records. That is a data-quality problem waiting to bite.

The Reference Type Contract

Every Reference element declares which resource types it accepts. Observation.subject accepts Patient, Group, Device, or Location. Sending a Reference to Practitioner in Observation.subject fails validation. That declaration is on the resource definition, and clients that ignore it end up with payloads that pass smoke tests but fail on a strict validator. For the way to read those declarations, reading a FHIR resource definition the way developers read a class covers the mechanic.

Reference.identifier: The Fallback

When the server does not know the logical id of the referenced resource yet, use Reference.identifier instead of Reference.reference. That fallback is what allows a client to send an Encounter with an external MRN before the Patient has been created on this server. It is expected, common, and often overlooked.

The Transaction Bundle Twist

Inside a transaction Bundle, references between entries can use urn:uuid:.... The server rewrites those URNs to real ids atomically at commit. That trick only works in transactions, not in batches, and it is how a client sends coupled entries without a prior create round-trip.

What This Buys You

Choosing Reference over contained keeps the resource graph clean, preserves identity, and lets receivers look up related resources on their own schedule. Choosing contained keeps the payload self-contained when the child has no external identity. Both have their place. The atlas surfaces the reference type per element to make the check fast.

For the base pattern, navigating FHIR R4 resources when you know DomainResource but not much else is the entry. For the ten resources you meet most, the ten FHIR resources you should learn first covers them.

Cyberpunk-neon diagram comparing a Reference link between two resources on the left with a contained embed inside a parent resource on the right, drawn with neon cyan accents on a dark grid

Sources

  • HL7 canonical R4 references chapter covering Reference and - HL7 canonical R4 references chapter covering Reference and contained
FHIR Validator & Compliance
Editorial illustration in cyberpunk-neon style depicting a cyberpunk-neon base Patient resource with US Core profile applied and sliced identifiers
R4 Resource Atlas
Profiles and Slicing at a Glance
Jasmine Ward Jul 13, 2026
Editorial illustration in cyberpunk-neon style depicting a cyberpunk-neon ten-tile grid of the most common R4 resource types with cyan neon strokes
R4 Resource Atlas
The Ten FHIR Resources You Should Learn First
Jasmine Ward Jul 12, 2026
Editorial illustration in cyberpunk-neon style depicting a cyberpunk-neon FHIR R4 inheritance tree fanning from Resource and DomainResource into module-scoped resources
R4 Resource Atlas
Navigating FHIR R4 Resources When You Know DomainResource But Not Much Else
Jasmine Ward Jul 12, 2026
Medical Forms & FHIR SDC
Editorial illustration in cyberpunk-neon style depicting a cyberpunk-neon base Patient resource with US Core profile applied and sliced identifiers
R4 Resource Atlas
Profiles and Slicing at a Glance
Jasmine Ward Jul 13, 2026
Editorial illustration in cyberpunk-neon style depicting a cyberpunk-neon side-by-side of Reference between resources vs a contained child resource
R4 Resource Atlas
Reference vs Contained: When to Embed and When to Link
Jasmine Ward Jul 13, 2026
Top 5 MPI Engines for Payer-Driven Patient Reconciliation in 2026
Master patient index
Top 5 MPI Engines for Payer-Driven Patient Reconciliation in 2026
Jasmine Ward Jul 12, 2026
Editorial illustration in cyberpunk-neon style depicting a cyberpunk-neon ten-tile grid of the most common R4 resource types with cyan neon strokes
R4 Resource Atlas
The Ten FHIR Resources You Should Learn First
Jasmine Ward Jul 12, 2026