Skip to content

feat(rest): advertise real search modifiers and includes in CapabilityStatement#157

Open
smunini wants to merge 1 commit into
mainfrom
feature/capabilities-real-search-params
Open

feat(rest): advertise real search modifiers and includes in CapabilityStatement#157
smunini wants to merge 1 commit into
mainfrom
feature/capabilities-real-search-params

Conversation

@smunini

@smunini smunini commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What

GET /metadata now advertises the server's real search capabilities. The headline gap from the UI requirements doc (§7.9) — only seven static search params — was already fixed on main; this closes the two remaining gaps:

  1. searchInclude / searchRevInclude were hardcoded ["*"]. They are now derived from real reference search params:
    • searchInclude = Type:code for each reference param defined on the type.
    • searchRevInclude = Source:code for every reference param (on any type) that targets this type.
    • Omitted entirely when a type has none (no more unconditional *).
  2. Modifiers were never advertised. Each resource-specific searchParam now carries the modifiers the backend actually honors (:exact, :contains, :not, :identifier, …) as repeating valueCode extensions under http://heliossoftware.com/fhir/StructureDefinition/capabilitystatement-search-modifier. R4/R5 CapabilityStatement.rest.resource.searchParam has no native modifier element, so an extension is the spec-compatible carrier.

How

  • New defaulted SearchProvider::modifiers_for_param_type; sqlite/postgres/elasticsearch/mongodb override it to surface their existing modifiers_for_type set, so the advertisement is per-backend honest. CompositeStorage (the storage the hfs binary runs) delegates with the same routing as supports_contained_search.
  • Handler precomputes the modifier map and a reverse-include index once per request (under the existing registry read lock) and threads them into build_resource_capability / build_search_params.
  • Modifiers are attached only to registry-driven params, not control params (_id, _tag, …), to avoid overclaiming.

Scope notes

  • No change to the already-correct real per-resource params or _text/_content typing.
  • comparator is not advertised (no standard CapabilityStatement field).

Tests

  • Unit: include/revinclude derivation from a small registry; modifier extension presence + control-param exclusion.
  • Integration (crates/rest/tests/capabilities_search_params.rs, SQLite + full spec registry): GET /metadata advertises Patient.name / Observation.code, non-wildcard Patient includes, an Observation:* revinclude, and the modifier extension on a reference param.

Verified: cargo fmt --all; CI-style cargo clippy -p helios-persistence -p helios-rest --all-targets --features elasticsearch,postgres -- -D warnings ... clean; helios-rest capabilities/sof_capabilities + new integration test, and helios-persistence lib (665) all green.

…yStatement

`GET /metadata` previously hardcoded `searchInclude`/`searchRevInclude` to
`["*"]` and never advertised search modifiers. This closes both gaps (the
real per-resource search params were already emitted from the registry).

Persistence:
- Add `SearchProvider::modifiers_for_param_type` (defaulted to empty). The
  sqlite/postgres/elasticsearch/mongodb backends override it to expose their
  existing per-type modifier set (`modifiers_for_type`); `CompositeStorage`
  delegates with the same search-backend/primary routing as
  `supports_contained_search`.

REST handler:
- `searchInclude` is now derived from each type's real reference params
  (`Type:code`) instead of `["*"]`; omitted when a type has none.
- `searchRevInclude` is derived from a reverse index of every reference param
  that targets the type (`Source:code`), instead of `["*"]`.
- Each resource-specific `searchParam` carries the modifiers the backend
  honors as repeating `valueCode` extensions under
  `capabilitystatement-search-modifier` (R4/R5 `searchParam` has no native
  `modifier` element). Control params (`_id`, `_tag`, ...) are left as-is to
  avoid overclaiming.

Tests: unit tests for include/revinclude derivation and the modifier
extension; an integration test asserting real params, includes, and modifier
extensions via `GET /metadata`.
@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.84530% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/persistence/src/composite/storage.rs 0.00% 17 Missing ⚠️
crates/persistence/src/core/search.rs 0.00% 4 Missing ⚠️
crates/rest/src/handlers/capabilities.rs 99.34% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant