google / cql

An experimental Clinical Quality Language execution engine for analyzing FHIR healthcare data at scale.
Apache License 2.0
28 stars 3 forks source link

Run MERIndicators CQL #39

Open citizenrich opened 1 week ago

citizenrich commented 1 week ago

Hi,

Thanks for the great app. I'm just trying it out and see an error:

CQL CLI failed with an error: failed to parse CQL: failed to parse library: , failed to import library "DAKConcepts", dependency graph could not resolve with error: DAKConcepts  does not exist in the graph.

The repository I'm using is https://github.com/PATH-Global-Health/MERIndicators and the invocation I'm using is:

cql -cql_dir="input/cql" -fhir_bundle_dir="input/tests" -fhir_terminology_dir="input/vocabulary" -json_output_dir="./"

I'm not clear about the error, if there's any guidance that can be provided to help me troubleshoot it. Thanks.

suyashkumar commented 1 week ago

@citizenrich thank you for raising this! At first glance, this appears to be happening because our library importing logic (topological sort during library import) does not properly support including libraries without a version.

For example: https://github.com/PATH-Global-Health/MERindicators/blob/6e6403176ff980776bcfe8b697fedbd4e1939839/input/cql/DAKDataElements.cql#L7C1-L7C8

This include DAKConcepts called Cx is causing our library issues. You can bypass this issue temporarily by passing an explicit version in each include. Either way, this is an issue we should fix on our end (likely next week), and I'll update this issue title to reflect this issue.

Thanks again for raising!

suyashkumar commented 1 week ago

Note, that after updating all the includes with a version, there's still an error running your CQL with our engine:

2024/07/05 23:31:47 CQL CLI failed with an error: failed to parse CQL: 129-3 could not resolve Equivalent(Named<FHIR.CodeableConcept>, System.Code): no matching overloads
130-5 could not resolve Equivalent(Named<FHIR.CodeableConcept>, System.Code): no matching overloads
131-5 could not resolve Equivalent(Named<FHIR.CodeableConcept>, System.Code): no matching overloads

As noted in the README, this toolkit is pretty early and fully experimental with missing system operators and overloads.

For this one, I this this may be because there's no implicit converstion between FHIR.CodeableConcept and System.Code in CQL. Without looking too deeply, I think there's a conversion between FHIR.Coding and System.Code, but not one between CodeableConcept and System.Code. So this might need to be something you update in the code where this comparison is happening? If this runs in other engines, then it could very well be something we're not doing right. Our equivalent overload is a (T, T) overload meaning that we expect to be able to implicitly convert both operands to the same type.

citizenrich commented 1 week ago

Thanks for the great troubleshooting! It makes sense about the includes and authors can make that fix easily. The code does run on the CQF tooling engine and the HAPI FHIR JPA with clinical reasoning module enabled. But, I don't know enough about the codeable concept issue to offer anything useful, so I'll ping @brynrhodes

suyashkumar commented 1 week ago

No problem! Sounds good, and thank you for trying our tools out! :)

I took a closer look at the Equivalent issue, and looks like that's just something we need to do on our end. Equivalent has both (T, T) overloads and some additional explicit clinical overloads (where (System.Concept, System.Code) is a valid overload. So we'll also prioritize that next week! https://github.com/google/cql/issues/40 to track that.

evan-gordon commented 1 week ago

@citizenrich thanks again for your report!

I merged in @suyashkumar's change to add libraries to the error output, hopefully that will make debugging smoother in the future.

I started work today on https://github.com/google/cql/issues/40 I'd like to get that merged in early next week depending on team availability.

suyashkumar commented 1 week ago

I sent https://github.com/google/cql/commit/33faab5b82e4877ba3181de8edd90603eb505932 for the (Concept, Code) overload earlier (and fixed the (Code, Code)) one. Across Evan and I, we'll try to wrap up the other overloads.

That said, I think I'll just change the title of this issue to "Run MERIndicators" since there are a few other minor associated things we can fix to support all the CQL in there. It's as good of a target as any to get ship ship, particularly if @citizenrich is interested in running it with our engine! :)

suyashkumar commented 5 days ago

Here are some items we'll need to support for this CQL (can break the larger ones out into separate tasks if we want):

Feel free to edit this comment and add some more if needed.