feat(hts): apply CodeSystem supplements in $expand, $validate-code, $…#100
Merged
Merged
Conversation
…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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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-supplementextension. 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.