Stream: cql
Topic: cql in atom for beginners
Vasyl Herman (Jan 25 2021 at 10:07):
Hello guys. I would appreciate any help to understand how cql works in Atom.
- I have downloaded Atom and installed the language-cql package, Java 1.8 as required here
- Next, the documentation says that I need to open any .cql file and have the following directories:
input/cql
input/tests
input/tests/<cql-library-name>
input/tests/<cql-library-name>/<patient-id>
input/tests/<cql-library-name>/<patient-id>/<resource-type-name>/<resource files>
input/vocabulary/codesystem
input/vocabulary/valueset
I am trying to understand how it works but I don't know where I can take the files from? resource files, codesystem, valueset and the .cql itself.
I am guessing I can get resource files form a HAPI FHIR server, but I need help on how to...
- Using [base]/Patient/[id]/$everything request ? but what if I have a 1 000 000 000 Patients ?
- Or using fhir-downloader
Is there a git repo starter or something to help?
JP (Jan 25 2021 at 19:44):
The Connectathon repository is the most up-to-date I think. Open the fhir401 folder as the root folder. You should then be able to execute an open CQL file with F5. There a sample resources that are already in the appropriate directory structure as well.
https://github.com/DBCG/connectathon/tree/master/fhir401
Richard Stanley (Jan 29 2021 at 19:01):
Hi folks. May I as what is the flexibility around the folder structure required for the Atom CQL runner? I see different examples of folder/file structures (I prefer the IG approach):
- /tests in cqframework/atom_cql_support: /tests/cql/<FHIR Version>
- DBCG/connectathon: nests cql folder under page
/input/pagecontent
while resources are ../ - framework/content-ig-walkthrough: as specified by the runner except that resource type folders are not used.
- cqframework/CQL-Formatting-and-Usage-Wiki (Cooking with FHIR examples): Every resource in one folder.
Vasyl Herman (Jan 30 2021 at 08:14):
I still can't figure out how it works.
Bryn Rhodes (Jan 30 2021 at 16:54):
The Atom plugin supports a variety of folder setups because we have evolved the best-practice over time but tried to maintain backwards compatibility to avoid forcing changes on existing IGs. The current best-practice is consistent with the IG layout and is described in the Atom Plugin Repository readme here: https://github.com/cqframework/atom_cql_support/blob/master/README.md#using-the-cql-support-in-atom
Bryn Rhodes (Jan 30 2021 at 16:57):
Specifically, the resources in each test case can be organized into folders for each resource type, or they can all be included in the same folder. We've also added support for providing the resources as bundles (including nested bundles). Basically, when evaluating, for each test case, the evaluator will attempt to load every .xml or .json file in the test case folder and any sub-folders, recursively. If the resource is a Bundle, the resources in the bundle are loaded, recursively.
Bryn Rhodes (Jan 30 2021 at 16:57):
Hopefully that helps?
Richard Stanley (Jan 30 2021 at 19:11):
Perfect, thanks. That helps a lot.
Tien Thai (Feb 09 2021 at 16:02):
How would you generate the JSON files that go under the input/vocabulary/codesystem and input/vocabulary/valueset folders? Thank you.
TT
JP (Feb 09 2021 at 17:32):
Hi Tien,
The files that are under the input/vocabulary
folders are standard FHIR ValueSet and CodeSystem resources and they can be XML or JSON. Depending on the source of your terminology you have several options for creating those files. Using a FHIR terminology server like Apelon you can simply download the FHIR resources from the server after you've authored them. If you're using ValueSets from VSAC the cqf-tooling has a operation that will convert the spreadsheets into ValueSets:
If you're creating some simple terminology for test cases it's easiest to just hand-code the resources. I've also had success using FSH and SUSHI. There are some examples you can use as a pattern to start with here:
https://www.hl7.org/fhir/valueset-example.json.html
As well as more complete "real world" examples in the opioid-cds and connectathon IGs:
https://github.com/cqframework/opioid-cds-r4/tree/master/input/vocabulary/valueset
https://github.com/DBCG/connectathon/tree/master/fhir401/input/vocabulary/valueset
Tien Thai (Feb 09 2021 at 18:47):
@JP, thanks so much for your helpful info.
TT
Tien Thai (Feb 09 2021 at 20:37):
hi JP,
Are you familiar with the following error? Thank you.
Unknown lifecycle phase ".args=-VsacXlsxToValueSet -pts=ep_ec_eh_unique_vs_20190510.xlsx". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy.
JP (Feb 09 2021 at 22:14):
Easiest thing to do is mvn package
. You then have a jar you can execute:
java -jar ./target/tooling-1.3.1-SNAPSHOT-jar-with-dependencies.jar -VsacXlsxToValueSet -pts= ep_ec_eh_unique_vs_20190510.xlsx -op=./valuesets -e=json
JP (Feb 09 2021 at 22:16):
There's also a batch mode:
java -jar ./target/tooling-1.3.1-SNAPSHOT-jar-with-dependencies.jar -VsacXlsxToValueSetBatch -ptsd=./spreadsheets -burl="http://cts.nlm.nih.gov/fhir/ValueSet/" -setname=true
Vasyl Herman (Feb 20 2021 at 13:31):
JP said:
The Connectathon repository is the most up-to-date I think. Open the fhir401 folder as the root folder. You should then be able to execute an open CQL file with F5. There a sample resources that are already in the appropriate directory structure as well.
Thanks! Finally I got it up and running. I just have executed fhir401/input/pagecontent/cql/EXM74-10.2.000.cql
file.
Can I ask you if it possible to translate EXM74-10.2.000.cql
to ELM within Atom and the cql package or any other ways?
I have tried cql-translation-service but it gives me an error:
"Could not load source for library MATGlobalCommonFunctions, version 5.0.000."
image.png
Vasyl Herman (Feb 20 2021 at 13:35):
I am trying to repeat the experiment (EXM74-10.2.000.cql) with cql-exec-fhir
and cql-exec-vsac
libraries, at this point I got stuck on translating cql to elm.
JP (Feb 20 2021 at 17:04):
Can I ask you if it possible to translate EXM74-10.2.000.cql to ELM within Atom and the cql package or any other ways?
Yes, do can do a "default" (i.e. you can't set any special translator options) by right-clicking in an open CQL file and selecting CQL -> View ELM. It's not meant for embedding into a Library resource or anything but it's a quick way to see what ELM would be generated.
The IG Publisher and the cqf-tooling both provide ways to embed ELM into a FHIR Library resource as part of an IG if that's your end goal.
I believe the cql-translation-service supports translating that file, but you have to do a "multi-part" request to upload all the required libraries from the cql
directory:
https://github.com/cqframework/cql-translation-service#multipart-request
If you just looking to translate a bunch of CQL in a directory to ELM, you can use the cql-to-elm translator command line. That's here:
FWIW, the next to-be-released version of the Atom plugin has some basic support for the some of the cqf-tooling operations to make this sort of thing easier.
Vasyl Herman (Feb 22 2021 at 09:10):
@JP Thanks! I am going to try cql-to-elm cli!
David Yak (Feb 23 2021 at 15:11):
New to the board... hello everyone. Are there some troubleshooting steps to get the atom plugin working? I've installed it on two different machines, one MacOS11 and one Windows10. Both show it is installed, and I have the correct java versions installed. I get syntax highlighting but no option to Run the CQL. I suspect some dependency is not being met but I can't tell which one(s).
Richard Stanley (Feb 23 2021 at 15:45):
Hi @David Yak the CQL file must be open and have focus, then right-click and down at about the very bottom should be a menu item for CQL.
Vasyl Herman (Feb 23 2021 at 16:00):
@David Yak
- clone this repo https://github.com/DBCG/connectathon
- open
fhir401
folder in Atom - then open
input\pagecontent\cql\EXM74-10.2.000.cql
file and finally press on F5
Vasyl Herman (Feb 23 2021 at 16:03):
@David Yak
Also make sure language-cql library is installed in Atom
Hope it helps
https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Developers-Introduction-to-CQL
David Yak (Feb 23 2021 at 16:44):
I appreciate the responses. Vasyl when I open that particular cql file I do now see the CQL choice at the bottom of my right-click menu. However View ELM is the only choice. F5 does nothing. Screen shot attached. Yak
Vasyl Herman (Feb 23 2021 at 17:24):
@David Yak Can you please also make sure that language-cql
is installed?
image.png
Vasyl Herman (Feb 23 2021 at 17:27):
Sorry if it doesn't help. I don't remember how I did. I was fighting with Atom for a few days before it started working.
Vasyl Herman (Feb 23 2021 at 17:28):
Probably - Atom, Java, language-cql, that's whole the recipe
David Yak (Feb 23 2021 at 18:06):
I think I've got the right stuff. Screen shot plus java version:
% java --version
openjdk 15.0.1 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9)
OpenJDK 64-Bit Server VM (build 15.0.1+9, mixed mode, sharing)
Vasyl Herman (Feb 23 2021 at 19:20):
On Windows 10
image.png
Chris Moesel (Feb 23 2021 at 19:25):
@David Yak -- I don't think the Java components of the plugin have been developed or tested against Java 15. I thought JDK 11 (LTS) was required, but it looks like @Vasyl Herman has it working w/ JDK 8 -- so probably try one of those.
Richard Stanley (Feb 23 2021 at 19:38):
@David Yak is the JAR file (which should be automagically downloaded by the plugin) in place? On *nix, ls ~/.atom/packages/language-cql/server
and it should be there
David Yak (Feb 23 2021 at 20:16):
I am starting to think this is a java version issue. I'm going to load jenv so I can manage which java is in effect. Answer to above question is yes:
% pwd
/Users/david.yakimischak/.atom/packages/language-cql
% ls -al server
total 93224
drwxr-xr-x 3 david.yakimischak staff 96 Feb 23 11:41 .
drwxr-xr-x 18 david.yakimischak staff 576 Feb 23 11:41 ..
-rw-r--r-- 1 david.yakimischak staff 46827333 Feb 23 11:41 ls-1.5.0-SNAPSHOT-shaded.jar
David Yak (Feb 23 2021 at 20:24):
The java control panel thinks I have the correct version installed. The command line thinks something else.
David Yak (Feb 23 2021 at 21:29):
Does anyone have any troubleshooting steps or things I can try? I have added the Java 1.8 jdk and it is in my $JAVA_HOME and now the CQL choice has disappeared from the bottom of my context menu again. I am trying to read through the plugin source but I can't figure out what it is doing. There are a lot of dependencies in the code in package.json - if some of those were not there or right I would have thought I could see an error log somewhere or get a message telling me what is not right. (Maybe I am defining a project for myself!). Right now I just want to get it running.
JP (Feb 23 2021 at 23:46):
Hi David. I took a look at this and it seems that a dependency is missing from Maven. I'm prepping a fix in the Atom plugin and should have it deployed later today.
JP (Feb 24 2021 at 00:32):
Atom plugin version 2.8.3 is released which includes a fix for the CQL menu not showing up (due to a missing dependency), and fix for that dependency, and some better status / error messages as it's initializing. You should see the option to upgrade in the packages section of Atom's preferences
David Yak (Feb 24 2021 at 12:30):
100% worked immediately. Thanks so much JP. All good now. Yak
David Yak (Jun 09 2021 at 18:54):
@Richard Stanley that directory does not exist in the language-cql folder. I did get this working by following @Vasyl Herman instructions, so thank you very much and sorry it took so long for me to get back and close this off. Once things started working I just plowed ahead and did not look back!
Last updated: Apr 12 2022 at 19:14 UTC