Skip to content

feat(hts): apply CodeSystem supplements in $expand, $validate-code, $…#100

Merged
smunini merged 1 commit into
feat/hts-terminology-servicefrom
feat/hts-cs-supplements
May 5, 2026
Merged

feat(hts): apply CodeSystem supplements in $expand, $validate-code, $…#100
smunini merged 1 commit into
feat/hts-terminology-servicefrom
feat/hts-cs-supplements

Conversation

@smunini
Copy link
Copy Markdown
Contributor

@smunini smunini commented May 5, 2026

…lookup

A CodeSystem with content=supplement plus a supplements= field adds designations / properties to a base CS without redefining its concepts. Until now we only rejected unknown supplements (commits 9077590 + 87f40db); valid ones were silently ignored, so the IG fixtures' good / none / extension-driven cases all failed.

This commit makes useSupplement actually do something:

  • New backend trait methods (default-empty so postgres degrades silently): supplement_target(url) → SupplementInfo{target_url, supplement_canonical}, supplement_designations(urls, codes), supplement_property_values(...). SQLite reads from the same code_systems / concept_designations / concept_properties tables, filtered by content='supplement'.

  • $lookup merges supplement designations into the response, tagging each one with source = supplement|version (emitted as designation.source on the Parameters output) and appends one used-supplement parameter per applied supplement. Mismatched-target supplements reject 404.

  • $validate-code accepts supplement designation values as valid alt displays: when the backend returns a display-mismatch failure and the caller's display matches a supplement designation, "rescue" the response (clear message, set result=true). Restores honoring Coding.display in both CodeSystem and ValueSet variants (re-applies the logic reverted in 340cf5f but now scoped to supplements). Also emits used-supplement and propagates bad-supplement → 404.

  • $expand resolves supplements from BOTH the request useSupplement parameter AND the source ValueSet's valueset-supplement extension. Merges supplement designations (when includeDesignations=true) and supplement properties (when property= is requested) into expansion.contains[]. Emits used-supplement in expansion.parameter.

Adds 9 new unit tests covering the good/none/bad cases for all three operations. All 500 helios-hts unit tests pass.

Expected to unlock the IG parameters/parameters-{lookup,validate, expand}-supplement-{good,none} fixtures (~6 tests), plus the extensions/extensions-echo-* family that auto-applies via the VS extension. Display-aware tests like validation/simple-coding-bad- language-{vs,vslang} should now also pass since Coding.display is honored again — without the supplement plumbing they would re-trigger the issue that caused 340cf5f to revert 670a686.

…lookup

A CodeSystem with content=supplement plus a supplements=<base> field adds
designations / properties to a base CS without redefining its concepts.
Until now we only rejected unknown supplements (commits 9077590 +
87f40db); valid ones were silently ignored, so the IG fixtures' good /
none / extension-driven cases all failed.

This commit makes useSupplement actually do something:

- New backend trait methods (default-empty so postgres degrades silently):
  supplement_target(url) → SupplementInfo{target_url, supplement_canonical},
  supplement_designations(urls, codes), supplement_property_values(...).
  SQLite reads from the same code_systems / concept_designations /
  concept_properties tables, filtered by content='supplement'.

- $lookup merges supplement designations into the response, tagging each
  one with `source = supplement|version` (emitted as designation.source
  on the Parameters output) and appends one used-supplement parameter
  per applied supplement. Mismatched-target supplements reject 404.

- $validate-code accepts supplement designation values as valid alt
  displays: when the backend returns a display-mismatch failure and the
  caller's display matches a supplement designation, "rescue" the
  response (clear message, set result=true). Restores honoring
  Coding.display in both CodeSystem and ValueSet variants (re-applies
  the logic reverted in 340cf5f but now scoped to supplements). Also
  emits used-supplement and propagates bad-supplement → 404.

- $expand resolves supplements from BOTH the request useSupplement
  parameter AND the source ValueSet's `valueset-supplement` extension.
  Merges supplement designations (when includeDesignations=true) and
  supplement properties (when property= is requested) into
  expansion.contains[]. Emits used-supplement in expansion.parameter.

Adds 9 new unit tests covering the good/none/bad cases for all three
operations. All 500 helios-hts unit tests pass.

Expected to unlock the IG `parameters/parameters-{lookup,validate,
expand}-supplement-{good,none}` fixtures (~6 tests), plus the
extensions/extensions-echo-* family that auto-applies via the VS
extension. Display-aware tests like validation/simple-coding-bad-
language-{vs,vslang} should now also pass since Coding.display is
honored again — without the supplement plumbing they would re-trigger
the issue that caused 340cf5f to revert 670a686.
@smunini smunini merged commit f571498 into feat/hts-terminology-service May 5, 2026
smunini added a commit that referenced this pull request May 5, 2026
Resolved conflicts in:
- crates/hts/src/operations/validate_code.rs: kept HEAD's SupplementInfo import alongside #98's ValidationIssue; spliced both supplement-display and multi-issue test groups as separate fns.
- crates/hts/src/backends/sqlite/value_set.rs: merged duplicate finish_validate_code_response doc-comments (HEAD's many-args rationale + #98's is_inactive_in_underlying_cs explanation).

Fix interaction between #100 supplements and #98 issues: rescue_via_supplements now also clears resp.issues — without that, a successful supplement display match would still leave an invalid-display error in the issues vec, which build_validate_response converts to result=false.
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