Skip to content

feat(hts): emit multi-issue OperationOutcomes from $validate-code#98

Merged
smunini merged 1 commit into
feat/hts-terminology-servicefrom
feat/hts-multi-issue-oo
May 5, 2026
Merged

feat(hts): emit multi-issue OperationOutcomes from $validate-code#98
smunini merged 1 commit into
feat/hts-terminology-servicefrom
feat/hts-multi-issue-oo

Conversation

@smunini
Copy link
Copy Markdown
Contributor

@smunini smunini commented May 5, 2026

The HL7 tx-ecosystem IG fixtures expect $validate-code failure cases to surface one OperationOutcome.issue per concern (abstract + not-in-vs, unknown-system + not-in-vs, inactive + valid-but-not-active + not-in-vs, display-mismatch, etc.) rather than collapsing every signal into a single error issue. The previous implementation always emitted a single issue with code=code-invalid + tx-issue-type=not-in-vs, which made ~40 fixtures fail with "Expected:N Actual:1" issue counts.

Changes:

  • types.rs: add ValidationIssue (severity, fhir_code, tx_code, text, location, message_id) and ValidateCodeResponse.issues field — backends push one issue per detected concern; the operations layer renders them as OperationOutcome.issue[] entries and joins their texts (alphabetically, "; "-separated) into the top-level message parameter.
  • backends/sqlite/value_set.rs::finish_validate_code_response: emit separate issues for code-not-in-vs, abstract (business-rule code-rule
    • code-invalid not-in-vs), inactive (warning), display-mismatch (error invalid-display), and the IG-specific "valid but not active" triple when a code is in the underlying CodeSystem but excluded from the VS by activeOnly / compose.inactive=false.
  • backends/sqlite/code_system.rs: emit not-found/not-found for unknown CodeSystem, code-invalid/invalid-code for unknown code, and invalid/invalid-display for display mismatch.
  • operations/validate_code.rs::build_validate_response: walk resp.issues; synthesise an UNKNOWN_CODESYSTEM not-found issue when the operations layer sees an unknown system (surfaces the IG-required second issue alongside the backend's not-in-vs); fall back to the legacy single-issue path only when no structured issues are present.
  • backends/postgres/*: add empty issues field to satisfy the new struct shape (postgres backend keeps single-message behaviour for now).

Adds two unit tests (vs_validate_unknown_system_emits_two_issues, vs_validate_no_system_on_coding_emits_invalid_data_issue) covering the two simplest multi-issue scenarios. All 622 helios-hts tests pass.

[skip ci]

The HL7 tx-ecosystem IG fixtures expect $validate-code failure cases to
surface one OperationOutcome.issue per concern (abstract + not-in-vs,
unknown-system + not-in-vs, inactive + valid-but-not-active + not-in-vs,
display-mismatch, etc.) rather than collapsing every signal into a
single error issue. The previous implementation always emitted a single
issue with code=code-invalid + tx-issue-type=not-in-vs, which made ~40
fixtures fail with "Expected:N Actual:1" issue counts.

Changes:
- types.rs: add ValidationIssue (severity, fhir_code, tx_code, text,
  location, message_id) and ValidateCodeResponse.issues field — backends
  push one issue per detected concern; the operations layer renders
  them as OperationOutcome.issue[] entries and joins their texts
  (alphabetically, "; "-separated) into the top-level message parameter.
- backends/sqlite/value_set.rs::finish_validate_code_response: emit
  separate issues for code-not-in-vs, abstract (business-rule code-rule
  + code-invalid not-in-vs), inactive (warning), display-mismatch
  (error invalid-display), and the IG-specific "valid but not active"
  triple when a code is in the underlying CodeSystem but excluded from
  the VS by activeOnly / compose.inactive=false.
- backends/sqlite/code_system.rs: emit not-found/not-found for unknown
  CodeSystem, code-invalid/invalid-code for unknown code, and
  invalid/invalid-display for display mismatch.
- operations/validate_code.rs::build_validate_response: walk
  resp.issues; synthesise an UNKNOWN_CODESYSTEM not-found issue when
  the operations layer sees an unknown system (surfaces the IG-required
  second issue alongside the backend's not-in-vs); fall back to the
  legacy single-issue path only when no structured issues are present.
- backends/postgres/*: add empty issues field to satisfy the new struct
  shape (postgres backend keeps single-message behaviour for now).

Adds two unit tests (vs_validate_unknown_system_emits_two_issues,
vs_validate_no_system_on_coding_emits_invalid_data_issue) covering the
two simplest multi-issue scenarios. All 622 helios-hts tests pass.

[skip ci]
@smunini smunini merged commit 308b3e5 into feat/hts-terminology-service May 5, 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