Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/.gradle
/node_modules
.DS_Store
coverage
5 changes: 5 additions & 0 deletions CREATING-TEST-CASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Each YAML file in the `tests` folder is a separate test case. Each file has the
* **externalData**: A YAML [array](https://yaml.org/spec/1.2/spec.html#id2802662) of the names of other YAML files which may contain [anchored](https://yaml.org/spec/1.2/spec.html#id2785586) resource definitions which can be referenced below under the `data` section. See "Reusing Resources" below for more information.
* **data**: A sequence (i.e., array) of the resource instances making up the test case (with the `Patient` resource as the first one). Can include YAML references to anchored resources defined in any YAML files listed under the `externalData` section.
* **results**: A hash (i.e. object) for which each key corresponds to a CQL expression name and the value is the _expected_ result for that CQL expression.
* **skip**: Skip test case if true (optional, default false).
* **only**: Only run this test case if true (optional, default false).
* **parameters**: A hash (i.e. object) for which each key corresponds to a CQL library parameter name and the value is the input for execution. (optional, default none).

The following is a very simple example of a test case for a fictional CQL library with inclusion criteria that the patient must be male, over 18, and have an Opiod prescription on record. It sets up test data for a 40 year-old male with an Oxycodone prescription and specifies that the `MeetsInclusionCriteria` CQL expression should evaluate to `true`.

Expand Down Expand Up @@ -211,6 +214,8 @@ results:
# The following indicates that these outputs should be arrays of length 1
ThirdCqlExpression: $should have length 1
FourthCqlExpression: $should have length 1
# The following indicates that the output should contain a JSON subset, needs to be properly quoted and valid JSON
FifthCqlExpression: "$should include {\"LookbackPeriod\": 90}"
```

Currently only the `exist` and `have length` methods are supported.
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ The following configuration parameters are currently supported:
* **dumpFiles**:
* **enabled**: Indicates if test data and actual results should be dumped to files for debugging or testing; supports bundles, CQL Hooks requests, and Postman collections of CQL Hooks requests _(optional, boolean, default: false)_
* **path**: The file path to dump files to, if enabled _(optional, string, default: dump\_files)_
* **skip**: Skip test folder if true _(optional, boolean, default: false)_.
* **only**: Only run this test folder if true _(optional, boolean, default: false)_.

All file paths are relative to the location of the `cqlt.yaml` configuraton file unless the file path is absolute.

Expand Down Expand Up @@ -289,6 +291,30 @@ CQLT Config: /path/to/my/cql/project/test/cqlt.yaml

```

## Generating CQL library coverage reports

Test coverage reports describing total number of expressions in the library, number of covered expressions, and list of uncovered expressions can be generated using the custom Mocha coverage reporter. Setup the additional script `test:coverage` in `package.json` as below. The reporter exports lcov formatted files and HTML to the `coverage` folder.

```json
{
"name": "my-cql-project",
"version": "1.0.0",
"scripts": {
"test": "./node_modules/.bin/mocha --reporter spec --recursive",
"test:coverage": "./node_modules/.bin/mocha --reporter ./src/exporters/coverage.js --recursive"
},
"devDependencies": {
"mocha": "^5.2.0",
"cql-testing": "^1.0.0",
"cql-execution": "^1.3.7"
}
}
```

```sh
$ npm run test:coverage
```

## Generating FHIR Documentation

The _FHIR_DSTU2.md_ and _FHIR_STU3.md_ documentation files are generated using the FHIR specification definitions and the corresponding _config.yaml_ files (in _src/fhir/${version}/_). Developers working on the CQL Testing Framework (i.e., developing the framework itself) can regenerate the documentation using the following command:
Expand Down
38 changes: 35 additions & 3 deletions bin/cql2elm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ const { platform, argv, cwd } = require('process');
const { join, resolve, sep } = require('path');
const { exec } = require('child_process');

// ANSI escape codes for colors
const GREEN = '\x1b[32m';
const RED = '\x1b[31m';
const YELLOW = '\x1b[33m';
const RESET = '\x1b[0m';

// List of strings to check for non-error output piped to stderr
const greenPrefixes = ['================================================================================',
'TRANSLATE ',
'Translation completed successfully.', 'ELM output written to: '];
const yellowPrefixes = ['Translation completed with messages:', 'Warning:'];

let exeCmd = platform == 'win32' ? 'gradlew.bat' : './gradlew';

let inputArgs = argv;
Expand All @@ -20,12 +32,32 @@ exec(
cwd: resolve(join(__dirname, '..'))
},
(error, stdout, stderr) => {
// Handle any errors from exec
if (error) {
console.error(error);
return;
}
// eslint-disable-next-line no-console
console.log(stdout);
console.error(stderr);

// Output stdout in green
if (stdout) {
process.stdout.write(`${GREEN}${stdout}${RESET}`);
}

// Handle stderr
if (stderr) {
const stderrLines = stderr.toString().split('\n');
stderrLines.forEach(line => {
if (greenPrefixes.some(prefix => line.startsWith(prefix))) {
// Output lines starting with specified prefixes in green
process.stderr.write(`${GREEN}${line}${RESET}\n`);
} else if (yellowPrefixes.some(prefix => line.startsWith(prefix))) {
// Output warnings in yellow
process.stderr.write(`${YELLOW}${line}${RESET}\n`);
} else if (line.trim()) {
// Output other stderr data in red
process.stderr.write(`${RED}${line}${RESET}\n`);
}
});
}
}
);
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading