Converter: preserve choice type slicing (open/closed rules, all variants) - #19
Merged
Conversation
Type slicing on choice elements ($this type discriminator) was mangled: a slicing root without an explicit type list was dropped entirely (losing slicing.rules and the discriminator), each slice overwrote the parent's choices (only the last variant survived), and variants got self-referential slices with empty matches. Collapse such slicing into the plain choice representation before stack processing: the sliced element becomes the choice declaration with accumulated choices and the slicing metadata, each slice becomes a regular typed variant element, and slice children are re-parented under their variant.
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.
Type slicing on choice elements (
$thistype discriminator) — the pattern KBV Basis and US Core use ononset[x]/value[x]— was mangled by the converter:typelist was dropped entirely, losingslicing.rules(open/closed) and the discriminatorchoices(e.g. KBVCondition.onset[x]with slices Period/Range/dateTime/Age came out aschoices: ["onsetAge"])slicing.slicesnodes with emptymatch: {}(type discriminators are skipped bybuildMatchForSlice)Fix:
collapseChoiceTypeSlicing()rewrites such slicing into the plain choice representation before stack processing — the sliced element becomes the choice declaration (accumulatedchoices+ preservedslicingmetadata), each slice becomes a regular typed variant element (choiceOfset), and slice children are re-parented under their variant.Before (KBV
Condition.onset[x], open slicing with 4 type slices):After:
main(make allfully green with this build linked): generated KBV profiles lose their falsevalidateExcludedchecks for open choice variants, previously-lostus-core-smokingstatusvalue[x]slice bindings materialize, and genuinely restricted profiles keep their exclusions.