Skip to content

Implement pagination for FHIR Observation REST API end point #38

Closed
@s1monj

Description

@s1monj

Background

  • The JHE server should be able to support a large number of Observations
  • Therefore it needs to support filtering and pagination options that are executed at the DB level (ie LIMIT and OFFSET etc)
  • FHIR specifies the search param _count for the page size but does not specify a parameter for the page number (see https://www.hl7.org/fhir/search.html#table)
  • Various servers have their own params
Image
  • We will use _page
  • We also need to return the total number of results as bundle.total but we'll leave this for another ticket

TBD

  1. Use Postman to create >30 Observations for testing - update the ID to use a random string (using Postman {{$randomPassword}} or similar so you can click the SEND button repeatedly without having to change the payload each time
  2. Accept the parameter _count so that GET /fhir/r5/Observation?_count=10 displays only the first 10 results by adding LIMIT 10 to the end of the raw DB query
  3. Accept the parameter _page so that GET /fhir/r5/Observation?_count=10&_page=2 displays results 11-20 by adding OFFSET (page-1)*10)
  4. Lastly, add the link property to the response Bundle with self, previous and next as per FHIR spec - see example below.
// GET /fhir/r5/Observation?_count=1&_page=2
{
    "resourceType": "Bundle",
    "type": "searchset",
    "link": [ {
      "relation": "self",
      "url": "http://localhost:8000/Observation?_count=1&_page=2"
    }, {
      "relation": "previous",
      "url": "http://localhost:8000/Observation?_count=1&_page=1"
    },
   {
      "relation": "next",
      "url": "http://localhost:8000/Observation?_count=1&_page=3"
  } ],
    "entry": [
        {
            "resource": {
                "resourceType": "Observation",
                ...

Note:

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions