Skip to content
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

Support _skip parameter for pagination #2454

Open
almostchristian opened this issue Jan 26, 2022 · 4 comments
Open

Support _skip parameter for pagination #2454

almostchristian opened this issue Jan 26, 2022 · 4 comments
Labels
Question Issue is a question?

Comments

@almostchristian
Copy link

almostchristian commented Jan 26, 2022

Paging with FHIR server currently uses a continuation token which is not meant to be directly manipulated by the client. This limits traditional paging GUIs other than an infinite scrolling list.

Ideally it should look something like below:

first page:  Patient
second page: Patient?_skip=10
third page:  Patient?_skip=20

I created a POC to enable this for the SQL Server provider. Please have a look.
https://github.com/almostchristian/fhir-server/tree/fhir/paging

The change involves converting the usages of TOP into OFFSET

  SELECT DISTINCT T1, Sid1, 1 AS IsMatch, 0 AS IsPartial 
  FROM cte1
  ORDER BY Sid1 ASC
  OFFSET (@p4) ROWS
  FETCH NEXT @p5 ROWS ONLY

A lot of change had to be done to support sorting, which is still tricky. Since sorting can happen in two phases, the skip parameter in the POC resets when the second phase starts. I denote the second phase with a hyphen in the skip parameter,

The search urls when sorting is involved can look like below. In here, repurposed ct as the skip parameter.

1st page: Patient?_sort=family&_count=2
2nd page: Patient?_sort=family&_count=2&ct=2
3rd page: Patient?_sort=family&_count=2&ct=-1
4th page: Patient?_sort=family&_count=2&ct=-3

Since I am currently working with a fork of FHIR server, I plan to go introduce this to our implementation. The sorting issue is a bummer, but I don't think this can be avoided without a big redesign. I'd like to hear feedback on this implementation. The E2E integration tests all pass, but I'm not sure if there is some edge cases not covered in the integration tests that could break this.

In terms of performance, the generated query plan is the same with the original, but the OFFSET version seems to be heavier compared to the TOP version outside of the first page, but I'd need to do proper testing on a large db.

AB#105830

@almostchristian almostchristian added the Question Issue is a question? label Jan 26, 2022
@EXPEkesheth EXPEkesheth added the Review Tag for PM/Dev Review label Jul 31, 2023
@EXPEkesheth
Copy link
Collaborator

@almostchristian - Apologizes on delayed response. We would be interested to review.

@almostchristian
Copy link
Author

@EXPEkesheth I created a draft PR here #3536

@EXPEkesheth
Copy link
Collaborator

Thanks @almostchristian - have scheduled it in our queue for review. We will respond back once we have reviewed or have additional questions.

@EXPEkesheth
Copy link
Collaborator

@almostchristian
Thanks for the time taken to submit the review. We reviewed the change and unfortunately, we won't be able to accept the change in the current form. The proposed change is not aligned with MSFT FHIR server approach with using snapshots for continuation token. The proposed change introduces a new behavior with implementing separate parameter from the continuation token. Please update the PR to align with MSFT FHIR server approach.

@EXPEkesheth EXPEkesheth removed the Review Tag for PM/Dev Review label Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Issue is a question?
Projects
None yet
Development

No branches or pull requests

2 participants