Skip to content

Fix sorted SQL includes pagination - #5868

Open
Richa Bansal (rbans96) wants to merge 1 commit into
mainfrom
rbans96-bug-207476-root-cause
Open

Richa Bansal (rbans96) wants to merge 1 commit into
mainfrom
rbans96-bug-207476-root-cause

Conversation

@rbans96

Copy link
Copy Markdown
Contributor

Description

Fix missing and incorrect $includes results in sorted SQL searches. Replay sorted match pages instead of surrogate-ID ranges, preserve phase cursors and legacy tokens, and add SQL pagination regression coverage.

Related issues

Addresses [AB#207476](https://microsofthealth.visualstudio.com/Health/_workitems/edit/207476).

Testing

  • New SQL E2E suite: 7 failures before the fix; all 15 cases pass afterward.

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch|Skip|Feature|Breaking (reason)

Replay sorted match pages for includes instead of surrogate ID ranges; preserve phase cursors and legacy tokens. Add SQL pagination regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@rbans96
Richa Bansal (rbans96) requested a review from a team as a code owner September 22, 2026 22:01
@rbans96 Richa Bansal (rbans96) added Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs No-ADR ADR not needed Bug Bug bug bug. Schema Version unchanged No-PaaS-breaking-change labels Sep 22, 2026
Comment on lines +174 to +201
{
await base.OnInitializedAsync();

var sortedSetDayOffsets = new int?[SortedSetSize];
for (var rank = 0; rank < SortedSetDescendingRankToCreationIndex.Length; rank++)
{
sortedSetDayOffsets[SortedSetDescendingRankToCreationIndex[rank]] = SortedSetDayOffsetByRank[rank];
}

for (var creationIndex = 0; creationIndex < SortedSetSize; creationIndex++)
{
var (reportReference, observationReference) = await CreateTripleAsync(_sortedTag, creationIndex, sortedSetDayOffsets[creationIndex], sortedSetDayOffsets[creationIndex]);
_sortedSetReportReferences.Add(reportReference);
_sortedSetObservationReferences.Add(observationReference);
}

var phaseSetDayOffsets = new int?[PhaseSetSize];
for (var rank = 0; rank < PhaseSetDescendingRankToCreationIndex.Length; rank++)
{
phaseSetDayOffsets[PhaseSetDescendingRankToCreationIndex[rank]] = PhaseSetDayOffsetByRank[rank];
}

for (var creationIndex = 0; creationIndex < PhaseSetSize; creationIndex++)
{
var (reportReference, _) = await CreateTripleAsync(_phaseTag, creationIndex, phaseSetDayOffsets[creationIndex], observationDayOffset: null);
_phaseSetReportReferences.Add(reportReference);
}
}
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@a64af8f). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5868   +/-   ##
=======================================
  Coverage        ?   78.85%           
=======================================
  Files           ?     1018           
  Lines           ?    37140           
  Branches        ?     5684           
=======================================
  Hits            ?    29287           
  Misses          ?     6424           
  Partials        ?     1429           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Bug Bug bug bug. No-ADR ADR not needed No-PaaS-breaking-change Schema Version unchanged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants