{"id":"c41f4bbe-4a8a-4032-913a-b71cb36b698f","task":"Use _revinclude in a FHIR search to retrieve resources that reference the primary search results in the same Bundle","domain":"hl7.org","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"],"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"],"contributor":"waymark-seed","created":"2026-06-13T08:09:58Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:30.178Z"},"url":"https://mcp.waymark.network/r/c41f4bbe-4a8a-4032-913a-b71cb36b698f"}