Skip to content

Latest commit

 

History

History
83 lines (55 loc) · 3.94 KB

README.md

File metadata and controls

83 lines (55 loc) · 3.94 KB

Overview

This is a multi-module project for CQL java libraries and tooling applications. It contains the following sub-projects:

  • cql: generates and builds Java lexers, parsers, listeners, and visitors using the CQL ANTLR4 grammar
  • model: generates and builds Java classes based on the ELM Model Info schema and CQL base type system
  • elm: generates and builds Java classes based on the ELM XML schema
  • qdm: contains schema and model info resources for QDM (4.2, 5.0, 5.0.1, 5.0.2, 5.3)
  • quick: contains schema and model info resources for QUICK and FHIR, DSTU2 (1.0.2), and STU3 (1.4, 1.6, 1.8, and 3.0.1)
  • cql-to-elm: generates Expression Logical Model (ELM) XML and JSON from CQL source
  • tools:cql-formatter: formats input CQL based on standard formatting conventions as suggested by the CQL specification
  • tools:cql-parsetree: provides simple command-line access to the debug information for a CQL parse tree
  • tools:xsd-to-modelinfo: generates model info given an XML Schema (XSD) as input

Building the Project

This project uses the Gradle build system. A gradle wrapper, which automatically downloads and uses an instance of gradle, is provided for convenience. To build the project, install the Java SE Development Kit 8 (a.k.a. JDK 1.8), clone this repository, then execute this command from within this directory:

./gradlew build

This will generate and build the ANTLR4 CQL artifacts, the JAXB QUICK artifacts, and the JAXB ELM artifacts. It will also build and test the corresponding code libraries and applications.

To clean up the build artifacts:

./gradlew clean

Generating IDE Projects

You can generate an IDE project for IntelliJ IDEa:

./gradlew idea

In addition to creating project modules for cql, model, quick, elm, cql-to-elm, and the tools projects, this will also import project modules for the CQL grammar and examples.

Executing the Sample Code

You can execute the sample code using the gradlew command or a script generated by gradle.

To execute the sample code using gradlew, you must execute the run command, using the project-specific path. The following are current possibilities:

./gradlew :cql:run
./gradlew :cql-to-elm:run
./gradlew :tools:cql-parsetree:run

To execute the sample code using a script generated by gradle, first generate the scripts:

./gradlew installDist

Then execute the generated script (optionally passing in an argument). The following example executes the sample cql code with the path to a CQL file as an argument:

./cql/build/install/cql/bin/cql ../../Examples/ChlamydiaScreening_CQM.cql

You can also execute the cql-parsetree tool in a similar way:

./tools/cql-parsetree/build/install/cql-parsetree/bin/cql-parsetree ../../Examples/ChlamydiaScreening_CQM.cql

Generate an ELM Representation of CQL Logic

To generate an ELM representation of CQL logic, build and execute the cql-to-elm app:

./gradlew :cql-to-elm:installDist
./cql-to-elm/build/install/cql-to-elm/bin/cql-to-elm --input ../../Examples/ChlamydiaScreening_CQM.cql

The following options are supported:

  • --input or -i: Specify the input CQL file (REQUIRED).
  • --output or -o: Specify the output file. If not specified, the output file will have the same base name and location as the input file. If only a directory is specified, the output file will have the same base name as the input file and be written to the requested directory.
  • --format or -f: Output as XML (default), JSON, or COFFEE.
  • --date-range-optimization or -d: Refactor simple during clauses into the Retrieve.
  • --annotations or -a: Include CQL source annotations in the output.
  • --stdout or -s: Write output to the console instead of a file.

For more information on the CQL-to-ELM translator, refer to the Overview for that project.