CQL to ELM in JS

The Clinical Quality Language (CQL) is a language for computable clinical knowledge, used in quality measures and decision support tools.

Behind CQL's high-level, human-readable syntax is the Expression Logical Model (ELM). This model/formalism represents the CQL logic in a structured, machine-friendly way—in which it can be consumed by CQL engines (ELM engines).

The original (reference) implementation of a CQL-to-EML compiler/translator is written in Java and therefore requires a Java runtime to run. This means that if you want to do anything with CQL (except maybe syntax highlighting and ANTLR-based parsing), you need to have a Java backend that runs the CQL-to-ELM converter.

To make it possible to convert CQL to ELM in the browser (and make it easier to work with CQL in JavaScript), I've ported the Java source of the CQL-to-ELM compiler to JS using Google's J2CL (live demo below). To make it all work, I had to make some changes to the codebase and supersource/polyfill the Java classes that are not implemented by J2CL. Some functionalities like model info and library loading were also adapted to fit the browser environment.

The interactive demo below uses the JavaScript version of the CQL-to-ELM translator and runs entirely on the client. You can type the CQL code and see the equivalent ELM JSON generated in real time.

Demo: CQL-to-ELM in the browser

See also

Made by Anton Vasetenkov.

If you want to say hi, you can reach me on LinkedIn or via email. If you like my work, you can support me by buying me a coffee.