Problem with previous link url when using offset-based pagination

53 views
Skip to first unread message

Yusuf Daniju

unread,
Nov 7, 2022, 10:50:12 AM11/7/22
to HAPI FHIR
Hello all,

We are working on a project that uses a hapi fhir facade option. The facade gets all the data it needs through a RESTful API. Therefore, we do not implement any paging provider as there is no caching layer for search results. 

While attempting to paginate the search endpoint, we used SimpleBundleProvider by setting the currentPageOffset, size and currentPageSize. This generated the right links for the next page. However, once I get to the third page, I get the following link urls. 

{
  "type": "searchset",
  "total": 21,
  "link": [
    {
      "relation": "self",
      "url": ".../Patient?_count=5&_offset=10"
    },
    {
      "relation": "next",
      "url": ".../Patient?_count=5&_offset=15"
    },
    {
      "relation": "previous",
      "url": ".../Patient?_count=5&_offset=0"
    }
  ],
}

The the link that points to the previous page always return an offset of zero. I'll like to know if this an expected behaviour or am I missing something?

Note:
We are setting the offset and page size as follows (in Kotlin)

val bundle = SimpleBundleProvider(resourcesList)
bundle.currentPageOffset = offset
bundle.currentPageSize = countPerPage
bundle.setSize(totalCount)

Reply all
Reply to author
Forward
0 new messages