Simplified recommendations for use by demonstration applications to illustrate the Clinical Practice Guidelines implementation guide.
The recommendations in this implementation guide are intentionally not clinical to allow demonstration applications to focus on the infrastructural support for performing activities as part of guideline-directed care.
Each recommendation has CQL logic in input/cql/ and test cases in input/tests/Library/<Library>/<TestCase>/. Every test case folder holds a Patient (with the same id as the folder) and the resources that make up its scenario:
| Library | Test case | Expected |
|---|---|---|
| DailyAppleLogic | NeedsDailyAppleOrder | Daily apple proposed |
| HasDailyAppleOrder, RefusedDailyAppleOrder | Nothing proposed | |
| SpoonfulOfSugarLogic | NeedsSpoonfulOfSugar | Spoonful of sugar proposed |
| DoesNotNeedSpoonfulOfSugar, HasSpoonfulOfSugar, RefusedSpoonfulOfSugar | Nothing proposed |
Whenever you change the resources in input/tests, run node bin/build-test-bundles.js (requires Node.js 18 or later). It regenerates the example bundles (input/examples/Bundle-<TestCase>.json, which end up in the FHIR package), their entries in input/cpg-example.xml (which give them a name and description in the IG), and the request bodies of the Postman collection. Commit the results.
-
Check out this repository.
-
Open it in VS Code and install the CQL extension.
-
Right-click a CQL file in
input/cql/and choose Execute CQL. The library is evaluated against each of its test cases (every folder underinput/tests/Library/<Library>/), and the value of eachdefineper test case is written toinput/tests/results/<Library>.txt. Use Execute CQL - Select Test Cases to run only some of them.
The FHIR server and cpg-review below run in Docker.
-
Install Docker Desktop (macOS, Windows, Linux), or Docker Engine on Linux.
-
Start Docker Desktop and wait until it reports that the engine is running.
-
Check that it works:
docker run --rm hello-world
-
Start a HAPI FHIR server with the clinical reasoning module (which provides
$apply):docker pull hapiproject/hapi:latest docker run -p 8080:8080 -e hapi.fhir.cr.enabled=true hapiproject/hapi:latest
Leave it running in this terminal. Startup takes a minute or so; it's ready when http://localhost:8080/fhir/metadata returns a CapabilityStatement. The server keeps its data only as long as the container exists, so after starting a new container, load the resources again (step 3). Stop it with Ctrl+C.
-
Build the IG, so
output/contains the Libraries with compiled CQL. On macOS/Linux run./_updatePublisher.shonce, then./_genonce.sh; on Windows run_updatePublisher.batonce, then_genonce.bat. Openoutput/index.htmlin a browser to see the IG, for example the Artifact Index: -
Load the conformance resources (CodeSystem, ValueSets, Libraries, ActivityDefinitions, PlanDefinitions), using Node.js 18 or later:
node bin/load-fhir-server.js # optionally pass a base URL, default http://localhost:8080/fhirDo not load the test data: each request passes its test case inline, and a patient that is also stored on the server is seen twice, which makes the CQL fail.
-
Import
postman/CPG-Example.postman_collection.jsoninto Postman and run the collection. Each request callsPlanDefinition/$applyfor one test case and checks that it proposes (or doesn't propose) the expected activity. From the command line:postman collection run postman/CPG-Example.postman_collection.json.
cpg-review, part of the Reason Framework, visualizes a PlanDefinition and runs $apply for a selected patient.
-
Start the HAPI FHIR server and load the conformance resources as described above. cpg-review uses it as the CPG engine and content endpoint.
-
In a new terminal, build and start cpg-review from a checkout of the Reason Framework:
git clone https://github.com/reason-healthcare/reason-framework.git cd reason-framework docker build -f packages/cpg-review/Dockerfile -t reason-framework-cpg-review:latest . # once, and again after pulling updates docker run --rm --name reason-cpg-review --add-host=host.docker.internal:host-gateway -p 3000:3000 reason-framework-cpg-review:latest
(On macOS/Linux,
./bin/docker-build-cpg-reviewand./bin/docker-run-cpg-reviewdo the same.) Open http://localhost:3000. If port 3000 is taken, use e.g.-p 3001:3000and open port 3001 instead. The default endpoints (http://localhost:8080/fhir) point at the HAPI server; the container reaches it throughhost.docker.internal. Stop it with Ctrl+C. -
Build the IG with
./_genonce.sh(Windows:_genonce.bat). -
Upload
output/package.tgz, pick a PlanDefinition, and under Add Context pick one of the test case bundles from the package as the patient. Then apply.



