Skip to content

Comments

Expiry date search parameter#5403

Draft
LTA-Thinking wants to merge 5 commits intomainfrom
personal/rojo/ttl-search-param
Draft

Expiry date search parameter#5403
LTA-Thinking wants to merge 5 commits intomainfrom
personal/rojo/ttl-search-param

Conversation

@LTA-Thinking
Copy link
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)


UPDATE dbo.SearchParam
SET Status = sps.Status, LastUpdated = @lastUpdated, IsPartiallySupported = sps.IsPartiallySupported
SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled.ToString()}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported.ToString()}' ELSE sps.Status END) ELSE sps.Status END

Check notice

Code scanning / CodeQL

Redundant ToString() call Note

Redundant call to 'ToString' on a String object.

Copilot Autofix

AI 3 days ago

In general, to fix redundant ToString() calls in interpolated or concatenated strings, remove the explicit .ToString() when the language/runtime will implicitly convert the value to string anyway (such as in $"..." or string.Format). This keeps the code simpler and avoids unnecessary method calls.

In this specific case, within InitializeSearchParameterStatuses in SqlServerFhirModel.cs, line 397 builds a SQL command via an interpolated verbatim string. It uses '{SearchParameterStatus.Enabled.ToString()}' and '{SearchParameterStatus.Supported.ToString()}' inside the command text. C# interpolated strings automatically call ToString() on SearchParameterStatus.Enabled and SearchParameterStatus.Supported, so the explicit .ToString() calls are redundant. The correct fix is to remove .ToString() from both occurrences on that line, leaving '{SearchParameterStatus.Enabled}' and '{SearchParameterStatus.Supported}'. No other imports, methods, or definitions are needed, and the resulting SQL text will be identical to the current one.

Concretely:

  • Edit src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.cs.
  • In the sqlCommandWrapper.CommandText assignment, on the UPDATE dbo.SearchParam line, replace SearchParameterStatus.Enabled.ToString() with SearchParameterStatus.Enabled and SearchParameterStatus.Supported.ToString() with SearchParameterStatus.Supported.
  • Leave all other code unchanged.

Suggested changeset 1
src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.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.SqlServer/Features/Storage/SqlServerFhirModel.cs b/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.cs
--- a/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.cs
+++ b/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.cs
@@ -394,7 +394,7 @@
                         DECLARE @resourcesPresent bit = CASE WHEN EXISTS (SELECT TOP 1 * FROM Resource) THEN 1 ELSE 0 END
 
                         UPDATE dbo.SearchParam
-                        SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled.ToString()}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported.ToString()}' ELSE sps.Status END) ELSE sps.Status END
+                        SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported}' ELSE sps.Status END) ELSE sps.Status END
                             , LastUpdated = @lastUpdated, IsPartiallySupported = sps.IsPartiallySupported
                         FROM dbo.SearchParam INNER JOIN @searchParamStatuses as sps
                         ON dbo.SearchParam.Uri = sps.Uri
EOF
@@ -394,7 +394,7 @@
DECLARE @resourcesPresent bit = CASE WHEN EXISTS (SELECT TOP 1 * FROM Resource) THEN 1 ELSE 0 END

UPDATE dbo.SearchParam
SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled.ToString()}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported.ToString()}' ELSE sps.Status END) ELSE sps.Status END
SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported}' ELSE sps.Status END) ELSE sps.Status END
, LastUpdated = @lastUpdated, IsPartiallySupported = sps.IsPartiallySupported
FROM dbo.SearchParam INNER JOIN @searchParamStatuses as sps
ON dbo.SearchParam.Uri = sps.Uri
Copilot is powered by AI and may make mistakes. Always verify output.

UPDATE dbo.SearchParam
SET Status = sps.Status, LastUpdated = @lastUpdated, IsPartiallySupported = sps.IsPartiallySupported
SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled.ToString()}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported.ToString()}' ELSE sps.Status END) ELSE sps.Status END

Check notice

Code scanning / CodeQL

Redundant ToString() call Note

Redundant call to 'ToString' on a String object.

Copilot Autofix

AI 3 days ago

In general, to fix redundant ToString() calls in interpolated strings or string concatenations, you should remove the explicit .ToString() and let C#’s implicit conversion (via string.Format or interpolation) invoke ToString() as needed. This avoids unnecessary method calls and cleans up the code without altering behavior.

In this specific method, InitializeSearchParameterStatuses, the SQL command text is built with an interpolated verbatim string assigned to sqlCommandWrapper.CommandText. Line 397 contains two explicit ToString() calls: SearchParameterStatus.Enabled.ToString() and SearchParameterStatus.Supported.ToString(). These appear inside {...} interpolation holes, so the compiler will already call ToString() on those values. We can safely remove both .ToString() calls and interpolate SearchParameterStatus.Enabled and SearchParameterStatus.Supported directly. No additional imports, methods, or definitions are needed; only this line in SqlServerFhirModel.cs must be updated.

Concretely, update line 397 from:

SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled.ToString()}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported.ToString()}' ELSE sps.Status END) ELSE sps.Status END

to:

SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported}' ELSE sps.Status END) ELSE sps.Status END

This preserves the generated SQL while removing redundant ToString() calls.

Suggested changeset 1
src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.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.SqlServer/Features/Storage/SqlServerFhirModel.cs b/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.cs
--- a/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.cs
+++ b/src/Microsoft.Health.Fhir.SqlServer/Features/Storage/SqlServerFhirModel.cs
@@ -394,7 +394,7 @@
                         DECLARE @resourcesPresent bit = CASE WHEN EXISTS (SELECT TOP 1 * FROM Resource) THEN 1 ELSE 0 END
 
                         UPDATE dbo.SearchParam
-                        SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled.ToString()}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported.ToString()}' ELSE sps.Status END) ELSE sps.Status END
+                        SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported}' ELSE sps.Status END) ELSE sps.Status END
                             , LastUpdated = @lastUpdated, IsPartiallySupported = sps.IsPartiallySupported
                         FROM dbo.SearchParam INNER JOIN @searchParamStatuses as sps
                         ON dbo.SearchParam.Uri = sps.Uri
EOF
@@ -394,7 +394,7 @@
DECLARE @resourcesPresent bit = CASE WHEN EXISTS (SELECT TOP 1 * FROM Resource) THEN 1 ELSE 0 END

UPDATE dbo.SearchParam
SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled.ToString()}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported.ToString()}' ELSE sps.Status END) ELSE sps.Status END
SET Status = CASE WHEN sps.Status = '{SearchParameterStatus.Enabled}' THEN (CASE WHEN @resourcesPresent = 1 THEN '{SearchParameterStatus.Supported}' ELSE sps.Status END) ELSE sps.Status END
, LastUpdated = @lastUpdated, IsPartiallySupported = sps.IsPartiallySupported
FROM dbo.SearchParam INNER JOIN @searchParamStatuses as sps
ON dbo.SearchParam.Uri = sps.Uri
Copilot is powered by AI and may make mistakes. Always verify output.
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant