TS: demonstrate fixed[x] merge corner case (WIP)#168
Draft
ryukzak wants to merge 1 commit into
Draft
Conversation
- new PatientFixedMaritalStatus profile (true fixedCodeableConcept on maritalStatus)
- runtime test exercising generated apply():
- create() materializes exactly the fixed value
- apply() on a resource with a conflicting coding + text merges instead of
replacing, and validate() still passes (validateFixedValue uses containment)
- register the profile in the example tree-shake config
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.
Draft — adds a failing-by-design demonstration of the
fixed[x]vspattern[x]issue from #165. Test only; the codegen fix is not included yet.Context
#165 made generated profile
apply()merge fixed values (applyFixedValue) instead of overwriting them. That is correct forpattern[x]and slice discriminators, but a true FHIRfixed[x]requires the element to be exactly equal to the fixed value. The generator does not branch onvalueConstraint.kind, sofixed[x]is merged too — andvalidateFixedValueuses containment (matchesValue), so it accepts the merged result.What this PR adds
PatientFixedMaritalStatusStructureDefinition — a truefixedCodeableConceptonPatient.maritalStatus(not a coding slice), registered in the example tree-shake config.examples/local-package-folder/profile-fixed-marital-status.test.ts— runtime tests against the generated profile class:create()materializes exactly the fixed CodeableConcept.apply()on a resource that already carries a conflicting coding (same system, different code) + freetextmerges rather than replacing — caller data survives and the fixed coding is appended — yetvalidate().errorsis empty.The generated
apply()confirms a realfixed[x]reaches the merge path:TODO before un-drafting
valueConstraint.kind("fixed"→ exact replace,"pattern"→ merge), and relabel the synthesized fixed-coding-slice constraint (field-builder.ts) aspattern.