Skip to content

Converter: derive choices from the explicit type ceiling, not slice names - #20

Merged
ryukzak merged 2 commits into
mainfrom
fix/choices-explicit-types-only
Jul 23, 2026
Merged

Converter: derive choices from the explicit type ceiling, not slice names#20
ryukzak merged 2 commits into
mainfrom
fix/choices-explicit-types-only

Conversation

@ryukzak

@ryukzak ryukzak commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
  • Derive the choice declaration's choices from the explicit ElementDefinition.type ceiling only — never from slice names. When a profile's differential does not restate the element's type list, choices is omitted entirely.
  • Slice variants are still materialized as choiceOf elements with their constraints; slicing.rules and discriminator stay on the declaration.
  • New tests: untyped open-sliced root (no choices), typed open-sliced root (ceiling choices incl. unsliced variants), untyped closed-sliced root (no choices; rules: closed + variants are the prohibition signal).

Motivation: slicing a choice under rules: open constrains the sliced variants without restricting the choice, but merging slice names into choices made that indistinguishable from a genuine type restriction. Downstream consumers (atomic-ehr/codegen) falsely prohibited unsliced variants for open profiles — the KBV Basis cases reported in atomic-ehr/codegen#196.

Before (KBV_PR_Base_Condition_Diagnosis.onset[x], open slicing, no type restatement):

"onset": {
  "choices": ["onsetPeriod", "onsetRange", "onsetDateTime", "onsetAge"],
  "slicing": { "discriminator": [{ "type": "type", "path": "$this" }], "rules": "open" }
}

After:

"onset": {
  "slicing": { "discriminator": [{ "type": "type", "path": "$this" }], "rules": "open" }
}

Consumers inherit the base ceiling (onsetString stays permitted). Verified end-to-end against atomic-ehr/codegen: the full codegen suite passes unchanged, and the KBV profile resolves to all five base variants with nothing prohibited.

ryukzak added 2 commits July 23, 2026 16:10
Slice names no longer populate the choice declaration's choices list.
Slices constrain types the element already allows, so for a typed root
they add nothing, and for an untyped root under open rules emitting them
as choices misstates the allowed set — the inherited ceiling stays in
effect. When the differential does not restate the element's type list,
choices is omitted entirely.
@ryukzak
ryukzak merged commit 32bdc39 into main Jul 23, 2026
11 checks passed
@ryukzak
ryukzak deleted the fix/choices-explicit-types-only branch July 23, 2026 12:16
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