Search in sources :

Example 61 with Parameters

use of org.hl7.fhir.r5.model.Parameters in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testRequiredCQLParameterSpecifiedPatientInRange.

@Test
public void testRequiredCQLParameterSpecifiedPatientInRange() throws Exception {
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1978-05-06");
    CqlEvaluator evaluator = setupTestFor(patient, "cql.parameters");
    String expression = "Female";
    Map<String, Parameter> parameters = new HashMap<>();
    parameters.put("MaxAge", new IntegerParameter(50));
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("TestWithParams", "1.0.0"), parameters, newPatientContext("123"), Collections.singleton(expression));
    Map<String, Object> expected = new HashMap<>();
    expected.put(expression, true);
    Assert.assertEquals(expected, actual.getExpressionResults());
}
Also used : IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) HashMap(java.util.HashMap) Patient(org.hl7.fhir.r4.model.Patient) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) CqlEvaluationResult(com.ibm.cohort.cql.evaluation.CqlEvaluationResult) CqlEvaluator(com.ibm.cohort.cql.evaluation.CqlEvaluator) CqlVersionedIdentifier(com.ibm.cohort.cql.library.CqlVersionedIdentifier) Test(org.junit.Test)

Example 62 with Parameters

use of org.hl7.fhir.r5.model.Parameters in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testRequiredCQLParameterSpecifiedPatientOutOfRange.

@Test
public void testRequiredCQLParameterSpecifiedPatientOutOfRange() throws Exception {
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1978-05-06");
    CqlEvaluator evaluator = setupTestFor(patient, "cql.parameters");
    String expression = "Female";
    Map<String, Parameter> parameters = new HashMap<>();
    parameters.put("MaxAge", new IntegerParameter(40));
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("TestWithParams", "1.0.0"), parameters, newPatientContext("123"), Collections.singleton(expression));
    Map<String, Object> expected = new HashMap<>();
    expected.put(expression, false);
    Assert.assertEquals(expected, actual.getExpressionResults());
}
Also used : IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) HashMap(java.util.HashMap) Patient(org.hl7.fhir.r4.model.Patient) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) CqlEvaluationResult(com.ibm.cohort.cql.evaluation.CqlEvaluationResult) CqlEvaluator(com.ibm.cohort.cql.evaluation.CqlEvaluator) CqlVersionedIdentifier(com.ibm.cohort.cql.library.CqlVersionedIdentifier) Test(org.junit.Test)

Example 63 with Parameters

use of org.hl7.fhir.r5.model.Parameters in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testMissingRequiredCQLParameterSomeSpecified.

@Test
public void testMissingRequiredCQLParameterSomeSpecified() throws Exception {
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1978-05-06");
    CqlEvaluator evaluator = setupTestFor(patient, "cql.parameters");
    String expression = "Female";
    Map<String, Parameter> parameters = new HashMap<>();
    parameters.put("Unused", new IntegerParameter(100));
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("TestWithParams", "1.0.0"), parameters, newPatientContext("123"), Collections.singleton(expression));
    Map<String, Object> expected = new HashMap<>();
    expected.put(expression, null);
    Assert.assertEquals(expected, actual.getExpressionResults());
}
Also used : IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) HashMap(java.util.HashMap) Patient(org.hl7.fhir.r4.model.Patient) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) CqlEvaluationResult(com.ibm.cohort.cql.evaluation.CqlEvaluationResult) CqlEvaluator(com.ibm.cohort.cql.evaluation.CqlEvaluator) CqlVersionedIdentifier(com.ibm.cohort.cql.library.CqlVersionedIdentifier) Test(org.junit.Test)

Example 64 with Parameters

use of org.hl7.fhir.r5.model.Parameters in project quality-measure-and-cohort-service by Alvearie.

the class CDMMeasureEvaluation method getParameterExtensions.

protected static List<Extension> getParameterExtensions(Measure measure, Context context, Map<String, Parameter> parameterMap) {
    Set<String> parameterNames = new HashSet<>();
    // Check for special parameters we handle elsewhere
    if (context.resolveParameterRef(null, CDMConstants.MEASUREMENT_PERIOD) != null) {
        parameterNames.add(CDMConstants.MEASUREMENT_PERIOD);
    }
    if (context.resolveParameterRef(null, CDMConstants.PRODUCT_LINE) != null) {
        parameterNames.add(CDMConstants.PRODUCT_LINE);
    }
    if (parameterMap != null) {
        parameterNames.addAll(parameterMap.keySet());
    }
    List<Extension> parameterExtensions = measure.getExtensionsByUrl(CDMConstants.MEASURE_PARAMETER_URL);
    for (Extension e : parameterExtensions) {
        ParameterDefinition parameterDefinition = (ParameterDefinition) e.getValue();
        parameterNames.add(parameterDefinition.getName());
    }
    return parameterNames.stream().map(x -> createParameterExtension(context, x)).filter(Objects::nonNull).collect(Collectors.toList());
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) HashSet(java.util.HashSet) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition)

Example 65 with Parameters

use of org.hl7.fhir.r5.model.Parameters in project quality-measure-and-cohort-service by Alvearie.

the class CQLToFHIRMeasureReportHelper method getFhirTypeForInterval.

private static IBaseDatatype getFhirTypeForInterval(Interval interval) {
    Object low = interval.getLow();
    Object high = interval.getHigh();
    if (low instanceof DateTime) {
        // Handle DateTime conversion to force UTC timezone
        Period period = new Period();
        period.setStartElement(createDateTimeType((DateTime) low));
        period.setEndElement(createDateTimeType((DateTime) high));
        return period;
    } else if (low instanceof Quantity) {
        return converter.toFhirRange(interval);
    } else {
        logger.warn("Support not implemented for Interval parameters of type {} on a MeasureReport", low.getClass());
        return null;
    }
}
Also used : Period(org.hl7.fhir.r4.model.Period) Quantity(org.opencds.cqf.cql.engine.runtime.Quantity) DateTime(org.opencds.cqf.cql.engine.runtime.DateTime)

Aggregations

Parameters (org.hl7.fhir.r4.model.Parameters)105 Test (org.junit.jupiter.api.Test)96 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)71 StringType (org.hl7.fhir.r4.model.StringType)68 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)61 HashMap (java.util.HashMap)58 ArrayList (java.util.ArrayList)53 FHIRException (org.hl7.fhir.exceptions.FHIRException)48 IOException (java.io.IOException)44 Parameters (org.hl7.fhir.dstu3.model.Parameters)41 Bundle (org.hl7.fhir.r4.model.Bundle)34 Measure (org.hl7.fhir.r4.model.Measure)31 Path (javax.ws.rs.Path)25 Produces (javax.ws.rs.Produces)25 Patient (org.hl7.fhir.r4.model.Patient)25 FileNotFoundException (java.io.FileNotFoundException)24 List (java.util.List)24 JsonObject (javax.json.JsonObject)23 GET (javax.ws.rs.GET)23 ExtraParameters (org.apache.camel.component.fhir.api.ExtraParameters)23