Search in sources :

Example 11 with ParameterDefinition

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testInteger__shouldReturnIntegerParameter.

@Test
public void testInteger__shouldReturnIntegerParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("integer");
    int expectedValue = 10;
    IntegerType fhirValue = new IntegerType(expectedValue);
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    assertEquals(new IntegerParameter(expectedValue), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : IntegerType(org.hl7.fhir.r4.model.IntegerType) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 12 with ParameterDefinition

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testRange__shouldReturnIntervalParameterOfQuantityParameter.

@Test
public void testRange__shouldReturnIntervalParameterOfQuantityParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("Range");
    String lowString = "1.5";
    String highString = "2.5";
    BigDecimal lowValue = new BigDecimal(lowString);
    BigDecimal highValue = new BigDecimal(highString);
    String unit = "ml";
    Range fhirValue = new Range().setLow(new org.hl7.fhir.r4.model.Quantity().setValue(lowValue).setUnit(unit)).setHigh(new org.hl7.fhir.r4.model.Quantity().setValue(highValue).setUnit(unit));
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    IntervalParameter expectedParameter = new IntervalParameter(new QuantityParameter().setUnit(unit).setAmount(lowString), true, new QuantityParameter().setUnit(unit).setAmount(highString), true);
    assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) Range(org.hl7.fhir.r4.model.Range) BigDecimal(java.math.BigDecimal) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 13 with ParameterDefinition

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

the class CDMMeasureEvaluation method createParameterExtension.

protected static Extension createParameterExtension(Context context, String parameterName) {
    Object parameterValue = context.resolveParameterRef(null, parameterName);
    Extension innerExtension = new Extension();
    innerExtension.setUrl(PARAMETER_VALUE_URL);
    IBaseDatatype fhirParameterValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(parameterValue);
    Extension outerExtension = null;
    // Do not create an extension for unsupported types
    if (fhirParameterValue != null) {
        innerExtension.setValue(fhirParameterValue);
        ParameterDefinition parameterDefinition = new ParameterDefinition();
        parameterDefinition.setName(parameterName);
        parameterDefinition.setUse(ParameterDefinition.ParameterUse.IN);
        parameterDefinition.setExtension(Collections.singletonList(innerExtension));
        parameterDefinition.setType(fhirParameterValue.fhirType());
        outerExtension = new Extension();
        outerExtension.setUrl(MEASURE_PARAMETER_VALUE_URL);
        outerExtension.setValue(parameterDefinition);
    }
    return outerExtension;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) IBaseDatatype(org.hl7.fhir.instance.model.api.IBaseDatatype) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition)

Example 14 with ParameterDefinition

use of org.hl7.fhir.r4b.model.ParameterDefinition 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 15 with ParameterDefinition

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

the class R4ParameterDefinitionWithDefaultToCohortParameterConverter method toCohortParameter.

public static Parameter toCohortParameter(ParameterDefinition parameterDefinition) {
    Extension defaultValueExtension = parameterDefinition.getExtensionByUrl(CDMConstants.PARAMETER_DEFAULT_URL);
    Parameter parameter = null;
    if (defaultValueExtension != null) {
        parameter = toCohortParameter(defaultValueExtension);
    }
    return parameter;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) 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)

Aggregations

ParameterDefinition (org.hl7.fhir.r4.model.ParameterDefinition)32 Test (org.junit.Test)26 Extension (org.hl7.fhir.r4.model.Extension)14 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)9 ArrayList (java.util.ArrayList)9 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)9 QuantityParameter (com.ibm.cohort.cql.evaluation.parameters.QuantityParameter)8 StringParameter (com.ibm.cohort.cql.evaluation.parameters.StringParameter)8 Quantity (org.hl7.fhir.r4.model.Quantity)8 Range (org.hl7.fhir.r4.model.Range)8 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)7 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)7 Period (org.hl7.fhir.r4.model.Period)7 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)6 ConceptParameter (com.ibm.cohort.cql.evaluation.parameters.ConceptParameter)6 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)6 DecimalParameter (com.ibm.cohort.cql.evaluation.parameters.DecimalParameter)6 IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)6 RatioParameter (com.ibm.cohort.cql.evaluation.parameters.RatioParameter)6 TimeParameter (com.ibm.cohort.cql.evaluation.parameters.TimeParameter)6