Fix handling of choice elements that specify SimpleQuantity as a choice type - #46
Merged
Conversation
Make tests specific to the problem of choice types w/ SimpleQuantity and add a test for each way of accessing them (via root and via explicit choice type).
hossenlopp
approved these changes
Aug 25, 2025
hossenlopp
left a comment
Contributor
There was a problem hiding this comment.
Looks good and works with fqm-execution.
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.
FHIR serializes choice elements (e.g.,
value[x]) by replacing the[x]with the datatype name (e.g.,valueString). When cql-exec-fhir needs to process a choice element, it references the model info to see the available choices and uses their names to derive the expected property names in the JSON. This mainly works except in one case: choices that allow for aSimpleQuantityneed to use the datatype nameQuantitybecauseSimpleQuantityis actually a profile of theQuantitytype (and profiles are serialized using their base type name).This PR fixes processing of choices by adding a function to normalize choice type names that are used in FHIR JSON. There are tests for two variations of this problem: accessing a choice element by its root (e.g.,
dosageInstruction[0].doseAndRate[0].dose) and accessing a choice element by its explicit property name (e.g.,dosageInstruction[0].doseAndRate[0].doseQuantity). To see the tests fail, check out this branch and roll back to commit 4fade9d.This bug was reported against FQM Execution. See fqm-execution#352.
This PR also updates all dependencies to their latest versions (except chai, which dropped support for CommonJS in version 5).