Paging for _include and _revinclude Searches
When _include or _revinclude search results exceed the Bundle entry limit, SAP Health Data Services for FHIR adds a retrieval link to each Bundle entry so that clients can access all related included resources.
When a paged search includes _include or _revinclude resources, the total number of primary and included resources for a page can exceed the maximum number of entries allowed in the Bundle response. As a result, not all related _include or _revinclude resources can be returned in the same page.
In such cases, for each primary resource in the Bundle, SAP Health Data Services for FHIR returns a retrieval link in Bundle.entry[x].link that clients can use to retrieve all related included resources. This link is returned even if some of the related resources are already present in the current page.
This approach enables clients to retrieve the complete set of related resources for each primary resource without aggregating included resources across multiple pages, while providing consistent navigation to all related resources.
Example
Request:
GET https://api.eu10.health-data.cloud.sap/instance123/Patient?_include=Patient:general-practitioner:Practitioner
Response:
{
"resourceType": "Bundle",
"id": "bundle-001",
"type": "searchset",
"total": 1,
"entry": [
{
"link": [
{
"relation": "self",
"url": "https://api.eu10.health-data.cloud.sap/instance123/fhir/Patient?_id=patient-123&_include=Patient:general-practitioner:Practitioner"
},
{
"relation": "related",
"url": "https://api.eu10.health-data.cloud.sap/instance123/fhir/Patient?_id=patient-123&_include=Patient:general-practitioner:Practitioner&_skipRelated=10"
}
],
"resource": {
"resourceType": "Patient",
"id": "patient-123",
"name": [
{
"family": "Smith",
"given": [
"John"
]
}
],
"generalPractitioner": [
{
"reference": "Practitioner/pract-101"
},
{
"reference": "Practitioner/pract-102"
},
{
"reference": "Practitioner/pract-103"
}
]
},
"search": {
"mode": "match"
}
},
{
"resource": {
"resourceType": "Practitioner",
"id": "pract-101",
"name": [
{
"family": "Wilson",
"given": [
"Emily"
]
}
]
},
"search": {
"mode": "include"
}
}
]
}
Explanation:
-
The Patient is the primary search result (search.mode = "match").
-
Only one of the referenced Practitioner resources (pract-101) is included in this Bundle response. This happens when the Bundle entry limit is reached.
-
The "self" link identifies the request that produced the current entry.
-
The "related" link lets the client retrieve the remaining included Practitioner resources (such as pract-102 and pract-103) using the _skipRelated parameter.
