Skip to content

Fix handling of choice elements that specify SimpleQuantity as a choice type - #46

Merged
cmoesel merged 6 commits into
masterfrom
dosage-bug
Aug 25, 2025
Merged

Fix handling of choice elements that specify SimpleQuantity as a choice type#46
cmoesel merged 6 commits into
masterfrom
dosage-bug

Conversation

@cmoesel

@cmoesel cmoesel commented Aug 22, 2025

Copy link
Copy Markdown
Member

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 a SimpleQuantity need to use the datatype name Quantity because SimpleQuantity is actually a profile of the Quantity type (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).

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).
@cmoesel
cmoesel requested a review from hossenlopp August 22, 2025 22:19

@hossenlopp hossenlopp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works with fqm-execution.

@cmoesel
cmoesel merged commit ad8b4f2 into master Aug 25, 2025
14 checks passed
@cmoesel
cmoesel deleted the dosage-bug branch August 25, 2025 19:00
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.

2 participants