Skip to content

fix(sof): align $viewdefinition-run with v2 spec error & body shapes#114

Merged
smunini merged 1 commit into
feat/sof-integrationfrom
feat/sof-spec-compliance
May 26, 2026
Merged

fix(sof): align $viewdefinition-run with v2 spec error & body shapes#114
smunini merged 1 commit into
feat/sof-integrationfrom
feat/sof-spec-compliance

Conversation

@smunini
Copy link
Copy Markdown
Contributor

@smunini smunini commented May 26, 2026

Summary

Three spec-compliance fixes for SQL-on-FHIR $viewdefinition-run, surfaced by an audit of the v2 OperationDefinition against both binaries (sof-server and HFS REST):

  • Absent patient / group400 Bad Request + OperationOutcome. Spec's error table is explicit (Referenced patient/group not found (400)). The previous "200 OK + Warning: 199 - "..." HTTP header" path is retired. Carrier: new SofError::ReferencedResourceNotFound; the filter returns Err instead of a PatientGroupFilterOutcome { resources, warnings } wrapper, which is removed.
  • sof-server accepts a bare ViewDefinition body. Matches HFS REST. Other operation parameters (filters, _format, _limit, _since, header) must come from the query string when using this shape.
  • System-level /\$viewdefinition-run route on HFS REST was already registered (verified during the audit). No code change needed — confirmed by test_run_view_definition_system_level_route.

crates/sof/docs/spec-inconsistencies.md is updated: see-also drops the absent-target deviation, adds a note on the bare-VD shortcut, and a new "Resolved spec deviations" section records what closed.

Test plan

  • cargo fmt --all
  • cargo clippy -p helios-sof -p helios-rest --all-targets --features R4 -- -D warnings ... (CI flags) — clean
  • cargo test -p helios-sof --features R4 — all suites pass (incl. new test_run_view_definition_bare_body, updated test_filter_with_unresolvable_group_returns_bad_request)
  • cargo test -p helios-rest --features R4 — all 31 sof_run tests pass (incl. updated test_inline_run_rejects_absent_patient_target_with_400)
  • CI green

Three spec-compliance items from the v2 OperationDefinition audit
(`crates/sof/docs/spec-inconsistencies.md`):

1. Absent `patient` / `group` references are now `400 Bad Request` with
   an `OperationOutcome`, per the spec's error table — the previous
   "200 OK + Warning: 199 header" path is gone. New
   `SofError::ReferencedResourceNotFound` carries the absence; the
   filter in `filter_resources_by_patient_and_group` returns Err
   instead of an outcome wrapper, dropping `PatientGroupFilterOutcome`.

2. `sof-server` now accepts a bare `ViewDefinition` body as an
   alternative to a `Parameters` wrapper (the HFS REST handler already
   did). Other operation parameters must come from the query string in
   that shape.

3. The HFS REST system-level route at `/$viewdefinition-run` was
   already wired (verified during audit) — capability output and
   docs continue to advertise it.

Updates the see-also section of `spec-inconsistencies.md` to record
item #1 as a resolved deviation and notes the bare-ViewDefinition
shortcut as a deliberate-but-spec-silent convenience.
@smunini smunini merged commit 64dd46c into feat/sof-integration May 26, 2026
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