Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 7, 2025

Description

Adds GetSearchParamsFromCapabilityStatement, a table-valued function that parses FHIR Capability Statement JSON and returns search parameter metadata (resource type, URL, type) for SQL querying.

Implementation:

  • SQL Server table-valued function using OPENJSON to traverse rest[] → resource[] → searchParam[] nested structure
  • Returns table with columns: ResourceType, SearchParamUrl, SearchParamType
  • Filters incomplete entries (NULL values)

Schema changes:

  • New function in Sprocs/GetSearchParamsFromCapabilityStatement.sql
  • Schema version V100 with migration 100.diff.sql

Usage:

DECLARE @json NVARCHAR(MAX) = N'{
  "resourceType": "CapabilityStatement",
  "rest": [{
    "resource": [{
      "type": "Patient",
      "searchParam": [{
        "definition": "http://hl7.org/fhir/SearchParameter/Patient-name",
        "type": "string"
      }]
    }]
  }]
}';

SELECT * FROM dbo.GetSearchParamsFromCapabilityStatement(@json);
-- Returns: Patient | http://hl7.org/fhir/SearchParameter/Patient-name | string

Supports filtering, joining with SearchParam table, and aggregation.

Related issues

Addresses internal requirement for SQL-based Capability Statement search parameter extraction.

Testing

Manual test script with 8 scenarios covering:

  • Basic functionality (multiple resources/params)
  • Edge cases (empty arrays, NULL handling)
  • Multiple rest entries
  • Filtering and aggregation patterns

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: Enhancement
  • Tag the PR with Azure Healthcare APIs (SQL code)
  • Tag the PR with Schema Version backward compatible (read-only function, no breaking changes)
  • 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)

Feature (new SQL function)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • microsofthealthoss.pkgs.visualstudio.com
    • Triggering command: dotnet build Microsoft.Health.Fhir.sln --configuration Release (dns block)
    • Triggering command: dotnet build src/Microsoft.Health.Fhir.SqlServer/Microsoft.Health.Fhir.SqlServer.csproj --configuration Release (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Write json function to return the list of (resource type, search param url, and search param type) from FHIR capability statement in json format. Required funtion should be implemented as SELECT in SQL server.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 8, 2025 00:00
- Created table-valued function to extract search parameters from FHIR Capability Statement JSON
- Updated schema version to V100
- Added migration file 100.diff.sql
- Added unit test documentation
- Added comprehensive usage documentation

Co-authored-by: SergeyGaluzo <[email protected]>
Copilot AI changed the title [WIP] Add JSON function to extract FHIR capability statement data Add SQL function to extract search params from Capability Statement JSON Nov 8, 2025
Copilot AI requested a review from SergeyGaluzo November 8, 2025 00:06
Copilot finished work on behalf of SergeyGaluzo November 8, 2025 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants