Contained Resources
By default, search results only include resources that are not contained in
other resources. However, chained parameters will be evaluated inside contained resources. The
client can use the _contained
parameter to include contained resources in the
search result.
To illustrate this, consider an Observation resource that has a contained patient resource.
{
"resourceType": "Observation",
"id": "test-observation",
"contained": [
{
"resourceType": "Patient",
"id": "contained-patient-test",
"name": [{
"family": "Taylor"
}]
}
],
"subject": { "reference": "#contained-patient-test" }
}
In this case, the search:
GET [base]/Observation?subject.name=Taylor&_contained=true
Will include patient resource as well in the response:
{
"resourceType": "Bundle",
"id": "fac7f392-6678-4f7a-b497-097e9eebf3db",
"meta": {
"lastUpdated": "2024-02-26T10:08:03.246+00:00"
},
"type": "searchset",
"total": 1,
"link": [ {
"relation": "self",
"url": "http://localhost:3003/oracle-fhir-server/fhir/Observation?_contained=true&subject.name=Taylor"
} ],
"entry": [ {
"fullUrl": "http://localhost:3003/oracle-fhir-server/fhir/Observation/152",
"resource": {
"resourceType": "Observation",
"id": "152",
"meta": {
"versionId": "1",
"lastUpdated": "2024-02-26T10:07:46.522+00:00",
"source": "#bDxRJtAqeE5Avf9s"
},
"contained": [ {
"resourceType": "Patient",
"id": "contained-patient-test",
"name": [ {
"family": "Taylor"
} ]
} ],
"subject": {
"reference": "#contained-patient-test"
}
},
"search": {
"mode": "match"
}
} ]
}
To enable the _contained
parameter on Oracle HDR FHIR server, set the
below property to true in the hdr_fhir.yaml file. By default this property is set to
false. If this is set to true all the contained resources will be indexed while
persisting the resources.
enable_index_contained_resource: true
Parent topic: Modify Search Results