Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.opencds.cqf.fhir.cr.measure.r4;

import org.junit.jupiter.api.Test;
import org.opencds.cqf.fhir.cr.measure.common.MeasurePopulationType;
import org.opencds.cqf.fhir.cr.measure.r4.Measure.Given;

/**
* Integration-style test for a cohort Measure whose stratifier is driven by a CQL expression that
* returns the Patient id ({@code define PatientIdStratifier: Patient.id.value}).
*
* <p>There are 5 patients in the repository, but the initial population CQL only selects the 3
* female patients. A "population" (Summary) report still evaluates the stratifier for every subject,
* so each patient id gets its own stratum: the 3 patients in the initial population have a count of
* 1, and the 2 excluded patients have a count of 0.
*/
@SuppressWarnings("squid:S2699")
class MeasurePatientIdStratifierTest {

private static final Given GIVEN_FEASIBILITY = Measure.given().repositoryFor("FeasibilityMeasure");

@Test
void cohortPatientIdStratifierPopulationReportOneStratumPerPatient() {
GIVEN_FEASIBILITY
.when()
.measureId("FeasibilityMeasure")
.reportType("population")
.evaluate()
.then()
.hasReportType("Summary")
.firstGroup()
// Only the 3 female patients are in the cohort's initial population.
.population(MeasurePopulationType.INITIALPOPULATION)
.hasCount(3)
.up()
.hasStratifierCount(1)
.firstStratifier()
.hasCodeText("PatientIdStratifier")
// Every evaluated patient id gets its own stratum, including the 2 not in the population.
.hasStratumCount(5)
// The 3 patients in the initial population each have a count of 1.
.stratumByComponentValueText("patient-1")
.hasComponentValueText("patient-1")
.population(MeasurePopulationType.INITIALPOPULATION)
.hasCount(1)
.up()
.up()
.stratumByComponentValueText("patient-3")
.hasComponentValueText("patient-3")
.population(MeasurePopulationType.INITIALPOPULATION)
.hasCount(1)
.up()
.up()
.stratumByComponentValueText("patient-5")
.hasComponentValueText("patient-5")
.population(MeasurePopulationType.INITIALPOPULATION)
.hasCount(1)
.up()
.up()
// The 2 male patients are excluded from the population, so their strata have a count of 0.
.stratumByComponentValueText("patient-2")
.hasComponentValueText("patient-2")
.population(MeasurePopulationType.INITIALPOPULATION)
.hasCount(0)
.up()
.up()
.stratumByComponentValueText("patient-4")
.hasComponentValueText("patient-4")
.population(MeasurePopulationType.INITIALPOPULATION)
.hasCount(0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
library FeasibilityMeasure version '1.0.0'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1' called FHIRHelpers

context Patient

// Only female patients qualify, so 3 of the 5 patients land in the initial population.
define "InitialPopulation":
Patient.gender = 'female'

define "PatientIdStratifier":
Patient.id.value
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"resourceType": "Library",
"id": "FeasibilityMeasure",
"url": "https://research.balgrist.ch/Library/FeasibilityMeasure",
"version": "1.0.0",
"name": "FeasibilityMeasure",
"status": "active",
"type": {
"coding": [ {
"system": "http://terminology.hl7.org/CodeSystem/library-type",
"code": "logic-library"
} ]
},
"content": [ {
"contentType": "text/cql",
"url": "../../cql/FeasibilityMeasure.cql"
} ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"resourceType": "Measure",
"id": "FeasibilityMeasure",
"url": "https://research.balgrist.ch/Measure/FeasibilityMeasure",
"version": "1.0.0",
"name": "FeasibilityMeasure",
"title": "Patient and Imaging Study Feasibility Measure",
"status": "active",
"description": "Counts patients matching specified demographic and imaging study inclusion/exclusion criteria.",
"library": [
"https://research.balgrist.ch/Library/FeasibilityMeasure|1.0.0"
],
"extension": [
{
"url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-populationBasis",
"valueCode": "boolean"
}
],
"scoring": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/measure-scoring",
"code": "cohort",
"display": "Cohort"
}
]
},
"group": [
{
"id": "feasibility-cohort",
"population": [
{
"id": "initial-population",
"code": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/measure-population",
"code": "initial-population",
"display": "Initial Population"
}
]
},
"criteria": {
"language": "text/cql-identifier",
"expression": "InitialPopulation"
}
}
],
"stratifier": [
{
"id": "patient-id-stratifier",
"code": {
"text": "PatientIdStratifier"
},
"component": [
{
"id": "patient-id-stratifier-component",
"code": {
"text": "PatientId"
},
"criteria": {
"language": "text/cql-identifier",
"expression": "PatientIdStratifier"
}
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"resourceType": "Patient",
"id": "patient-1",
"gender": "female",
"birthDate": "1980-05-12"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"resourceType": "Patient",
"id": "patient-2",
"gender": "male",
"birthDate": "1975-11-03"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"resourceType": "Patient",
"id": "patient-3",
"gender": "female",
"birthDate": "1990-02-20"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"resourceType": "Patient",
"id": "patient-4",
"gender": "male",
"birthDate": "1968-07-30"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"resourceType": "Patient",
"id": "patient-5",
"gender": "female",
"birthDate": "2001-09-14"
}
Loading