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-exec-fhir

v2.1.5

Published

Provides a FHIR-based data source for use w/ CQL

Downloads

4,872

Readme

CQL Execution FHIR Data Source

This project establishes a FHIR-based data source module for use with the CQL Execution Engine. Currently, FHIR 1.0.2 (DSTU2), FHIR 3.0.0 (STU3), FHIR 4.0.0 ,and FHIR 4.0.1 (R4) are supported.

Setting Up the Environment

To use this project, you should perform the following steps:

  1. Install Node.js
  2. Execute the following from this project's root directory: npm install

Using the FHIR Patient Data Source

The FHIR Data Source expects each patient to be represented as a single FHIR Bundle containing all of the patient's relevant data. The FHIR Data Source does not query FHIR servers, but rather, expects the Bundles to be passed to it.

The following is a simple example of how it would be used to execute over two patients:

const cqlfhir = require('cql-exec-fhir');

// Code setting up the CQL library, executor, etc, and getting the patient data as a bundle
// ...

const patientSource = cqlfhir.PatientSource.FHIRv401(); // or .FHIRv102() or .FHIRv300() or .FHIRv400()
patientSource.loadBundles([patient01, patient02]);
const results = executor.exec(patientSource);

(Optional) Trusted Environment with meta.profile

NOTE: This feature will only work with cql-execution version 2.4.1 or higher.

If desired, the FHIR Data Source can be configured to use the meta.profile list on FHIR resources as a source of truth for whether or not that resource should be included when looking through the Bundle of data.

const cqlfhir = require('cql-exec-fhir');

// Including "requireProfileTagging: true" in an object passed in to the constructor enables the trusted environment
const patientSource = cqlfhir.PatientSource.FHIRv401({
  requireProfileTagging: true,
}); // or .FHIRv102() or .FHIRv300() or .FHIRv400()

As an example, if an ELM Retrieve expression asks for a FHIR Condition Resource with profile http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition-encounter-diagnosis, the default behavior of the FHIR Data Source is to find any FHIR Condition resource. With the trusted environment enabled however, the FHIR Data Source will only find resources with the string 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-condition-encounter-diagnosis' included in their meta.profile lists.

Using the FHIRWrapper

If you are passing in individual FHIR resources to the execution engine as parameters, you can use FHIRWrapper to convert the raw json FHIR resources into FHIRObjects that work with the execution engine.

Example:

const cqlfhir = require('cql-exec-fhir');
const fhirWrapper = cqlfhir.FHIRWrapper.FHIRv401(); // or .FHIRv102() or .FHIRv300() or .FHIRv400()

const conditionRawResource = { "resourceType": "Condition", "id": "f201", "clinicalStatus": "active", ... }
const conditionFhirObject = fhirWrapper.wrap(conditionResource)
// Now conditionFhirObject can be passed into the cql execution engine

Testing the Code

To run the automated unit tests, execute the following command:

$ npm test

Linting the Code

To encourage quality and consistency within the code base, all code should pass eslint without any warnings. Many text editors can be configured to automatically flag eslint violations. We also provide an npm script for running eslint on the project. To check your code against eslint's rules, execute the following command:

$ npm run lint

To automatically fix code that violates eslint's rules:

$ npm run lint:fix

Prettier

To encourage quality and consistency within the code base, all code should also be formatted using Prettier. Many text editors can be configured to automatically reformat code using Prettier on save. We also provide an npm script for running prettier on the project. To check your code against Prettier's rules, execute the following command:

$ npm run prettier

To automatically fix any code that violates Prettier's rules:

$ npm run prettier:fix

Altogether Now!

To run the unit tests, linter, and prettier all in one shot, execute the following command:

$ npm run test:plus