@cqframework/cql

中文文档
5.5.0发布于 2026/10/27Apache-2.0TypeScriptES Module近 30 天下载 1.3万

JavaScript tools for the Clinical Quality Language (CQL).

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Compiling CQL to ELM
  4. Evaluating ELM
  5. TypeScript support
  6. Project status

CQL.js

NPM Version

JavaScript tools for the Clinical Quality Language (CQL).

Installation

npm install @cqframework/cql

Usage

@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.

版本与发布记录

@cqframework/cql 共发布 5 个版本,首次发布于 2025/09/25;过去 12 个月发布了 4 个版本。

版本发布日期距今
5.5.0latest2026/10/2714 天前
5.4.02026/10/011 个月前
5.3.02026/09/102 个月前
5.2.02026/08/202 个月前
4.0.0-beta.1beta2025/09/251.1 年前

关于 @cqframework/cql 的常见问题

@cqframework/cql 是什么?

JavaScript tools for the Clinical Quality Language (CQL).

如何安装 @cqframework/cql?

在项目目录运行 npm install @cqframework/cql,或使用 pnpm add / yarn add / bun add。

@cqframework/cql 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cqframework/cql 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cqframework/cql 可以商用吗?

@cqframework/cql 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cqframework/cql 的下载量有多少?

根据 npm 官方下载统计,@cqframework/cql 在 2026/10/11 – 2026/11/09 这 30 天内被下载 12,611 次,日均约 420 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cqframework/cql 还在维护吗?

最新版本 5.5.0 发布于 2026/10/27(14 天前);至今共发布 5 个版本,其中过去 12 个月发布了 4 个;首次发布于 2025/09/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。