Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #401 +/- ##
==========================================
+ Coverage 89.21% 89.32% +0.10%
==========================================
Files 60 61 +1
Lines 5081 5123 +42
Branches 1451 1453 +2
==========================================
+ Hits 4533 4576 +43
+ Misses 317 315 -2
- Partials 231 232 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dehall
force-pushed
the
instance_datamodelproviders
branch
from
November 3, 2026 17:14
57a113e to
ec4037d
Compare
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.
Addresses #391
Currently, objects created with the instance syntax /
InstanceELM expression are constructed as Tuples/plain JS objects, and only a few specific classes are then mapped to the real data model equivalent class. This caused issues with instances of objects outside of the system data model, where theIsexpression was throwing an error. (For the system data model, theIsexpression was permissive and always returnedtrue, so a much simpler alternate fix would be to just use that same permissive check for any type, not just the system data model. But that would produce false positives)A decent solution would be to tag the constructed JS objects with an
_isfunction that allows typechecking. The problem with that is, in theInstanceexpression there's no way to know what the full hierarchy of the requested type is, it needs some way of calling out to the library that defines the relevant data model.This PR introduces the concept of a
DataModelProvider, which is an interface that defines a single functioncreateInstance(type: string, obj: any).objis the plain JS object with mapped fields, which previously would have been the direct return value of theInstanceexpression. The intent of this is for libraries that implement a data model, eg cql-exec-fhir, they can define aDataModelProviderthat knows how to turn an arbitrary JS object into a real instance of the relevant class, and so then there's really no difference between a constructed instance and a value pulled from a DataSource.DataModelProviders are registered on an Executor and/or a Context, with the idea that we can support multiple data models if needed.
System types are handled with a new
SystemDataModelProviderthat demonstrates the concept. Previously only a few types were handled, so I added support for the remaining classes in the ELM system data model.Importantly, it is not mandatory for libraries to implement a
DataModelProviderimmediately. If theInstanceexpression gets a type that no registeredDataModelProviderknows how to handle, the resulting object stays as a plain JS object, same as today, but it's still tagged with an_isfunction that knows the specific type it is. That said, cqframework/cql-exec-fhir#50 will implement the DataModelProvider for FHIR.Pull requests into cql-execution require the following.
Submitter and reviewer should ✔ when done.
For items that are not-applicable, mark "N/A" and ✔.
Submitter:
npm run checkto run tests, lint, and prettier)Reviewer:
Name: