FHIR Chat · Pagination in Hapi · implementers

Stream: implementers

Topic: Pagination in Hapi


view this post on Zulip Aditya Joshi (Mar 27 2019 at 15:06):

How to modify pagination implemented in HAPI?
@James Agnew please help.

When executed below query-
GET http://hapi.fhir.org/baseDstu3/Patient?given=Smith&_pretty=true

got below as next set of records-

GET http://hapi.fhir.org/baseDstu3?_getpages=2a636711-3850-4bee-92fe-db61b8eb2cea&_getpagesoffset=20&_count=20&_pretty=true&_bundletype=searchset

I believe to implement above pagination, HAPI FHIR server should have all the records avaialble at first hand. Also, _getpages and _getpagesoffset are specific parameters defined by HAPI to implement pagination, these are not standard FHIR search parameters, right?

In my use case, EMR not providing all the records in one go. It provides 10 records at a time and a session id (some unique id at EMR side). Client can use this session id to query EMR specific API to get another 10 records. Now same has to be done using FHIR server. So, the first requirement is to able to pass on session id to client. This id should be part of FHIR JSON (Bundle returning first set of records from EMR). Question is where to put this id in Bundle?

I am not able to understand how to replace HAPI pagination url with my own. for example-

replacing below

http://hapi.fhir.org/baseDstu3?_getpages=2a636711-3850-4bee-92fe-db61b8eb2cea&_getpagesoffset=20&_count=20&_pretty=true&_bundletype=searchset

with

http://hapi.fhir.org/baseDstu3/Patient?sessionId=123444

Is it possible in HAPI and if yes how to do that?

view this post on Zulip James Agnew (Mar 27 2019 at 15:34):

This should work fine.

What you need to do is create your own implementation of the IPagingProvider interface and have your search methods return a custom IBundleProvider implementation.

Your bundle provider would incude the page ID for the next page of results, and the IPagingProvider would actually look up that next page. HAPI will then take care of the rest, including creating the URL you show above.

view this post on Zulip Aditya Joshi (Mar 28 2019 at 09:09):

Thanks @James Agnew it helped a lot.


Last updated: Apr 12 2022 at 19:14 UTC