Search in sources :

Example 6 with QuantityParameter

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testRatio__shouldReturnRatioParameter.

@Test
public void testRatio__shouldReturnRatioParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("Ratio");
    String denominatorString = "1.5";
    String numeratorString = "2.5";
    BigDecimal denominatorValue = new BigDecimal(denominatorString);
    BigDecimal numeratorValue = new BigDecimal(numeratorString);
    String unit = "ml";
    org.hl7.fhir.r4.model.Ratio fhirValue = new org.hl7.fhir.r4.model.Ratio().setDenominator(new org.hl7.fhir.r4.model.Quantity().setValue(denominatorValue).setUnit(unit)).setNumerator(new org.hl7.fhir.r4.model.Quantity().setValue(numeratorValue).setUnit(unit));
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    RatioParameter expectedParameter = new RatioParameter().setDenominator(new QuantityParameter().setUnit(unit).setAmount(denominatorString)).setNumerator(new QuantityParameter().setUnit(unit).setAmount(numeratorString));
    assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) BigDecimal(java.math.BigDecimal) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 7 with QuantityParameter

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testQuantity__shouldReturnQuantityParameter.

@Test
public void testQuantity__shouldReturnQuantityParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("Quantity");
    String decimalString = "1.5";
    BigDecimal bigDecimalValue = new BigDecimal(decimalString);
    String unit = "ml";
    org.hl7.fhir.r4.model.Quantity fhirValue = new org.hl7.fhir.r4.model.Quantity();
    fhirValue.setUnit(unit);
    fhirValue.setValue(bigDecimalValue);
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    QuantityParameter expectedParameter = new QuantityParameter().setUnit(unit).setAmount(decimalString);
    assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) BigDecimal(java.math.BigDecimal) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Aggregations

QuantityParameter (com.ibm.cohort.cql.evaluation.parameters.QuantityParameter)7 Test (org.junit.Test)6 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)4 ParameterDefinition (org.hl7.fhir.r4.model.ParameterDefinition)4 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)3 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)3 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)3 DecimalParameter (com.ibm.cohort.cql.evaluation.parameters.DecimalParameter)3 IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)3 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)3 StringParameter (com.ibm.cohort.cql.evaluation.parameters.StringParameter)3 TimeParameter (com.ibm.cohort.cql.evaluation.parameters.TimeParameter)3 BigDecimal (java.math.BigDecimal)3 RatioParameter (com.ibm.cohort.cql.evaluation.parameters.RatioParameter)2 WireMock.getRequestedFor (com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor)1 WireMock.urlEqualTo (com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo)1 WireMock.urlMatching (com.github.tomakehurst.wiremock.client.WireMock.urlMatching)1 WireMock.verify (com.github.tomakehurst.wiremock.client.WireMock.verify)1 ConceptParameter (com.ibm.cohort.cql.evaluation.parameters.ConceptParameter)1 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)1