FHIR Chat · Utility to convert CQL to Library · cql

Stream: cql

Topic: Utility to convert CQL to Library


view this post on Zulip Richard Stanley (Feb 02 2021 at 21:28):

Hi folks. Is there an existing utility that converts CQL to a Library resource (not the Base64 encoded bit), e.g. the required fields like relatedArtifact etc?

view this post on Zulip JP (Feb 02 2021 at 21:45):

Yes, the cqf-tooling is able to do that:

https://github.com/cqframework/cqf-tooling/blob/master/src/main/java/org/opencds/cqf/tooling/Main.java#L45

view this post on Zulip Bryn Rhodes (Feb 02 2021 at 22:56):

The publisher will also do it, with binary adjunct files: https://confluence.hl7.org/display/FHIR/Implementation+Guide+Parameters

view this post on Zulip Bryn Rhodes (Feb 02 2021 at 23:23):

And the publisher produces a very nice narrative for Library resources (hat tip @Grahame Grieve )

view this post on Zulip Richard Stanley (Feb 03 2021 at 00:30):

Thanks, I'll have a look at the publisher! On the cqf-tooling, I see an error on the CQL path. This must be user error, but any hints?

$ ls /Users/richard/src/github.com/intrahealth/madx-hiv/input/pagecontent/cql/
total 8
drwxr-xr-x  3 richard  staff    96B Feb  2 19:21 .
drwxr-xr-x  3 richard  staff    96B Feb  2 19:21 ..
-rw-r--r--  1 richard  staff   217B Feb  2 19:21 DEMOG-0.0.1.cql
~/src/github.com/cqframework/cqf-tooling [master|✔]
$ java -jar /Users/richard/Downloads/tooling-1.3.0-jar-with-dependencies.jar -CqlToR4Library -ptld=/Users/richard/src/github.com/intrahealth/madx-hiv/input/pagecontent/cql
Exception in thread "main" java.lang.IllegalArgumentException: The path to the CQL Content is required
    at org.opencds.cqf.tooling.library.BaseLibraryGenerator.buildArgs(BaseLibraryGenerator.java:118)
    at org.opencds.cqf.tooling.library.BaseLibraryGenerator.execute(BaseLibraryGenerator.java:52)
    at org.opencds.cqf.tooling.Main.main(Main.java:159)

view this post on Zulip JP (Feb 03 2021 at 18:20):

Looks like the docs are a bit out of date:

java -jar /Users/richard/Downloads/tooling-1.3.0-jar-with-dependencies.jar -CqlToR4Library -ptcql=/Users/richard/src/github.com/intrahealth/madx-hiv/input/pagecontent/cql -op=/Users/richard/src/github.com/intrahealth/madx-hiv/input/resources/library

Make sure the output folder exists before running the command.

view this post on Zulip Richard Stanley (Feb 04 2021 at 16:36):

:+1:

view this post on Zulip Richard Stanley (Feb 04 2021 at 21:00):

Thanks for the guidance. It runs without error to stdout but the library resource is not created. Output is named all-libraries-bundle.json and content is:

{
  "resourceType": "Bundle"
}

I don't think it's an issue with the CQL. I've confirmed that the CQL can be converted to ELM without errors. Here it is:

library DEMOG version '0.0.1'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1'

context Patient

define "Initial Population":
    Patient.gender = 'female'

define "Denominator":
    'Initial Population'

Edit: I can reproduce the same output using the cqframework/sample-content-ig repo.

view this post on Zulip Bryn Rhodes (Feb 04 2021 at 22:33):

You need to have the "skeleton" library resource available, like this example in the sample-ig: https://github.com/FHIR/sample-ig/blob/master/input/examples/Library-example.json

view this post on Zulip Bryn Rhodes (Feb 04 2021 at 22:33):

That link in the "content.id" element is how it knows which library file to package in which library resource. Does that help?

view this post on Zulip Bryn Rhodes (Feb 04 2021 at 22:34):

In other words, it won't automatically create a Library resource, it needs the basic information to be present (and won't overwrite anything that's in that source resource that isn't generated by the tooling)

view this post on Zulip Richard Stanley (Feb 04 2021 at 23:01):

Ok, thanks. I'll have a try. Does that template need also apply to the Measure generation? I've also seen an error "Could not load source for library FHIRHelpers", which I must be putting in the wrong place and it's not being found.

view this post on Zulip Richard Stanley (Feb 05 2021 at 01:27):

So, I've tried putting FHIR Helpers as CQL in the folders, or as /Library. It's still Could not load source for library FHIRHelpers, version 4.0.1 Where must it be?

view this post on Zulip Bryn Rhodes (Feb 05 2021 at 01:52):

All the CQL sorce resolves from the same cql folder. Are you running the cqf-tooling or the publisher?

view this post on Zulip Richard Stanley (Feb 05 2021 at 17:42):

I'm using the cqf-tooling. I can try publisher to create Library resources as well.

view this post on Zulip Dave Carlson (Feb 05 2021 at 19:26):

HI @Bryn Rhodes can you clarify the relationship and overlap between cqf-tooling and publishing tools? Hoping that they share common components/code, e.g. for populating Libraries. Can these tools be used in combination for complementary behavior? The cqf-tooling appears to have a helpful feature to create bundles of the outputs (library, valueset, plandef, etc) for posting to CQF Ruler. I'd like to do the same with publisher outputs for cpg-on-fhir and CDS.

view this post on Zulip JP (Feb 05 2021 at 19:34):

Yes, the cqf-tooling and the IG publisher can be used together for complementary behavior. This is how the Connectathon IG is built:

https://github.com/DBCG/connectathon/tree/master/fhir401

First, the cqf-tooling is run which produces the Bundles, among other things, and then the IG publisher is run to produce the complete IG. The main overlap in their behavior is the fact that they can both translate CQL and produce Library resources. If the cqf-tooling is used, it does that. If the additional features of the cqf-tooling are not needed just the IG publisher can be used.

view this post on Zulip Dave Carlson (Feb 05 2021 at 19:44):

Thanks JP. I saw this during the connectathon and did a very quick initial test. I found one disconnect where cqf-tooling expected to find CQL under input/pagecontent, whereas the publisher expects under /input/cql (which is my preference for IG content).

view this post on Zulip JP (Feb 05 2021 at 19:49):

Yes, the cqf-tooling is currently hard-coded for input/pagecontent/cql/. There's an issue tracking that here:

https://github.com/cqframework/cqf-tooling/issues/95

We expect to make that configurable or derive it from the IG resource.


Last updated: Apr 12 2022 at 19:14 UTC