Search in sources :

Example 1 with DecimalParameter

use of com.ibm.cohort.cql.evaluation.parameters.DecimalParameter in project quality-measure-and-cohort-service by Alvearie.

the class ParameterHelperTest method testResolveDecimalParameter.

@Test
public void testResolveDecimalParameter() {
    Map<String, Parameter> params = ParameterHelper.parseParameterArguments(Arrays.asList("test:decimal:40.0"));
    assertEquals(1, params.size());
    DecimalParameter p = (DecimalParameter) params.get("test");
    assertNotNull("Parameter with expected name not found", p);
    assertEquals("Unexpected value", "40.0", p.getValue());
}
Also used : DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) Test(org.junit.Test)

Example 2 with DecimalParameter

use of com.ibm.cohort.cql.evaluation.parameters.DecimalParameter in project quality-measure-and-cohort-service by Alvearie.

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testDecimal__shouldReturnDecimalParameter.

@Test
public void testDecimal__shouldReturnDecimalParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("decimal");
    String decimalString = "1.5";
    BigDecimal bigDecimalValue = new BigDecimal(decimalString);
    DecimalType fhirValue = new DecimalType(bigDecimalValue);
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    assertEquals(new DecimalParameter(decimalString), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) DecimalType(org.hl7.fhir.r4.model.DecimalType) BigDecimal(java.math.BigDecimal) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 3 with DecimalParameter

use of com.ibm.cohort.cql.evaluation.parameters.DecimalParameter in project quality-measure-and-cohort-service by Alvearie.

the class R4ParameterDefinitionWithDefaultToCohortParameterConverter method toCohortParameter.

public static Parameter toCohortParameter(Extension extension) {
    Parameter parameter;
    Type extensionValue = extension.getValue();
    if (extensionValue instanceof Base64BinaryType) {
        parameter = new StringParameter(((Base64BinaryType) extensionValue).asStringValue());
    } else if (extensionValue instanceof BooleanType) {
        parameter = new BooleanParameter(((BooleanType) extensionValue).booleanValue());
    } else if (extensionValue instanceof DateType) {
        parameter = new DateParameter(((DateType) extensionValue).asStringValue());
    } else if (extensionValue instanceof DateTimeType) {
        parameter = convertDateTimeType((DateTimeType) extensionValue);
    } else if (extensionValue instanceof DecimalType) {
        parameter = new DecimalParameter(((DecimalType) extensionValue).getValueAsString());
    } else if (extensionValue instanceof InstantType) {
        parameter = new DatetimeParameter(((InstantType) extensionValue).getValueAsString());
    } else if (extensionValue instanceof IntegerType) {
        parameter = new IntegerParameter(((IntegerType) extensionValue).getValue());
    } else if (extensionValue instanceof StringType) {
        parameter = new StringParameter(((StringType) extensionValue).getValue());
    } else if (extensionValue instanceof TimeType) {
        parameter = new TimeParameter(((TimeType) extensionValue).asStringValue());
    } else if (extensionValue instanceof UriType) {
        parameter = new StringParameter(((UriType) extensionValue).getValue());
    } else if (extensionValue instanceof Coding) {
        parameter = convertCoding((Coding) extensionValue);
    } else if (extensionValue instanceof CodeableConcept) {
        parameter = convertCodeableConcept((CodeableConcept) extensionValue);
    } else if (extensionValue instanceof Period) {
        Period castValue = (Period) extensionValue;
        parameter = new IntervalParameter(convertDateTimeType(castValue.getStartElement()), true, convertDateTimeType(castValue.getEndElement()), true);
    } else if (extensionValue instanceof Quantity) {
        parameter = convertQuantity((Quantity) extensionValue);
    } else if (extensionValue instanceof Range) {
        Range castValue = (Range) extensionValue;
        parameter = new IntervalParameter(convertQuantity(castValue.getLow()), true, convertQuantity(castValue.getHigh()), true);
    } else if (extensionValue instanceof Ratio) {
        Ratio castValue = (Ratio) extensionValue;
        parameter = new RatioParameter().setDenominator(convertQuantity(castValue.getDenominator())).setNumerator(convertQuantity(castValue.getNumerator()));
    } else {
        throw new UnsupportedFhirTypeException(extensionValue);
    }
    return parameter;
}
Also used : IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) StringType(org.hl7.fhir.r4.model.StringType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) TimeType(org.hl7.fhir.r4.model.TimeType) UriType(org.hl7.fhir.r4.model.UriType) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) Coding(org.hl7.fhir.r4.model.Coding) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) Ratio(org.hl7.fhir.r4.model.Ratio) InstantType(org.hl7.fhir.r4.model.InstantType) DateType(org.hl7.fhir.r4.model.DateType) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) UnsupportedFhirTypeException(com.ibm.cohort.engine.measure.parameter.UnsupportedFhirTypeException) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) BooleanType(org.hl7.fhir.r4.model.BooleanType) Period(org.hl7.fhir.r4.model.Period) Quantity(org.hl7.fhir.r4.model.Quantity) Range(org.hl7.fhir.r4.model.Range) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) IntegerType(org.hl7.fhir.r4.model.IntegerType) Type(org.hl7.fhir.r4.model.Type) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) StringType(org.hl7.fhir.r4.model.StringType) DecimalType(org.hl7.fhir.r4.model.DecimalType) IntegerType(org.hl7.fhir.r4.model.IntegerType) DateType(org.hl7.fhir.r4.model.DateType) TimeType(org.hl7.fhir.r4.model.TimeType) BooleanType(org.hl7.fhir.r4.model.BooleanType) InstantType(org.hl7.fhir.r4.model.InstantType) UriType(org.hl7.fhir.r4.model.UriType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) DecimalType(org.hl7.fhir.r4.model.DecimalType) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 4 with DecimalParameter

use of com.ibm.cohort.cql.evaluation.parameters.DecimalParameter in project quality-measure-and-cohort-service by Alvearie.

the class ParameterHelperTest method testResolveIntervalDecimalParameter.

@Test
public void testResolveIntervalDecimalParameter() {
    Map<String, Parameter> params = ParameterHelper.parseParameterArguments(Arrays.asList("test:interval:decimal,10,20"));
    assertEquals(1, params.size());
    IntervalParameter p = (IntervalParameter) params.get("test");
    assertEquals("10", ((DecimalParameter) p.getStart()).getValue());
    assertEquals("20", ((DecimalParameter) p.getEnd()).getValue());
}
Also used : DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Test(org.junit.Test)

Example 5 with DecimalParameter

use of com.ibm.cohort.cql.evaluation.parameters.DecimalParameter in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluatorTest method measure_report_generated___named_parameters_on_measure_report.

@Test
public void measure_report_generated___named_parameters_on_measure_report() throws Exception {
    CapabilityStatement metadata = getCapabilityStatement();
    mockFhirResourceRetrieval("/metadata?_format=json", metadata);
    Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
    mockFhirResourceRetrieval(patient);
    Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.xml", ELM_MIME_TYPE);
    Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
    mockFhirResourceRetrieval(measure);
    Map<String, Parameter> parameterMap = new HashMap<>();
    parameterMap.put("integerParam", new IntegerParameter(1));
    parameterMap.put("decimalParam", new DecimalParameter("1.0"));
    parameterMap.put("stringParam", new StringParameter("1"));
    parameterMap.put("booleanParam", new BooleanParameter(false));
    parameterMap.put("datetimeParam", new DatetimeParameter("2020-01-01"));
    parameterMap.put("dateParam", new DateParameter("2020-01-01"));
    parameterMap.put("timeParam", new TimeParameter("01:00:00"));
    parameterMap.put("quantityParam", new QuantityParameter("1.0", "ml"));
    parameterMap.put("ratioParam", new RatioParameter(new QuantityParameter("1.0", "ml"), new QuantityParameter("2.0", "ml")));
    parameterMap.put("codeParam", new CodeParameter("1", "2", "3", "4"));
    parameterMap.put("conceptParam", new ConceptParameter("1", new CodeParameter("1", "2", "3", "4")));
    parameterMap.put("datetimeIntervalParam", new IntervalParameter(new DatetimeParameter("2020-01-01"), true, new DatetimeParameter("2021-01-01"), true));
    parameterMap.put("quantityIntervalParam", new IntervalParameter(new QuantityParameter("1.0", "ml"), true, new QuantityParameter("2.0", "ml"), true));
    MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), parameterMap);
    assertNotNull(report);
    List<String> parameterNames = report.getExtension().stream().filter(x -> x.getUrl().equals(MEASURE_PARAMETER_VALUE_URL)).map(x -> (ParameterDefinition) x.getValue()).map(ParameterDefinition::getName).collect(Collectors.toList());
    // Expected parameters are the ones listed above, plus the special parameters
    // measurement period and product line
    assertEquals(parameterMap.size() + 2, parameterNames.size());
    assertTrue(parameterNames.containsAll(parameterMap.keySet()));
    assertTrue(parameterNames.contains(CDMConstants.MEASUREMENT_PERIOD));
    assertTrue(parameterNames.contains(CDMConstants.PRODUCT_LINE));
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) PARAMETER_VALUE_URL(com.ibm.cohort.engine.cdm.CDMConstants.PARAMETER_VALUE_URL) Range(org.hl7.fhir.r4.model.Range) StringUtils(org.apache.commons.lang3.StringUtils) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) InvalidOperatorArgument(org.opencds.cqf.cql.engine.exception.InvalidOperatorArgument) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) HumanName(org.hl7.fhir.r4.model.HumanName) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) Map(java.util.Map) StringType(org.hl7.fhir.r4.model.StringType) Assert.fail(org.junit.Assert.fail) ParseException(java.text.ParseException) IntegerType(org.hl7.fhir.r4.model.IntegerType) Patient(org.hl7.fhir.r4.model.Patient) DefineReturnOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions.DefineReturnOptions) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) DateType(org.hl7.fhir.r4.model.DateType) TimeZone(java.util.TimeZone) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) Period(org.hl7.fhir.r4.model.Period) MEASURE_PARAMETER_URL(com.ibm.cohort.engine.cdm.CDMConstants.MEASURE_PARAMETER_URL) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Collectors(java.util.stream.Collectors) PARAMETER_DEFAULT_URL(com.ibm.cohort.engine.cdm.CDMConstants.PARAMETER_DEFAULT_URL) TimeType(org.hl7.fhir.r4.model.TimeType) List(java.util.List) BooleanType(org.hl7.fhir.r4.model.BooleanType) Assert.assertFalse(org.junit.Assert.assertFalse) Coding(org.hl7.fhir.r4.model.Coding) WireMock.getRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor) Extension(org.hl7.fhir.r4.model.Extension) UriType(org.hl7.fhir.r4.model.UriType) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) UnsupportedFhirTypeException(com.ibm.cohort.engine.measure.parameter.UnsupportedFhirTypeException) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) Type(org.hl7.fhir.r4.model.Type) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) HashMap(java.util.HashMap) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) Measure(org.hl7.fhir.r4.model.Measure) ArrayList(java.util.ArrayList) Address(org.hl7.fhir.r4.model.Address) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) MEASURE_PARAMETER_VALUE_URL(com.ibm.cohort.engine.cdm.CDMConstants.MEASURE_PARAMETER_VALUE_URL) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Quantity(org.hl7.fhir.r4.model.Quantity) Ratio(org.hl7.fhir.r4.model.Ratio) MeasureSupplementalDataEvaluation(com.ibm.cohort.engine.cqfruler.MeasureSupplementalDataEvaluation) DecimalType(org.hl7.fhir.r4.model.DecimalType) Before(org.junit.Before) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) Assert.assertNotNull(org.junit.Assert.assertNotNull) ListResource(org.hl7.fhir.r4.model.ListResource) Library(org.hl7.fhir.r4.model.Library) Assert.assertTrue(org.junit.Assert.assertTrue) Matchers(org.hamcrest.Matchers) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) Test(org.junit.Test) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) WireMock.verify(com.github.tomakehurst.wiremock.client.WireMock.verify) WireMock.urlMatching(com.github.tomakehurst.wiremock.client.WireMock.urlMatching) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) CDMConstants(com.ibm.cohort.engine.cdm.CDMConstants) MeasurePopulationType(org.opencds.cqf.common.evaluation.MeasurePopulationType) InstantType(org.hl7.fhir.r4.model.InstantType) AdministrativeGender(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) WireMock.urlEqualTo(com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo) Assert.assertEquals(org.junit.Assert.assertEquals) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) HashMap(java.util.HashMap) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) Patient(org.hl7.fhir.r4.model.Patient) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) Measure(org.hl7.fhir.r4.model.Measure) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) Library(org.hl7.fhir.r4.model.Library) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Test(org.junit.Test)

Aggregations

DecimalParameter (com.ibm.cohort.cql.evaluation.parameters.DecimalParameter)7 IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)6 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)6 StringParameter (com.ibm.cohort.cql.evaluation.parameters.StringParameter)6 Test (org.junit.Test)6 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)5 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)4 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)4 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)4 QuantityParameter (com.ibm.cohort.cql.evaluation.parameters.QuantityParameter)4 TimeParameter (com.ibm.cohort.cql.evaluation.parameters.TimeParameter)4 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)3 DecimalType (org.hl7.fhir.r4.model.DecimalType)3 ConceptParameter (com.ibm.cohort.cql.evaluation.parameters.ConceptParameter)2 RatioParameter (com.ibm.cohort.cql.evaluation.parameters.RatioParameter)2 UnsupportedFhirTypeException (com.ibm.cohort.engine.measure.parameter.UnsupportedFhirTypeException)2 HashMap (java.util.HashMap)2 Base64BinaryType (org.hl7.fhir.r4.model.Base64BinaryType)2 BooleanType (org.hl7.fhir.r4.model.BooleanType)2 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2