Skip to content

Exclude Chained Scenarios DOB Query Optimization#5622

Closed
mikaelweave wants to merge 8 commits into
mainfrom
personal/mikaelw/fix-dob-rewriter-has-v2
Closed

Exclude Chained Scenarios DOB Query Optimization#5622
mikaelweave wants to merge 8 commits into
mainfrom
personal/mikaelw/fix-dob-rewriter-has-v2

Conversation

@mikaelweave

@mikaelweave mikaelweave commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a skip for the DOB rewriter for more chained / reverse chained queries.
Adds a skip for sort parameters as well,
Adds more tests for this rewriter.

Testing

local testing
e2e
unit

AB#195112

mikaelweave and others added 7 commits June 17, 2026 15:39
## What\n- Skip ScalarTemporalEqualityRewriter day-split union rewrite when the root expression contains any chain expression (forward or reverse).\n- Add regression unit tests covering both reverse-chain and forward-chain root query shapes to ensure birthdate equality stays pass-through.\n- Add an E2E forward-chain ImagingStudy started + patient birthdate + tag POST search test that mirrors the reverse-chain scenario.\n\n## Why\nUnion-expanded CTEs can shift predecessor selection in SqlQueryGenerator for complex chain queries. Skipping the scalar union rewrite for chain-containing roots preserves expected CTE ordering and prevents joins from binding to the wrong CTE branch.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Improved comments in SqlQueryGenerator and ScalarTemporalEqualityRewriter to clarify UNION ALL expansion, SMART scope unions, and DOB day-split handling, documenting current limitations and guardrails.
- Refactored chaining search E2E test to use unique tenant tags and dynamic patient creation; removed redundant forward chain test.
- Cleaned up Fixture class by removing static tenant tag and patient fields now handled within tests.
Add SQL-only E2E tests for partial birthdate OR/ne/total/sort and leap-day cases in DateSearchTests, plus chained birthdate month/day scenarios in ChainingSearchTests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…o local variable'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…o use Where'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@mikaelweave mikaelweave requested a review from a team as a code owner June 17, 2026 22:44
@mikaelweave mikaelweave added this to the FY26\Q4\2Wk\2Wk26 milestone Jun 17, 2026
@mikaelweave mikaelweave added Bug Bug bug bug. 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 Schema Version unchanged No-PaaS-breaking-change labels Jun 17, 2026
@mikaelweave mikaelweave changed the title Personal/mikaelw/fix dob rewriter has v2 Exclude Chained Scenarios DOB Query Optimization Jun 17, 2026
@mikaelweave mikaelweave enabled auto-merge (squash) June 17, 2026 23:21
Disable ScalarTemporalEqualityRewriter per-query when sort parameters are present to avoid sort/union query-shape failures, and add unit coverage for the gating behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
}

[Fact]
public void GivenRootExpressionContainsReverseChainAndAllowListedBirthdateExactDay_WhenRewritten_ThenPassThroughBirthdate()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these two be a theory?

return false;
}

return sortParameters == null || sortParameters.Count == 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will never be true, we apply type and lastupdated as default sort parameters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that explains why the test is passing...great comment thanks.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.89%. Comparing base (abca618) to head (99f8066).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5622      +/-   ##
==========================================
- Coverage   76.90%   76.89%   -0.02%     
==========================================
  Files         997      997              
  Lines       36616    36631      +15     
  Branches     5529     5537       +8     
==========================================
+ Hits        28160    28166       +6     
- Misses       7104     7115      +11     
+ Partials     1352     1350       -2     

see 13 files with indirect coverage changes

🚀 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.

auto-merge was automatically disabled June 18, 2026 17:37

Pull request was closed

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