Skip to content

Implement pagination for FHIR Observation REST API end point #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
s1monj opened this issue Mar 21, 2025 · 3 comments
Closed

Implement pagination for FHIR Observation REST API end point #38

s1monj opened this issue Mar 21, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@s1monj
Copy link
Collaborator

s1monj commented Mar 21, 2025

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:

@s1monj s1monj added the enhancement New feature or request label Mar 21, 2025
@s1monj s1monj moved this to In Progress in jupyterhealth-exchange Mar 21, 2025
@s1monj s1monj moved this from In Progress to Todo in jupyterhealth-exchange Mar 21, 2025
@travis-sauer-oltech travis-sauer-oltech moved this from Todo to In Progress in jupyterhealth-exchange Mar 25, 2025
@s1monj
Copy link
Collaborator Author

s1monj commented Apr 3, 2025

@travis-sauer-oltech I should have been more clear - it appears this change has altered the Observations Admin API ❌ (in addition to the Observation FHIR API ✅ )

  • This is the format/shape of data we're expecting from the Admin API response:
Image
  • But instead we are getting a FHIR response the same as the /fhir/observation endpoint
Image
  • Can you please revert the Observation Admin API to the original format/shape so this ticket only effects the FHIR API

@travis-sauer-oltech travis-sauer-oltech moved this from In Progress to Done in jupyterhealth-exchange Apr 19, 2025
@travis-sauer-oltech
Copy link
Collaborator

@s1monj -

Refactored PRs: #57, #60, and #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants