@cqframework/cql
v5.3.0
Published
JavaScript tools for the Clinical Quality Language (CQL).
Readme
CQL.js
JavaScript tools for the Clinical Quality Language (CQL).
Installation
npm install @cqframework/cqlUsage
@cqframework/cql is an ESM package. You can
use it in Node.js and the browser (both on the main thread and in web workers).
Compiling CQL to ELM
import { CqlTranslator, LibraryManager, ModelManager } from "@cqframework/cql/cql-to-elm";
const modelManager = new ModelManager();
// Register the necessary model info providers with the model manager here
const libraryManager = new LibraryManager(modelManager);
// Register the necessary library source providers with the library manager here
const cqlTranslator = CqlTranslator.fromText("library Example version '1.0.0'", libraryManager);
const elmJson = cqlTranslator.toJson();Evaluating ELM
import { CqlEngine, Environment, EvaluationParams } from "@cqframework/cql/engine";
const environment = new Environment(libraryManager);
const engine = new CqlEngine(environment);
const exampleLibraryParamsBuilder = new EvaluationParams.LibraryParams.Builder();
// To evaluate specific expressions and not the entire Example library, use `exampleLibraryParamsBuilder.expressionsByName(...)` here
const exampleLibraryParams = libraryParamsBuilder.build();
const evaluationParamsBuilder = new EvaluationParams.Builder();
evaluationParamsBuilder.libraryByName("Example", exampleLibraryParams);
const evaluationParams = evaluationParamsBuilder.build();
const evaluationResults = engine.evaluate(evaluationParams);TypeScript support
The TypeScript definitions included in this package are automatically generated from the Kotlin code. The generator is currently experimental, so the types may not be perfect.
Project status
This package is built from the Kotlin Multiplatform source which itself evolved from the reference Java implementation. The KMP project targets the JVM and JavaScript environments with the goal of maintaining a single, shared codebase for both platforms.
This new JavaScript target is currently in beta and its API may change in future releases. If you encounter any issues, please report them on GitHub or Zulip.
