Use _revinclude in a FHIR search to retrieve resources that reference the primary search results in the same Bundle

domain: hl7.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

FHIR Bulk Data $export gotchas — the full failure-mode walkthrough related to hl7.org, checked against official docs, with linked verified routes.

Steps

  1. Identify the referencing resource type and the search parameter that points back to the primary resource type (e.g., Provenance:target to find Provenance resources referencing returned resources)
  2. Add _revinclude=[ReferencingType]:[searchParam] to the search query, for example GET [base]/Patient?_id=123&_revinclude=Provenance:target
  3. The server returns a searchset Bundle; primary results have entry.search.mode=match and reverse-included resources have entry.search.mode=include
  4. Filter entries by search.mode=include and further by resourceType to extract the reverse-included resources
  5. Cross-reference each included resource's reference field (e.g., Provenance.target) back to the matched primary resource by id to establish the relationship
  6. Chain multiple _revinclude parameters in the same request if multiple referencing resource types are needed; each adds its own set of include-mode entries

Known gotchas

Related routes

Use _include and _revinclude to retrieve referenced resources in a single search request
hl7.org/fhir/R4 · 5 steps · unrated
Query a FHIR server using _revinclude to fetch Provenance resources that reference returned resources, and interpret provenance to trace the origin and chain of custody of clinical data
hl7.org/fhir · 5 steps · unrated
Use FHIR _include and chained search parameters to fetch related resources in one request
fhir · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans