FHIR Chat · Pages example · implementers

Stream: implementers

Topic: Pages example


view this post on Zulip Roberth Blum (Mar 04 2020 at 07:57):

Anyone have a good example, or a link to an example, of using pages to retrieve a very large data set via a FHIR REST API?

view this post on Zulip Frank Oemig (Mar 04 2020 at 10:57):

What do you mean with 'pages'?

view this post on Zulip Abel Stolz (Mar 04 2020 at 11:03):

FHIR searches return large results in sets of pages (search parameter 'count'). This is like web site which displays search results in sets of 10, 25, 100, whatever you specify. The first result set (first page) contains a link to the next page with the next search results.

view this post on Zulip Roberth Blum (Mar 04 2020 at 13:25):

Thanks for your responses.
I have this example in XML https://www.hl7.org/fhir/http.html#paging. As I understand I must define what the first/last, previous/next page is in the bundle Meta. However, where can I find a more real life example? And how do I implement this in json?

view this post on Zulip Jose Costa Teixeira (Mar 04 2020 at 13:29):

https://chat.fhir.org/#narrow/stream/179166-implementers/topic/result.20pagination.20-.20_count.20.2F.20offset.3F

view this post on Zulip Jose Costa Teixeira (Mar 04 2020 at 13:30):

you do a search with the parameter ?_count=x, where x is the amount of results you want to return

view this post on Zulip Jose Costa Teixeira (Mar 04 2020 at 13:31):

in the search result - depending on which server - you get the links to the next set

view this post on Zulip Jose Costa Teixeira (Mar 04 2020 at 13:31):

http://test.fhir.org/r4/Patient/?_count=5

view this post on Zulip Jose Costa Teixeira (Mar 04 2020 at 13:31):

is that what you are asking @Roberth Blum ?

view this post on Zulip Roberth Blum (Mar 04 2020 at 13:52):

Yes, kind of close. Just something I am missing is http://test.fhir.org/r4/Patient/?_count=1 where do I find the link to the next set? I seem to not be able to find it.

view this post on Zulip Roberth Blum (Mar 04 2020 at 14:02):

OK, i think I understand, If I build the API I need to store the search and let the requester offset with 1.
E.g. http://test.fhir.org/r4/Patient?_format=text/xhtml&search-id=aba873f1-7731-4600-ba67-0259d3efd6&search-offset=2&_count=1

I was under the impression that there is a possibility to not have to store the searches as Search ID.

As the example provided in https://www.hl7.org/fhir/http.html#paging

view this post on Zulip Josh Mandel (Mar 04 2020 at 14:07):

If you are building the server API, please note that you do not need to support an explicit offset parameter. You can internally track searches in any way you like and the only interface that you need to expose is to include a next page link and a previous page link on each page you return. These may embed parameters that are totally opaque to the client, rather than a transparent parameter like offset (or indeed they may point to totally distinct paths).

view this post on Zulip Roberth Blum (Mar 04 2020 at 14:14):

Josh Mandel said:

If you are building the server API, please note that you do not need to support an explicit offset parameter. You can internally track searches in any way you like and the only interface that you need to expose is to include a next page link and a previous page link on each page you return. These may embed parameters that are totally opaque to the client, rather than a transparent parameter like offset (or indeed they may point to totally distinct paths).

Yes exactly this is what I would like to achieve. This is what I am searching for an example for in json for inspiration, to just send the "next" URL in the response.

view this post on Zulip Josh Mandel (Mar 04 2020 at 16:55):

OK -- you can try http://hapi.fhir.org/baseR4/Patient?_count=1 for example and you'll see:

  "link": [
    {
      "relation": "self",
      "url": "http://hapi.fhir.org/baseR4/Patient?_count=1"
    },
    {
      "relation": "next",
      "url": "http://hapi.fhir.org/baseR4?_getpages=bb1387b5-45ec-4263-868a-aeb173a6bf14&_getpagesoffset=1&_count=1&_pretty=true&_bundletype=searchset"
    }
  ],

view this post on Zulip Josh Mandel (Mar 04 2020 at 16:56):

If you follow the next link (which, note, is totally opaque, and doens't look at all like the self link), you'll see examples of next and previous:

  "link": [
    {
      "relation": "self",
      "url": "http://hapi.fhir.org/baseR4?_getpages=bb1387b5-45ec-4263-868a-aeb173a6bf14&_getpagesoffset=1&_count=1&_pretty=true&_bundletype=searchset"
    },
    {
      "relation": "next",
      "url": "http://hapi.fhir.org/baseR4?_getpages=bb1387b5-45ec-4263-868a-aeb173a6bf14&_getpagesoffset=2&_count=1&_pretty=true&_bundletype=searchset"
    },
    {
      "relation": "previous",
      "url": "http://hapi.fhir.org/baseR4?_getpages=bb1387b5-45ec-4263-868a-aeb173a6bf14&_getpagesoffset=0&_count=1&_pretty=true&_bundletype=searchset"
    }
  ],

view this post on Zulip Lloyd McKenzie (Mar 04 2020 at 17:31):

What the next and previous links look like will vary from server to server. There's no expectation for the mechanisms to be consistent. From a client perspective it's an opaque URL you invoke to navigate from page to page.

view this post on Zulip Roberth Blum (Mar 05 2020 at 06:50):

Thanks, very helpful! I will test an adaption of this and see how it fit our need.


Last updated: Apr 12 2022 at 19:14 UTC