From 57cd5299ee7ad996c2004bd067ad52110ebb7c70 Mon Sep 17 00:00:00 2001 From: JP Date: Tue, 14 Feb 2023 12:38:58 -0700 Subject: [PATCH] Updated Clinical Reasoning documentation (#4549) * Updated Clinical Reasoning documentation * Fix some typos --- .../hapi/fhir/docs/clinical_reasoning/cql.md | 19 + .../fhir/docs/clinical_reasoning/measure.md | 387 ++++++++++++++++++ .../fhir/docs/clinical_reasoning/overview.md | 28 ++ .../ca/uhn/hapi/fhir/docs/files.properties | 5 + .../ca/uhn/fhir/cql/r4/CqlProviderR4Test.java | 79 ---- 5 files changed, 439 insertions(+), 79 deletions(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/cql.md create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/measure.md create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/overview.md delete mode 100644 hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/r4/CqlProviderR4Test.java diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/cql.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/cql.md new file mode 100644 index 00000000000..42a4d439a02 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/cql.md @@ -0,0 +1,19 @@ +# CQL + +## Introduction + +Clinical Quality Language (CQL) is a high-level, domain-specific language focused on clinical quality and targeted at measure and decision support artifact authors. HAPI embeds a [CQL engine](https://github.com/cqframework/clinical_quality_language) allowing the evaluation of clinical knowledge artifacts that use CQL to describe their logic. + +A more detailed description of CQL is available at the [CQL Specification Implementation Guide](https://cql.hl7.org/) + +The FHIR [Clinical Reasoning module](http://www.hl7.org/fhir/clinicalreasoning-module.html) defines a set of resources, profiles, operations, etc. that can be used to work with clinical knowledge within FHIR. HAPI provides implementation for some of those operations, described in more detail below. + +## Working Example + +A complete working example of HAPI CQL can be found in the [JPA Server Starter](/hapi-fhir/docs/server_jpa/get_started.html) project. You may wish to browse its source to see how it is set up. + +## Clinical Reasoning Operations + +HAPI provides implementations for some operations using CQL in DSTU3 and R4: + +[Measure Operations](measure.html) diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/measure.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/measure.md new file mode 100644 index 00000000000..b6f52a31d7e --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/measure.md @@ -0,0 +1,387 @@ +# Measures + +## Introduction + +The FHIR Clinical Reasoning Module defines the [Measure resource](https://www.hl7.org/fhir/measure.html) and several [associated operations](https://www.hl7.org/fhir/measure-operations.html). The Measure Resource represents a structured, computable definition of a health-related measure such as a clinical quality measure, public health indicator, or population analytics measure. These Measures can then be used for reporting, analytics, and data-exchange purposes. + +Electronic Clinical Quality Measures (eCQMs) in FHIR are represented as a FHIR Measure resource containing metadata and terminology, a population criteria section, and at least one FHIR Library resource containing a data criteria section as well as the logic used to define the population criteria. The population criteria section typically contains initial population criteria, denominator criteria, and numerator criteria subcomponents, among others. This is elaborated upon in greater detail in the [CQF Measures IG](http://hl7.org/fhir/us/cqfmeasures). An example of an eCQM as defined in FHIR looks like: + +```json +{ + "resourceType" : "Measure", + "library" : [ + "http://hl7.org/fhir/us/cqfmeasures/Library/EXMLogic" + ], + "group" : [ + { + "population" : [ + { + "code" : { + "coding" : [ + { + "code" : "initial-population" + } + ] + }, + "criteria" : { + "language" : "text/cql-identifier", + "expression" : "Initial Population" + } + }, + { + "code" : { + "coding" : [ + { + "code" : "numerator" + } + ] + }, + "criteria" : { + "language" : "text/cql-identifier", + "expression" : "Numerator" + } + }, + { + "code" : { + "coding" : [ + { + "code" : "denominator" + } + ] + }, + "criteria" : { + "language" : "text/cql-identifier", + "expression" : "Denominator" + } + } + ] + } + ] +} + +``` + +Measures are then scored according the whether a subjects (or subjects) are members of the various populations. + +For example, a Measure for Breast Cancer screening might define an Initial Population (via CQL expressions) of "all women", a Denominator of "women over 35", and a Numerator of "women over 35 who have had breast cancer screenings in the past year". If the Measure is evaluated against a population of 100 women, 50 are over 35, and of those 25 have had breast cancer screenings in the past year, the final score would be 50%1 (total number in numerator / total number in the denominator). + +1. There are several methods for scoring Measures, this is meant only as an example. + +## Operations + +HAPI implements the [$evaluate-measure](https://www.hl7.org/fhir/operation-measure-evaluate-measure.html) operation. Support for additional operations is planned. + +## Evaluate Measure + +The `$evaluate-measure` operation is used to execute a Measure as specified by the relevant FHIR Resources against a subject or set of subjects. This implementation currently focuses primarily on supporting the narrower evaluation requirements defined by the [CQF Measures IG](http://hl7.org/fhir/us/cqfmeasures). Some support for extensions defined by other IGs is included as well, and the implementation aims to support a wider range of functionality in the future. + +### Example Measure + +Several example Measures are available in the [ecqm-content-r4](https://github.com/cqframework/ecqm-content-r4) IG. Full Bundles with all the required supporting resources are available [here](https://github.com/cqframework/ecqm-content-r4/tree/master/bundles/measure). You can download a Bundle and load it on your server as a transaction: + +```bash +POST http://your-server-base/fhir BreastCancerScreeningFHIR-bundle.json +``` + +These Bundles also include example Patient clinical data so once posted Measure evaluation can be invoked with: + +```bash +GET http://your-server-base/fhir/Measure/BreastCancerScreeningFHIR/$evaluate-measure?periodStart=2019-01-01&periodEnd=2019-12-31&subject=numerator&reportType=subject +``` + +### Measure Features + +The FHIR Measure specification defines several types of Measures and various parameters for controlling the Measure evaluation. This section describes the features supported by HAPI. + +#### Reporting Period + +The `periodStart` and `periodEnd` parameters are used to control the Reporting Period for which a report is generated. This corresponds to `Measurement Period` defined in the CQL logic, as defined by the conformance requirements in the CQF Measures IG. Both `periodStart` and `periodEnd` must be used or neither must be used. + +If neither are used the default reporting period specified in the CQL logic is used, as shown here + +```cql +parameter "Measurement Period" Interval + default Interval[@2019-01-01T00:00:00.0, @2020-01-01T00:00:00.0) +``` + +If neither are used and there is no default reporting period in the CQL logic an error is thrown. + +A request using `periodStart` and `periodEnd` looks like: + +```bash +GET fhir/Measure//$evaluate-measure?periodStart=2019-01-01&periodEnd=2019-12-31 +``` + +`periodStart` and `periodEnd` support Dates (YYYY, YYYY-MM, or YYYY-MM-DD) and DateTimes (YYYY-MM-DDThh:mm:ss+zz:zz) + +#### Report Types + +Measure report types determine what data is returned from the evaluation. This is controlled with the `reportType` parameter on the $evaluate-measure Operation + +| Report Type | Supported | Description | +|--------------|:------------------:|----------------------------------------------------------------------------------------------------------------| +| subject | :white_check_mark: | Measure report for a single subject (e.g. one patient). Includes additional detail, such as evaluatedResources | +| subject-list | :white_check_mark: | Measure report including the list of subjects in each population (e.g. all the patients in the "numerator") | +| population | :white_check_mark: | Summary measure report for a population | + +NOTE: There's an open issue on the FHIR specification to align these names to the MeasureReportType value set. + +A request using `reportType` looks like: + +```bash +GET fhir/Measure//$evaluate-measure?reportType=subject-list +``` + +#### Subject Types + +The subject of a measure evaluation is controlled with the `subject` (R4+) and `patient` (DSTU3) operation parameters. Currently, the only subject type supported by HAPI is Patient. This means that all Measure evaluation and reporting happens with respect to a Patient or set of Patient resources. + +| Subject Type | Supported | Description | +|-------------------|:--------------------:|-------------------| +| Patient | :white_check_mark: | A Patient | +| Practitioner | :white_large_square: | A Practitioner | +| Organization | :white_large_square: | An Organization | +| Location | :white_large_square: | A Location | +| Device | :white_large_square: | A Device | +| Group1 | :white_check_mark: | A set of subjects | + +1. See next section + +A request using `subject` looks like: + +```bash +GET fhir/Measure//$evaluate-measure?subject=Patient/123 +``` + +##### Selecting a set of Patients + +The set of Patients used for Measure evaluation is controlled with the `subject` (R4+) or `patient` (DSTU3), and `practitioner` parameters. The two parameters are mutually exclusive. + +| Parameter | Supported | Description | +|-------------------------------------------------------|:------------------:|-------------------------------------------------------------------------| +| Not specified | :white_check_mark: | All Patients on the server | +| `subject=XXX` or `subject=Patient/XXX` | :white_check_mark: | A single Patient | +| `practitioner=XXX` or `practitioner=Practitioner/XXX` | :white_check_mark: | All Patients whose `generalPractitioner` is the referenced Practitioner | +| `subject=Group/XXX`1 | :white_check_mark: | A Group containing subjects | +| `subject=XXX` AND `practitioner=XXX` | :x: | Not a valid combination | + +1. Currently only Groups containing Patient resources are supported + +A request using `practitioner` looks like: + +```bash +GET fhir/Measure//$evaluate-measure?practitioner=Practitioner/XYZ +``` + +#### ReportType, Subject, Practitioner Matrix + +The following table shows the combinations of the `subject` (or `patient`), `practitioner` and `reportType` parameters that are valid + +| | subject reportType | subject-list reportType | population reportType | +|------------------------|:------------------:|:---------------------------------:|:---------------------------------:| +| subject parameter | :white_check_mark: | :white_check_mark: 1,2 | :white_check_mark: 1,2 | +| practitioner parameter | :x:3 | :white_check_mark: | :white_check_mark: | + +1. Including the subject parameter restricts the Measure evaluation to a single Patient. Omit the `subject` (or `patient`) parameter to get report for multiple Patients. The subject-list and population report types have less detail than a subject report. +2. A Group `subject` with a subject-list or population `reportType` will be a valid combination once Group support is implemented. +3. A practitioner have may zero, one, or many patients so a practitioner report always assumes a set. + +#### Scoring Methods + +The Measure scoring method determines how a Measure score is calculated. It is set with the [scoring](https://www.hl7.org/fhir/measure-definitions.html#Measure.scoring) element on the Measure resource. + +The HAPI implementation conforms to the requirements defined by the CQF Measures IG. A more detailed description of each scoring method is linked in the table below. + +| Scoring Method | Supported | Description | +|---------------------|:--------------------:|------------------------------------------------------------------------------------------------------------------------| +| proportion | :white_check_mark: | [Proportion Measures](https://build.fhir.org/ig/HL7/cqf-measures/measure-conformance.html#proportion-measures) | +| ratio | :white_check_mark: | [Ratio Measures](https://build.fhir.org/ig/HL7/cqf-measures/measure-conformance.html#ratio-measures) | +| continuous-variable | :white_check_mark: | [Continuous Variable](https://build.fhir.org/ig/HL7/cqf-measures/measure-conformance.html#continuous-variable-measure) | +| cohort | :white_check_mark:* | [Cohort](https://build.fhir.org/ig/HL7/cqf-measures/measure-conformance.html#cohort-definitions) | +| composite | :white_large_square: | See below | + +* The cohort Measure scoring support is partial. The HAPI implementation does not yet return the required Measure observations + +An example Measure resource with `scoring` defined looks like: + +```json +{ + "resourceType": "Measure", + "scoring": { + "coding": [ { + "system": "http://terminology.hl7.org/CodeSystem/measure-scoring", + "code": "proportion", + "display": "Proportion" + } ] + } +} +``` + +##### Composite Scoring + +A composite Measure is scored by combining and/or aggregating the results of other Measures. The [compositeScoring](https://www.hl7.org/fhir/measure-definitions.html#Measure.compositeScoring) element is used to control how composite Measures are scored. HAPI does not currently support any composite scoring method. + +| Composite Scoring Method | Supported | Description | +|--------------------------|:--------------------:|------------------------------------------------------------------------------------------------| +| opportunity | :white_large_square: | Combines Numerators and Denominators for each component Measure | +| all-or-nothing | :white_large_square: | Includes individuals that are in the numerator for all component Measures | +| linear | :white_large_square: | Gives an individual score based on the number of numerators in which they appear | +| weighted | :white_large_square: | Gives an individual a cored based on a weighted factor for each numerator in which they appear | + +#### Populations + +The HAPI implementation uses the populations defined by the CQF Measures IG for each scoring type. A matrix of the supported populations is shown in the [Criteria Names](https://build.fhir.org/ig/HL7/cqf-measures/measure-conformance.html#criteria-names) section of the CQF Measures IG. + +#### Population Criteria + +The logical criteria used for determining each Measure population is defined by the [Measure.group.population.criteria](https://hl7.org/fhir/R4/measure-definitions.html#Measure.group.population.criteria) element. The Measure specification allows population criteria to be defined using FHIR Path, CQL, or other languages as appropriate. The HAPI implementation currently only supports using CQL. The relationship between a Measure Population and CQL is illustrated in the [Population Criteria](https://build.fhir.org/ig/HL7/cqf-measures/measure-conformance.html#population-criteria) section of the CQF Measures IG. + +An example Measure resource with a population criteria referencing a CQL identifier looks like: + +```json +{ + "resourceType": "Measure", + "group": [ { + "population": [ { + "code": { + "coding": [ { + "system": "http://terminology.hl7.org/CodeSystem/measure-population", + "code": "initial-population", + "display": "Initial Population" + } ] + }, + "criteria": { + "language": "text/cql-identifier", + "expression": "Initial Population" + } + }] + }] +} +``` + +##### Criteria Expression Type + +| Expression Type | Supported | +|-----------------|:--------------------:| +| CQL | :white_check_mark: | +| FHIR Path | :white_large_square: | + +#### Supplemental Data Elements + +Supplemental Data Elements are used to report additional information about the subjects that may not be included in the Population criteria definitions. For example, it may be of interest to report the gender of all subjects for informational purposes. Supplemental data elements are defined by the [Measure.supplementalData](http://www.hl7.org/fhir/measure-definitions.html#Measure.supplementalData) element, and are reported as Observations in the evaluatedResources of the MeasureReport. + +Supplemental Data Elements can be specified as either CQL definitions or FHIR Path expressions. + +| Expression Type | Supported | +|-----------------|:--------------------:| +| CQL | :white_check_mark: | +| FHIR Path | :white_large_square: | + +An example Measure resource with some supplemental data elements set looks like: + +```json +{ +"resourceType": "Measure", + "supplementalData": [ { + "code": { + "text": "sde-ethnicity" + }, + "criteria": { + "language": "text/cql-identifier", + "expression": "SDE Ethnicity" + } + }] +} +``` + +#### Stratifiers + +Stratifiers are used divide Measure populations into segments of interest. For example, it may be of interest to compare the Measure score between different age groups or genders. Each stratum within a stratification is scored the same way as the overall population. Stratifiers are defined using the [Measure.group.stratifier](http://hl7.org/fhir/R4/measure-definitions.html#Measure.group.stratifier) element. + +An example Measure resource with a stratifier set looks like: + +```json +{ + "resourceType": "Measure", + "group": [ { + "stratifier": [ { + "code": { + "text": "Stratum 1" + }, + "criteria": { + "language": "text/cql-identifier", + "expression": "Stratification 1" + } + }] + }] +} +``` + +##### Stratifier Expression Support + +As with Populations and Supplemental Data Elements the criteria used for Stratification may be defined with CQL or FHIR Path. + +| Expression Type | Supported | +|-----------------|:--------------------:| +| CQL | :white_check_mark: | +| FHIR Path | :white_large_square: | + +##### Stratifier Component Support + +The Measure specification also supports multidimensional stratification, for cases where more than one data element is needed. + +| Stratifier Type | Supported | +|------------------|:--------------------:| +| Single Component | :white_check_mark: | +| Multi Component | :white_large_square: | + +#### Evaluated Resources + +A FHIR MeasureReport permits referencing the Resources used when evaluating in the [MeasureReport.evaluatedResource](https://www.hl7.org/fhir/measurereport-definitions.html#MeasureReport.evaluatedResource) element. HAPI includes these resources when generating `subject` reports for a single Patient. Evaluated resources for `population` or `subject-list` reports are not included. For large populations this could quickly become an extremely large number of resources. + +The evaluated resources will not include every resource on the HAPI server for a given subject. Rather, it includes only the resources that were retrieved from the server by the CQL logic that was evaluated. This corresponds to the data-requirements for a given Measure. As an example, consider the following CQL: + +```cql +valueset "Example Value Set" : 'http://fhir.org/example-value-set' + +define "Example Observations": + [Observation : "Example Value Set"] +``` + +That CQL will only select Observation Resources that have a code in the "Example Value Set". Those Observations will be reported in the Evaluated Resources while any others will not. + +#### Last Received On + +The `lastReceivedOn` parameter is the date the Measure was evaluated and reported. It is used to limit the number of resources reported in the Measure report for individual reports. It is currently not supported by HAPI. + +#### Extensions + +A number of extensions to Measure evaluation defined by various IGs are supported. They are described briefly in the table below. + +| Extension | Description | +|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------| +| http://hl7.org/fhir/us/cqframework/cqfmeasures/StructureDefinition/cqfm-productLine | Used to evaluate different product lines (e.g. Medicare, Private, etc.) | +| http://hl7.org/fhir/StructureDefinition/cqf-measureInfo | Used to denote a Measure Observation | +| http://hl7.org/fhir/us/davinci-deqm/StructureDefinition/extension-populationReference | Used to specify the population that triggered a particular `evaluatedResource` | + +There's not currently a way to configure which extensions are enabled. All supported extensions are always enabled. + +## FAQs + +Q: I get an error saying HAPI can't locate my library, and I've verified it's on the server. + +A: HAPI follows the [Library conformance requirements](https://build.fhir.org/ig/HL7/cqf-measures/measure-conformance.html#conformance-requirement-3-1) defined by the CQF Measures IG, meaning the Library must have a `logic-library` type, the name and versions of the FHIR Library and CQL Library must match, and the url of the Library must end in the name of the Library. + +FHIR Libraries generated from CQL via the IG Publisher follow these requirements automatically. + +Q: Does HAPI support partitions for evaluation? + +A: Yes, though the Measure and associated Resources must be in the same partition as the clinical data being used. + +## Roadmap + +* Complete cohort implementation +* Support for component stratifiers +* Support for FHIRPath expressions in Stratifiers, Supplemental Data Elements, and Population Criteria +* `$data-requirements`, `$collect-data`, `$submit-data`, and `$care-gaps` operations +* Support for more extensions defined in the CQF Measures, CPG, and ATR IGs diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/overview.md b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/overview.md new file mode 100644 index 00000000000..151a8b119ca --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/clinical_reasoning/overview.md @@ -0,0 +1,28 @@ +# Clinical Reasoning + +## Overview + +Clinical Reasoning (CR) is ability to represent, encode, and evaluate clinical knowledge so that it can be integrated into clinical systems. In other words, clinical reasoning is the ability to store and run business logic that is relevant to clinical settings. This may be as simple as controlling whether a particular section of an order set appears based on the conditions that a patient has, or it may be as complex as representing the care pathway for a patient with multiple conditions. + +The FHIR [Clinical Reasoning module](http://www.hl7.org/fhir/clinicalreasoning-module.html) specifies a foundational set of FHIR resources and associated operations that allow a FHIR repository to perform clinical reasoning on clinical data. Some use cases include: + +* Prospective/Retrospective Analytics + * Quality Measures + * Gaps in Care +* Clinical Decision Support +* Payer/Provider Data Exchange +* Prior Authorization + +There are additional IGs outside the FHIR CR module that define further requirements and behavior for other Clinical Reasoning use cases. Some examples include: + +* [Structured Data Capture IG](https://build.fhir.org/ig/HL7/sdc/) +* [Clinical Guidelines IG](https://hl7.org/fhir/uv/cpg/) +* [Quality Measures IG](http://hl7.org/fhir/us/cqfmeasures/) + +## HAPI FHIR + +The HAPI FHIR server includes support for storing all the Clinical Reasoning resources defined in the FHIR CR module, including `Measure`, `PlanDefinition`, `ActivityDefinition` and so on. Additionally, HAPI includes an embedded [CQL](/hapi-fhir/docs/clinical_reasoning/cql.html) engine that allows it to process clinical logic encoded in a standard representation. + +HAPI also includes a [Quality Measure](/hapi-fhir/docs/clinical_reasoning/measure.html) engine that can evaluate clinical quality measures. + +See the [CQL](/hapi-fhir/docs/clinical_reasoning/cql.html) and [Measure](/hapi-fhir/docs/clinical_reasoning/measure.html) documentation for further details. diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/files.properties b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/files.properties index 0f0e29c3c5a..027ed70dbfb 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/files.properties +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/docs/files.properties @@ -85,6 +85,11 @@ page.server_jpa_partitioning.enabling_in_hapi_fhir=Enabling Partitioning in HAPI section.server_jpa_batch.title=JPA Server: Batch Processing page.server_jpa_batch.introduction=Batch Introduction +section.clinical_reasoning.title=Clinical Reasoning +page.clinical_reasoning.overview=Clinical Reasoning Overview +page.clinical_reasoning.cql=CQL +page.clinical_reasoning.measures=Measures + section.interceptors.title=Interceptors page.interceptors.interceptors=Interceptors Overview page.interceptors.client_interceptors=Client Interceptors diff --git a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/r4/CqlProviderR4Test.java b/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/r4/CqlProviderR4Test.java deleted file mode 100644 index ddb8644eac4..00000000000 --- a/hapi-fhir-jpaserver-cql/src/test/java/ca/uhn/fhir/cql/r4/CqlProviderR4Test.java +++ /dev/null @@ -1,79 +0,0 @@ -package ca.uhn.fhir.cql.r4; - -import ca.uhn.fhir.cql.BaseCqlR4Test; -import ca.uhn.fhir.cql.common.provider.CqlProviderTestBase; -import ca.uhn.fhir.cql.r4.provider.MeasureOperationsProvider; -import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.Library; -import org.hl7.fhir.r4.model.Measure; -import org.hl7.fhir.r4.model.MeasureReport; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import java.io.IOException; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class CqlProviderR4Test extends BaseCqlR4Test implements CqlProviderTestBase { - private static final Logger ourLog = LoggerFactory.getLogger(CqlProviderR4Test.class); - private static final IdType measureId = new IdType("Measure", "measure-asf"); - private static final String measure = "Measure/measure-asf"; - private static final String patient = "Patient/Patient-6529"; - private static final String periodStart = "2000-01-01"; - private static final String periodEnd = "2019-12-31"; - private static boolean bundlesLoaded = false; - - @Autowired - IFhirResourceDao myMeasureDao; - @Autowired - IFhirResourceDao myLibraryDao; - @Autowired - MeasureOperationsProvider myMeasureOperationsProvider; - - public synchronized void loadBundles() throws IOException { - if (!bundlesLoaded) { - Bundle result = loadBundle("dstu3/hedis-ig/test-patient-6529-data.json"); - bundlesLoaded = true; - } - } - - @Test - public void testHedisIGEvaluateMeasureWithTimeframe() throws IOException { - loadBundles(); - loadResource("r4/hedis-ig/library-asf-logic.json", myRequestDetails); - loadResource("r4/hedis-ig/measure-asf.json", myRequestDetails); - - myPartitionHelper.clear(); - MeasureReport report = myMeasureOperationsProvider.evaluateMeasure(measureId, periodStart, periodEnd, measure, "subject", - patient, null, null, null, null, null, null, myRequestDetails); - - // Assert it worked - assertTrue(myPartitionHelper.wasCalled()); - assertThat(report.getGroup(), hasSize(1)); - assertThat(report.getGroup().get(0).getPopulation(), hasSize(3)); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(report)); - } - - @Test - public void testHedisIGEvaluateMeasureNoTimeframe() throws IOException { - loadBundles(); - loadResource("r4/hedis-ig/library-asf-logic.json", myRequestDetails); - loadResource("r4/hedis-ig/measure-asf.json", myRequestDetails); - - myPartitionHelper.clear(); - MeasureReport report = myMeasureOperationsProvider.evaluateMeasure(measureId, null, null, measure, "subject", - patient, null, null, null, null, null, null, myRequestDetails); - - // Assert it worked - assertTrue(myPartitionHelper.wasCalled()); - assertThat(report.getGroup(), hasSize(1)); - assertThat(report.getGroup().get(0).getPopulation(), hasSize(3)); - ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(report)); - } -}