Open
Description
Describe the bug
We are using hapi fhir as a facade. Pagination of search endpoints is performed by using SimpleBundleProvider
which generated the right links for the current and next pages. However, once we get to page 3 (and above), the previous link always points to page 1 instead of page 2 (currentPage - 1).
To Reproduce
Steps to reproduce the behavior:
- Create a Resource Provider search endpoint eg PatientResourceProvider
// List<IBaseResource> resourceList -> could be empty for reproducing this issue
SimpleBundleProvider bundleProvider = new SimpleBundleProvider(resourceList);
/**
* meta is a DTO for the backend service providing search data
* Offset and counterPerPage are from @Count and @Offset respectively
* Could be hardcoded to reproduce this issue
* /
bundleProvider.setCurrentPageOffset(meta.getOffset());
bundleProvider.setCurrentPageSize(meta.getCountPerPage());
bundleProvider.setSize(meta.getTotalCount()); // you can use a fixed size of 10
return bundleProvider;
- Set
currentPageSize = 1
,currentPageOffset = 3
,totalCount (ie size) = 10
corresponding to...?_count=1&_offset=3
- Make a request to the search endpoint of the resource provider
- You will get
"link": [
{
"relation": "self",
"url": "...?_count=1&_offset=3" // correct
},
{
"relation": "next",
"url": "...?_count=1&_offset=4" // correct
},
{
"relation": "previous",
"url": "...?_count=1&_offset=0" // wrong
}
Expected behavior
The previous link url should look like "url": "...?_count=1&_offset=2"
ie _offset should be current page offset minus count per page
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- HAPI FHIR Version: 6.2.5
- OS: N/A
- Browser: N/A
Additional context
If this is a bug, we could raise a fix for it.
Metadata
Metadata
Assignees
Labels
No labels