Skip to content

Feat/hts ig text patterns#103

Merged
smunini merged 3 commits into
feat/hts-terminology-servicefrom
feat/hts-ig-text-patterns
May 5, 2026
Merged

Feat/hts ig text patterns#103
smunini merged 3 commits into
feat/hts-terminology-servicefrom
feat/hts-ig-text-patterns

Conversation

@smunini
Copy link
Copy Markdown
Contributor

@smunini smunini commented May 5, 2026

No description provided.

smunini added 3 commits May 4, 2026 21:57
…o value

Add HtsError::VsInvalid distinct from InvalidRequest so the FHIR issue code
stays `invalid` (HTTP 400) but the tx-issue-type coding becomes `vs-invalid`,
matching the HL7 tx-ecosystem `errors/broken-filter-{expand,validate}`
fixtures (3 IG tests).

The validation runs at the top of `apply_compose_filters`: every
ValueSet.compose.include.filter[] entry must carry a non-empty `value`.
When missing, return a VsInvalid error with the IG-spec text
"The system <url> filter with property = <p>, op = <o> has no value".

Triggered identically by both `$expand` and `$validate-code` on the
broken-filter ValueSet, since both go through `apply_compose_filters`
during expansion.
The HL7 IG `deprecated/expand-*` fixtures (8 IG tests) require:

1. One `used-codesystem` parameter per distinct contributing CodeSystem,
   formatted as `<url>|<version>` — restored after the perf revert that
   removed it.
2. A parallel `warning-<status>` entry whenever the source ValueSet or a
   contributing CodeSystem carries one of:
     * `extension[].url == structuredefinition-standards-status` with
       `valueCode` of `deprecated`, `withdrawn`, `draft`, etc.
     * `experimental: true` → `warning-experimental`
     * `status: "draft"` → `warning-draft`

A new `standards_statuses()` helper centralises the rule application and
deduplicates when multiple markers point at the same status code.

Performance impact: one CodeSystem search per distinct contributing system
on the cache-miss path. Hot-path requests are still served from
`state.expand_cache` (pre-serialised bytes), so repeated identical
$expand calls pay the cost only once.
…yLanguage swap

The HL7 IG `language/expand-xform-*` fixtures (8 IG tests) plus a
follow-on set of `display/validation-*` fixtures expect a richer
displayLanguage swap shape:

  * The matching-language designation value is promoted to top-level
    `display` (existing behavior).
  * The original CodeSystem-language display becomes a designation
    `{language: <cs-lang>, use: {system, code: preferredForLanguage}, value: <orig>}`.
  * The duplicate matched designation is removed from the designation list.

Also handle the Accept-Language style "hard fallback" form
`displayLanguage=de,*; q=0`: when no matching designation exists and the
caller forbids fallback (q=0 on the wildcard), drop top-level `display`
entirely — but still surface the original CS-default display as a
preferredForLanguage designation so consumers can recover it.

Implementation:

  * `parse_display_language()` parses the request value into a
    `DisplayLangSpec { preferred, hard_fallback }`.
  * Designation lookup uses BCP 47 / RFC 4647 prefix matching, so a
    request for `de` matches stored `de-CH` designations.
  * A single per-system CodeSystem search now drives THREE downstream
    blocks (displayLanguage swap, used-codesystem emission, and
    warning-<status> emission) via a shared `cs_by_url` map — net zero
    extra SQL on the cache-miss path.
@smunini smunini merged commit 4eaa14c 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/expand.rs:
- Combined HEAD's displayLanguage/parse_display_language code with the supplements branch's apply_supplement_designations and apply_supplement_properties helpers.
- Re-added populate_concept_flags helper (referenced by the supplements branch but missing from the merged base after #102 + #103 reordering — restored from supplements branch source).
- Kept HEAD's source-VS warning-* expansion.parameter loop AND appended supplements branch's used-supplement entries (both emit distinct parameter names, no overlap).
- Closed parse_display_language_only_wildcard_returns_none test fn that the conflict cut mid-body, then preserved both test groups (parse_display_language + useSupplement).
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