Search in sources :

Example 6 with MeasureReport

use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.

the class MeasureEvaluateProviderIT method testMeasureEvaluateWithAdditionalData.

@Test
public void testMeasureEvaluateWithAdditionalData() throws Exception {
    String mainBundleAsText = stringFromResource("Exm104FhirR4MeasurePartBundle.json");
    Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(mainBundleAsText);
    getClient().transaction().withBundle(bundle).execute();
    String additionalBundleAsText = stringFromResource("Exm104FhirR4MeasureAdditionalData.json");
    Bundle additionalData = (Bundle) getFhirContext().newJsonParser().parseResource(additionalBundleAsText);
    Parameters params = new Parameters();
    params.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
    params.addParameter().setName("periodEnd").setValue(new StringType("2020-01-01"));
    params.addParameter().setName("reportType").setValue(new StringType("subject"));
    params.addParameter().setName("subject").setValue(new StringType("Patient/numer-EXM104"));
    params.addParameter().setName("lastReceivedOn").setValue(new StringType("2019-12-12"));
    params.addParameter().setName("additionalData").setResource(additionalData);
    MeasureReport returnMeasureReport = getClient().operation().onInstance(new IdType("Measure", "measure-EXM104-8.2.000")).named("$evaluate-measure").withParameters(params).returnResourceType(MeasureReport.class).execute();
    assertNotNull(returnMeasureReport);
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Bundle(org.hl7.fhir.r4.model.Bundle) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 7 with MeasureReport

use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.

the class MeasureEvaluateProvider method evaluateMeasure.

/**
 * Implements the <a href=
 * "https://www.hl7.org/fhir/operation-measure-evaluate-measure.html">$evaluate-measure</a>
 * operation found in the
 * <a href="http://www.hl7.org/fhir/clinicalreasoning-module.html">FHIR Clinical
 * Reasoning Module</a>. This implementation aims to be compatible with the CQF
 * IG.
 *
 * @param requestDetails The details (such as tenant) of this request. Usually
 *                       auto-populated HAPI.
 * @param theId          the Id of the Measure to evaluate
 * @param periodStart    The start of the reporting period
 * @param periodEnd      The end of the reporting period
 * @param reportType     The type of MeasureReport to generate
 * @param subject        the subject to use for the evaluation
 * @param practitioner   the practitioner to use for the evaluation
 * @param lastReceivedOn the date the results of this measure were last
 *                       received.
 * @param productLine    the productLine (e.g. Medicare, Medicaid, etc) to use
 *                       for the evaluation. This is a non-standard parameter.
 * @param additionalData the data bundle containing additional data
 * @return the calculated MeasureReport
 */
// warning for greater than 7 parameters
@SuppressWarnings("squid:S00107")
@Description(shortDefinition = "$evaluate-measure", value = "Implements the <a href=\"https://www.hl7.org/fhir/operation-measure-evaluate-measure.html\">$evaluate-measure</a> operation found in the <a href=\"http://www.hl7.org/fhir/clinicalreasoning-module.html\">FHIR Clinical Reasoning Module</a>. This implementation aims to be compatible with the CQF IG.", example = "Measure/example/$evaluate-measure?subject=Patient/123&periodStart=2019&periodEnd=2020")
@Operation(name = "$evaluate-measure", idempotent = true, type = Measure.class)
public MeasureReport evaluateMeasure(RequestDetails requestDetails, @IdParam IdType theId, @OperationParam(name = "periodStart") String periodStart, @OperationParam(name = "periodEnd") String periodEnd, @OperationParam(name = "reportType") String reportType, @OperationParam(name = "subject") String subject, @OperationParam(name = "practitioner") String practitioner, @OperationParam(name = "lastReceivedOn") String lastReceivedOn, @OperationParam(name = "productLine") String productLine, @OperationParam(name = "additionalData") Bundle additionalData) {
    Measure measure = read(theId);
    TerminologyProvider terminologyProvider = this.jpaTerminologyProviderFactory.create(requestDetails);
    DataProvider dataProvider = this.jpaDataProviderFactory.create(requestDetails, terminologyProvider);
    LibraryContentProvider libraryContentProvider = this.libraryContentProviderFactory.create(requestDetails);
    FhirDal fhirDal = this.fhirDalFactory.create(requestDetails);
    org.opencds.cqf.cql.evaluator.measure.r4.R4MeasureProcessor measureProcessor = new org.opencds.cqf.cql.evaluator.measure.r4.R4MeasureProcessor(null, this.dataProviderFactory, null, null, null, terminologyProvider, libraryContentProvider, dataProvider, fhirDal, null, this.globalLibraryCache);
    MeasureReport report = measureProcessor.evaluateMeasure(measure.getUrl(), periodStart, periodEnd, reportType, subject, null, lastReceivedOn, null, null, null, additionalData);
    if (productLine != null) {
        Extension ext = new Extension();
        ext.setUrl("http://hl7.org/fhir/us/cqframework/cqfmeasures/StructureDefinition/cqfm-productLine");
        ext.setValue(new StringType(productLine));
        report.addExtension(ext);
    }
    return report;
}
Also used : LibraryContentProvider(org.opencds.cqf.cql.evaluator.cql2elm.content.LibraryContentProvider) StringType(org.hl7.fhir.r4.model.StringType) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) FhirDal(org.opencds.cqf.cql.evaluator.fhir.dal.FhirDal) DataProvider(org.opencds.cqf.cql.engine.data.DataProvider) Extension(org.hl7.fhir.r4.model.Extension) TerminologyProvider(org.opencds.cqf.cql.engine.terminology.TerminologyProvider) Measure(org.hl7.fhir.r4.model.Measure) Description(ca.uhn.fhir.model.api.annotation.Description) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 8 with MeasureReport

use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.

the class MeasureEvaluateProviderIT method testMeasureEvaluate.

@Test
public void testMeasureEvaluate() throws Exception {
    String bundleAsText = stringFromResource("Exm105Fhir3Measure.json");
    Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
    getClient().transaction().withBundle(bundle).execute();
    Parameters params = new Parameters();
    params.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
    params.addParameter().setName("periodEnd").setValue(new StringType("2020-01-01"));
    params.addParameter().setName("reportType").setValue(new StringType("individual"));
    params.addParameter().setName("subject").setValue(new StringType("Patient/denom-EXM105-FHIR3"));
    params.addParameter().setName("lastReceivedOn").setValue(new StringType("2019-12-12"));
    MeasureReport returnMeasureReport = getClient().operation().onInstance(new IdType("Measure", "measure-EXM105-FHIR3-8.0.000")).named("$evaluate-measure").withParameters(params).returnResourceType(MeasureReport.class).execute();
    assertNotNull(returnMeasureReport);
// System.out.println("Resource:"+this.getFhirContext().newJsonParser().setPrettyPrint(true).encodeResourceToString(returnMeasureReport));
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) MeasureReport(org.hl7.fhir.dstu3.model.MeasureReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 9 with MeasureReport

use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.

the class MeasureEvaluateProviderIT method testMeasureEvaluateWithAdditionalData.

@Test
public void testMeasureEvaluateWithAdditionalData() throws Exception {
    String mainBundleAsText = stringFromResource("Exm105FhirR3MeasurePartBundle.json");
    Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(mainBundleAsText);
    getClient().transaction().withBundle(bundle).execute();
    String additionalBundleAsText = stringFromResource("Exm105FhirR3MeasureAdditionalData.json");
    Bundle additionalData = (Bundle) getFhirContext().newJsonParser().parseResource(additionalBundleAsText);
    Parameters params = new Parameters();
    params.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
    params.addParameter().setName("periodEnd").setValue(new StringType("2020-01-01"));
    params.addParameter().setName("reportType").setValue(new StringType("individual"));
    params.addParameter().setName("subject").setValue(new StringType("Patient/denom-EXM105-FHIR3"));
    params.addParameter().setName("lastReceivedOn").setValue(new StringType("2019-12-12"));
    params.addParameter().setName("additionalData").setResource(additionalData);
    MeasureReport returnMeasureReport = getClient().operation().onInstance(new IdType("Measure", "measure-EXM105-FHIR3-8.0.000")).named("$evaluate-measure").withParameters(params).returnResourceType(MeasureReport.class).execute();
    assertNotNull(returnMeasureReport);
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) MeasureReport(org.hl7.fhir.dstu3.model.MeasureReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 10 with MeasureReport

use of org.hl7.fhir.dstu3.model.MeasureReport in project cqf-ruler by DBCG.

the class SubmitDataProviderIT method testSubmitDataNoId.

@Test
public void testSubmitDataNoId() {
    // Create a MR and a resource
    MeasureReport mr = newResource(MeasureReport.class).setMeasure(new Reference("Measure/123"));
    Observation obs = newResource(Observation.class).setValue(new StringType("ABC"));
    // Submit it
    mySubmitDataProvider.submitData(new SystemRequestDetails(), new IdType("Measure", "123"), mr, Lists.newArrayList(obs));
    // Check if they made it to the db
    Observation savedObs = search(Observation.class, Searches.all()).single();
    assertNotNull(savedObs);
    assertEquals("ABC", savedObs.getValue().primitiveValue());
    MeasureReport savedMr = search(MeasureReport.class, Searches.all()).single();
    assertNotNull(savedMr);
    assertEquals("Measure/123", savedMr.getMeasure().getReference());
}
Also used : StringType(org.hl7.fhir.dstu3.model.StringType) SystemRequestDetails(ca.uhn.fhir.jpa.partition.SystemRequestDetails) Reference(org.hl7.fhir.dstu3.model.Reference) Observation(org.hl7.fhir.dstu3.model.Observation) MeasureReport(org.hl7.fhir.dstu3.model.MeasureReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test) DaoIntegrationTest(org.opencds.cqf.ruler.test.DaoIntegrationTest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

MeasureReport (org.hl7.fhir.r4.model.MeasureReport)51 Test (org.junit.Test)35 Measure (org.hl7.fhir.r4.model.Measure)31 Patient (org.hl7.fhir.r4.model.Patient)29 Library (org.hl7.fhir.r4.model.Library)23 HashMap (java.util.HashMap)19 CapabilityStatement (org.hl7.fhir.r4.model.CapabilityStatement)18 Extension (org.hl7.fhir.r4.model.Extension)17 MeasureEvidenceOptions (com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions)16 StringType (org.hl7.fhir.r4.model.StringType)16 Test (org.junit.jupiter.api.Test)16 ArrayList (java.util.ArrayList)15 Map (java.util.Map)13 Bundle (org.hl7.fhir.r4.model.Bundle)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 BooleanType (org.hl7.fhir.r4.model.BooleanType)10 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)10 MeasurePopulationType (org.opencds.cqf.common.evaluation.MeasurePopulationType)10 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)9 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)9