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));
}
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));
}
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;
}
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());
}
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;
}
Aggregations