npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cql-worker

v1.1.7

Published

A library for executing Clinical Quality Language (CQL) expressions asynchronously via web workers or node worker threads.

Downloads

19

Readme

CQL Worker

A library for executing Clinical Quality Language (CQL) expressions asynchronously via Web Workers. This allows web applications to evaluate CQL expressions in a non-blocking manner. For examples where this can be useful, see the Alcohol Screening and Brief Intervention (ASBI) Clinical Decision Support (CDS) Screening and Intervention apps.

Underlying Technologies

CQL Execution Engine

All CQL calculations are executed using the CQL Execution Engine, an open source library that implements the CQL standard.

FHIRHelpers

FHIRHelpers is a library that defines functions for converting between FHIR and CQL data types. cql-worker includes version 4.0.1 of FHIRHelpers, which is available under an Apache 2.0 License, Copyright 2014 The MITRE Corporation. Other versions of FHIRHelpers can be found here.

CQL Execution FHIR Data Source

The cql-exec-fhir is used to provide a FHIR-based data source for use with the CQL Execution Engine.

Web Workers

Web Workers provide a means to offload CQL expression calculations to a separate thread from within the browser.

Node Worker Threads

Node Worker Threads are similar to Web Workers but are for use in the Node.js runtime environment.

Current Limitations

CQL Workers has been tested with the following environments and build tools:

  • [x] Browser with Webpack 4 using worker-loader.
  • [ ] Webpack 5 supposedly has better support for Web Workers but also includes several breaking changes when it comes to bundling Node.js applications for the web browser. CQL Worker should work with Webpack 5, but it has not been tested. Please open an issue if you run into any problems.
  • [x] Node.js has been tested, but be sure to set the isNodeJs flag to true.

Example Usage

CQL Worker is published on npm and can be installed via: npm install cql-worker.

Browser with Webpack 4

// See: https://github.com/webpack-contrib/worker-loader
import Worker from "<PATH-TO-NODE-MODULES>/cql-worker/src/cql.worker.js";
import { initialzieCqlWorker } from 'cql-worker';

// Define a web worker for evaluating CQL expressions
const cqlWorker = new Worker();

// Initialize the cql-worker
let [setupExecution, sendPatientBundle, evaluateExpression] = initialzieCqlWorker(cqlWorker);

// Define `elmJson`, `valueSetJson`, `cqlParameters`, and `elmJsonDependencies`

// Send the cqlWorker an initial message containing the ELM JSON representation of the CQL expressions
setupExecution(elmJson, valueSetJson, cqlParameters, elmJsonDependencies);

// Create `patientBundle` to hold the patient's FHIR resources

// Send the patient bundle to the CQL web worker
sendPatientBundle(patientBundle);

// Define `namedExpression`, a string containing the name of a CQL expression

let result = await evaluateExpression(namedExpression);

See the ASBI CDS Screening and Intervention apps for additional information for how to configure Webpack to properly package cql-worker.

Node.js

Using CQL Workers with Node.js requires enabling the --experimental-json-modules flag.

import { Worker } from 'worker_threads';
import { initialzieCqlWorker } from 'cql-worker';
import { createRequire } from 'module';
const require = createRequire(import.meta.url);

let cqlWorker = new Worker(require.resolve('cql-worker/src/cql-worker-thread.js'));
let [setupExecution, sendPatientBundle, evaluateExpression] = initialzieCqlWorker(cqlWorker, true);

// Define `elmJson`, `valueSetJson`, and `cqlParameters`

setupExecution(elmJson, valueSetJson, cqlParameters, elmJsonDependencies);

// Create `patientBundle` to hold the patient's FHIR resources

sendPatientBundle(patientBundle);

// Define `namedExpression`, a string containing the name of a CQL expression

let result = await evaluateExpression(namedExpression);

License

(C) 2021 The MITRE Corporation. All Rights Reserved. Approved for Public Release: 20-0458. Distribution Unlimited.

Unless otherwise noted, this work is available under an Apache 2.0 license. It was produced by the MITRE Corporation for the National Center on Birth Defects and Developmental Disabilities, Centers for Disease Control and Prevention in accordance with the Statement of Work, contract number 75FCMC18D0047, task order number 75D30119F05691.