use of com.ibm.cohort.cql.evaluation.parameters.BooleanParameter in project quality-measure-and-cohort-service by Alvearie.
the class ParameterHelperTest method testResolveBooleanParameter.
@Test
public void testResolveBooleanParameter() {
Map<String, Parameter> params = ParameterHelper.parseParameterArguments(Arrays.asList("test:boolean:true"));
assertEquals(1, params.size());
BooleanParameter p = (BooleanParameter) params.get("test");
assertNotNull("Parameter with expected name not found", p);
assertEquals("Unexpected value", true, p.getValue());
}
use of com.ibm.cohort.cql.evaluation.parameters.BooleanParameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method id_based_library_link___successfully_loaded_and_evaluated.
@Test
public void id_based_library_link___successfully_loaded_and_evaluated() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.cql");
Measure measure = getCareGapMeasure("IDBasedLibraryMeasure", library, expressionsByPopulationType, "CareGap1", "CareGap2");
measure.setLibrary(Arrays.asList(new CanonicalType("Library/" + library.getId())));
mockFhirResourceRetrieval(measure);
Map<String, Parameter> passingParameters = new HashMap<>();
passingParameters.put("InInitialPopulation", new BooleanParameter(true));
List<MeasureContext> measureContexts = new ArrayList<>();
measureContexts.add(new MeasureContext(measure.getId(), passingParameters));
List<MeasureReport> reports = evaluator.evaluatePatientMeasures(patient.getId(), measureContexts);
assertEquals(1, reports.size());
MeasureReport report = reports.get(0);
verifyStandardPopulationCounts(report);
verify(1, getRequestedFor(urlEqualTo("/Library/" + library.getId() + "?_format=json")));
}
use of com.ibm.cohort.cql.evaluation.parameters.BooleanParameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method multilevel_library_dependencies___successfully_loaded_and_evaluated.
@Test
public void multilevel_library_dependencies___successfully_loaded_and_evaluated() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library nestedHelperLibrary = mockLibraryRetrieval("NestedChild", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-nested-child.cql");
Library helperLibrary = mockLibraryRetrieval("Child", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-child.cql");
helperLibrary.addRelatedArtifact(asRelation(nestedHelperLibrary));
Library library = mockLibraryRetrieval("Parent", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-parent.cql");
library.addRelatedArtifact(asRelation(helperLibrary));
Measure measure = getCareGapMeasure("NestedLibraryMeasure", library, expressionsByPopulationType, "CareGap1", "CareGap2");
mockFhirResourceRetrieval(measure);
Map<String, Parameter> passingParameters = new HashMap<>();
passingParameters.put("InInitialPopulation", new BooleanParameter(true));
List<MeasureContext> measureContexts = new ArrayList<>();
measureContexts.add(new MeasureContext(measure.getId(), passingParameters));
List<MeasureReport> reports = evaluator.evaluatePatientMeasures(patient.getId(), measureContexts);
assertEquals(1, reports.size());
MeasureReport report = reports.get(0);
verifyStandardPopulationCounts(report);
}
use of com.ibm.cohort.cql.evaluation.parameters.BooleanParameter in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testBoolean__shouldReturnBooleanParameter.
@Test
public void testBoolean__shouldReturnBooleanParameter() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("boolean");
BooleanType fhirValue = new BooleanType(true);
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
assertEquals(new BooleanParameter(true), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
use of com.ibm.cohort.cql.evaluation.parameters.BooleanParameter 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;
}
Aggregations