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
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)
Add _revinclude=[ReferencingType]:[searchParam] to the search query, for example GET [base]/Patient?_id=123&_revinclude=Provenance:target
The server returns a searchset Bundle; primary results have entry.search.mode=match and reverse-included resources have entry.search.mode=include
Filter entries by search.mode=include and further by resourceType to extract the reverse-included resources
Cross-reference each included resource's reference field (e.g., Provenance.target) back to the matched primary resource by id to establish the relationship
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
_revinclude is the reverse of _include: _include follows outbound references from matched resources, _revinclude finds resources that point TO matched resources — confusing the two is a common error
Not all search parameters support _revinclude; verify the parameter name (e.g., Provenance:target, not Provenance:subject) against the CapabilityStatement revInclude list
Reverse-included resources are not paginated separately; they are appended to the page they are discovered on, so the total count in Bundle.total reflects only primary match resources, not includes
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?