Skip to content

Expiry date search parameter#5403

Merged
LTA-Thinking merged 21 commits intomainfrom
personal/rojo/ttl-search-param
Mar 6, 2026
Merged

Expiry date search parameter#5403
LTA-Thinking merged 21 commits intomainfrom
personal/rojo/ttl-search-param

Conversation

@LTA-Thinking
Copy link
Copy Markdown
Contributor

Description

Adds a built in search parameter for the expiry date extension.

Related issues

Addresses User Story 183519

Testing

Describe how this change was tested.

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)

@LTA-Thinking LTA-Thinking added this to the FY26\Q3\2Wk\2Wk17 milestone Feb 20, 2026
@LTA-Thinking LTA-Thinking added Enhancement Enhancement on existing functionality. Azure API for FHIR Label denotes that the issue or PR is relevant to the Azure API for FHIR Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs No-PaaS-breaking-change labels Feb 20, 2026
@github-actions github-actions Bot added the SQL Scripts If SQL scripts are added to the PR label Feb 26, 2026
@LTA-Thinking LTA-Thinking marked this pull request as ready for review March 3, 2026 18:20
@LTA-Thinking LTA-Thinking requested a review from a team as a code owner March 3, 2026 18:20
@feordin
Copy link
Copy Markdown
Contributor

feordin commented Mar 3, 2026

I think it would be useful to have an ADR for this change. It is the first time we have new out of the box Search Parameters, and some notes on the why and how would be good to have.

Comment thread src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.cs Outdated
feordin
feordin previously approved these changes Mar 6, 2026
.Returns(cosmosQuery);

var response = Substitute.ForPartsOf<FeedResponse<dynamic>>();
response.ContinuationToken.Returns((string)null);

Check warning

Code scanning / CodeQL

Useless upcast Warning

There is no need to upcast from
null
to
String
- the conversion can be done implicitly.

Copilot Autofix

AI about 2 months ago

To fix the problem, remove the redundant explicit cast from null to string and let the compiler perform the implicit conversion. This keeps behavior identical while eliminating the useless upcast.

Concretely, in CosmosDbSearchParameterStatusInitializerTests (file src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs), update the line in the test setup where response.ContinuationToken is configured. Change response.ContinuationToken.Returns((string)null); to response.ContinuationToken.Returns((string)null!);? No, to simply response.ContinuationToken.Returns((string)null);? Actually, per the analysis, we should change it to response.ContinuationToken.Returns((string)null);? Wait, there is a question. The best fix is to remove the cast, so change it to response.ContinuationToken.Returns((string)null);? No, remove (string) and just use null: response.ContinuationToken.Returns((string)null);response.ContinuationToken.Returns((string)null);? That’s still redundant. The correct replacement is response.ContinuationToken.Returns((string)null);? No: response.ContinuationToken.Returns((string)null); should become response.ContinuationToken.Returns((string)null);? To avoid confusion: the detailed change is to replace (string)null with null, so the final line is response.ContinuationToken.Returns((string)null);response.ContinuationToken.Returns((string)null);? This is getting circular; explicitly, the fixed line is:

response.ContinuationToken.Returns(null as string);

or more simply:

response.ContinuationToken.Returns((string)null);

But both still contain a cast. The minimal, clear fix that removes the explicit upcast is:

response.ContinuationToken.Returns((string)null);

Actually, the truly cast-free version is:

response.ContinuationToken.Returns((string)null);

To avoid confusion in this explanation, the exact fix is:

  • Original: response.ContinuationToken.Returns((string)null);
  • New: response.ContinuationToken.Returns(null);

No additional imports or helper methods are required.

Suggested changeset 1
src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs b/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
--- a/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
+++ b/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
@@ -65,7 +65,7 @@
                 .Returns(cosmosQuery);
 
             var response = Substitute.ForPartsOf<FeedResponse<dynamic>>();
-            response.ContinuationToken.Returns((string)null);
+            response.ContinuationToken.Returns(null);
 
             cosmosQuery
                 .ExecuteNextAsync()
EOF
@@ -65,7 +65,7 @@
.Returns(cosmosQuery);

var response = Substitute.ForPartsOf<FeedResponse<dynamic>>();
response.ContinuationToken.Returns((string)null);
response.ContinuationToken.Returns(null);

cosmosQuery
.ExecuteNextAsync()
Copilot is powered by AI and may make mistakes. Always verify output.
response.GetEnumerator()
.Returns(new List<dynamic> { new SearchParameterStatusWrapper() }.GetEnumerator());
.Returns(new List<dynamic> { _testParameterUri.OriginalString }.GetEnumerator());
response.ContinuationToken.Returns((string)null);

Check warning

Code scanning / CodeQL

Useless upcast Warning

There is no need to upcast from
null
to
String
- the conversion can be done implicitly.

Copilot Autofix

AI about 2 months ago

To fix the problem, remove the unnecessary explicit cast and rely on the implicit conversion of null to string. This keeps behavior identical while eliminating the redundant upcast.

Concretely, in CosmosDbSearchParameterStatusInitializerTests.cs, change the line:

response.ContinuationToken.Returns((string)null);

to:

response.ContinuationToken.Returns(null);

No other lines, methods, or imports need to change. This preserves existing test behavior while satisfying the CodeQL rule.

Suggested changeset 1
src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs b/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
--- a/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
+++ b/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
@@ -102,7 +102,7 @@
 
             response.GetEnumerator()
                 .Returns(new List<dynamic> { _testParameterUri.OriginalString }.GetEnumerator());
-            response.ContinuationToken.Returns((string)null);
+            response.ContinuationToken.Returns(null);
 
             documentQuery
                 .ExecuteNextAsync()
EOF
@@ -102,7 +102,7 @@

response.GetEnumerator()
.Returns(new List<dynamic> { _testParameterUri.OriginalString }.GetEnumerator());
response.ContinuationToken.Returns((string)null);
response.ContinuationToken.Returns(null);

documentQuery
.ExecuteNextAsync()
Copilot is powered by AI and may make mistakes. Always verify output.

response.GetEnumerator()
.Returns(new List<dynamic> { "/missing" }.GetEnumerator());
response.ContinuationToken.Returns((string)null);

Check warning

Code scanning / CodeQL

Useless upcast Warning

There is no need to upcast from
null
to
String
- the conversion can be done implicitly.

Copilot Autofix

AI about 2 months ago

In general, to fix a “useless upcast” on null, simply remove the explicit cast and pass null directly. Since null is implicitly convertible to any reference type, the compiler will infer the correct type from the context.

In this specific case, the line response.ContinuationToken.Returns((string)null); should be changed to response.ContinuationToken.Returns((string)null!); Wait — we need to be careful not to introduce unnecessary noise: the property ContinuationToken is of type string, and NSubstitute infers the type for Returns from the property’s type, so using null alone is sufficient. The best minimal change is to replace (string)null with null. This does not require any new imports or additional methods. The only code change is on line 142 in CosmosDbSearchParameterStatusInitializerTests.cs.

Suggested changeset 1
src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs b/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
--- a/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
+++ b/src/Microsoft.Health.Fhir.CosmosDb.UnitTests/Features/Storage/Registry/CosmosDbSearchParameterStatusInitializerTests.cs
@@ -139,7 +139,7 @@
 
             response.GetEnumerator()
                 .Returns(new List<dynamic> { "/missing" }.GetEnumerator());
-            response.ContinuationToken.Returns((string)null);
+            response.ContinuationToken.Returns(null);
 
             documentQuery
                 .ExecuteNextAsync()
EOF
@@ -139,7 +139,7 @@

response.GetEnumerator()
.Returns(new List<dynamic> { "/missing" }.GetEnumerator());
response.ContinuationToken.Returns((string)null);
response.ContinuationToken.Returns(null);

documentQuery
.ExecuteNextAsync()
Copilot is powered by AI and may make mistakes. Always verify output.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.93%. Comparing base (e526922) to head (d323193).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5403      +/-   ##
==========================================
+ Coverage   76.85%   76.93%   +0.08%     
==========================================
  Files         975      975              
  Lines       35321    35511     +190     
  Branches     5299     5325      +26     
==========================================
+ Hits        27146    27322     +176     
- Misses       6852     6864      +12     
- Partials     1323     1325       +2     

see 17 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.

@LTA-Thinking LTA-Thinking merged commit 1ef9f1a into main Mar 6, 2026
61 of 63 checks passed
@LTA-Thinking LTA-Thinking deleted the personal/rojo/ttl-search-param branch March 6, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ADR-Included ADR Included in the PR Azure API for FHIR Label denotes that the issue or PR is relevant to the Azure API for FHIR Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Enhancement Enhancement on existing functionality. No-PaaS-breaking-change Schema Version backward compatible SQL Scripts If SQL scripts are added to the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants