Search with related resources
A client can add related resources to a search result using (rev)include FHIR parameters and with Aidbox parameter. In ORM frameworks, such feature is sometimes called an "associations eager loading". This technique can save extra roundtrips from the client to the server and potential N+1 problem.
Example
This example demonstrates how _include, _revinclude, and _with search parameters work. You may want to get encounters with patients (each encounter refers to patient):
Create Patient
Create Encounter
Search with _include
Search with _with
Or you can request patients and return all Encounter resources that refer to them (by a reverse reference):
Aidbox can do the same in a compact way:
Distinguish between matched and related resources
An entry.search.mode field has a value match
if the resource is in the search set because it matched the search criteria and has a value include
if another resource refers to it.
Last updated