use of org.hl7.fhir.r4b.model.BooleanType in project quality-measure-and-cohort-service by Alvearie.
the class CDMMeasureEvaluationTest method testDefinesOnMeasureReport.
@Test
public void testDefinesOnMeasureReport() {
MeasureReport report = new MeasureReport();
Map<VersionedIdentifier, Map<String, Object>> expectedResults = setupTestExpectedResultsContext();
CDMContext defineContext = setupTestDefineContext(expectedResults);
CDMMeasureEvaluation.addDefineEvaluationToReport(report, defineContext, DefineReturnOptions.ALL);
assertEquals(5, report.getExtension().size());
int index = 0;
for (Entry<VersionedIdentifier, Map<String, Object>> expectedLibraryResults : expectedResults.entrySet()) {
for (Entry<String, Object> defineResult : expectedLibraryResults.getValue().entrySet()) {
Extension extension = report.getExtension().get(index++);
assertEquals(MeasureEvidenceHelper.createEvidenceKey(expectedLibraryResults.getKey(), defineResult.getKey()), extension.getExtensionByUrl(CDMConstants.EVIDENCE_TEXT_URL).getValue().primitiveValue());
// hack because Type does not return equals for 2 identical objects :(
Type returnType = extension.getExtensionByUrl(CDMConstants.EVIDENCE_VALUE_URL).getValue();
if (defineResult.getValue() instanceof Boolean) {
assertTrue(returnType.isBooleanPrimitive());
assertEquals(defineResult.getValue(), ((BooleanType) returnType).booleanValue());
} else if (defineResult.getValue() instanceof String) {
assertTrue(returnType.isPrimitive());
assertEquals(defineResult.getValue(), returnType.primitiveValue());
} else if (defineResult.getValue() instanceof DomainResource) {
assertTrue(returnType instanceof Reference);
}
}
}
}
use of org.hl7.fhir.r4b.model.BooleanType in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_report_generated___FHIR_measure_parameters_on_measure_report.
@Test
public void measure_report_generated___FHIR_measure_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);
Map<String, Type> measureParameters = new HashMap<>();
measureParameters.put("base64Param", new Base64BinaryType("AAA"));
measureParameters.put("booleanParam", new BooleanType(false));
measureParameters.put("dateParam", new DateType("2020-01-01"));
measureParameters.put("dateTimeParam", new DateTimeType("2020-01-01T12:00:00"));
measureParameters.put("decimalParam", new DecimalType(12.0));
measureParameters.put("instantParam", new InstantType("2020-01-01T12:00:00-04:00"));
measureParameters.put("integerParam", new IntegerType(1));
measureParameters.put("stringParam", new StringType("str"));
measureParameters.put("timeParam", new TimeType("05:30:00"));
measureParameters.put("uriParam", new UriType("abcde"));
measureParameters.put("codeableConceptParam", new CodeableConcept().setText("display").addCoding(new Coding().setCode("val").setSystem("sys").setDisplay("display")));
measureParameters.put("codingParam", new Coding().setCode("v").setSystem("s").setDisplay("d"));
measureParameters.put("periodParam", new Period().setStart(new Date(1)).setEnd(new Date(2)));
measureParameters.put("quantityParam", new Quantity().setValue(1).setUnit("g"));
measureParameters.put("rangeParam", new Range().setLow(new Quantity().setUnit("g").setValue(1)).setHigh(new Quantity().setUnit("g").setValue(5)));
measureParameters.put("ratioParam", new Ratio().setNumerator(new Quantity().setUnit("g").setValue(1)).setDenominator(new Quantity().setUnit("g").setValue(5)));
List<Extension> parameterExtensions = measureParameters.entrySet().stream().map(x -> createMeasureParameter(x.getKey(), x.getValue())).collect(Collectors.toList());
measure.setExtension(parameterExtensions);
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null);
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(measureParameters.size() + 2, parameterNames.size());
assertTrue(parameterNames.containsAll(measureParameters.keySet()));
assertTrue(parameterNames.contains(CDMConstants.MEASUREMENT_PERIOD));
assertTrue(parameterNames.contains(CDMConstants.PRODUCT_LINE));
}
use of org.hl7.fhir.r4b.model.BooleanType 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 org.hl7.fhir.r4b.model.BooleanType in project quality-measure-and-cohort-service by Alvearie.
the class R4RestFhirTerminologyProviderTest method inOperationReturnsFalseWhenFhirReturnsFalse.
@Test
public void inOperationReturnsFalseWhenFhirReturnsFalse() throws Exception {
ValueSetInfo info = new ValueSetInfo();
info.setId("urn:oid:Test");
Code code = new Code();
code.setSystem(TEST_SYSTEM);
code.setCode(TEST_CODE);
code.setDisplay(TEST_DISPLAY);
Parameters parameters = new Parameters();
parameters.getParameterFirstRep().setName("result").setValue(new BooleanType(false));
mockFhirResourceRetrieval("/ValueSet/Test/$validate-code?code=" + urlencode(code.getCode()) + "&system=" + urlencode(code.getSystem()) + "&_format=json", parameters);
boolean result = provider.in(code, info);
assertFalse(result);
}
use of org.hl7.fhir.r4b.model.BooleanType in project quality-measure-and-cohort-service by Alvearie.
the class R4RestFhirTerminologyProviderTest method inOperationReturnsTrueWhenFhirReturnsTrue.
@Test
public void inOperationReturnsTrueWhenFhirReturnsTrue() throws Exception {
ValueSetInfo info = new ValueSetInfo();
info.setId("urn:oid:Test");
Code code = new Code();
code.setSystem(TEST_SYSTEM);
code.setCode(TEST_CODE);
code.setDisplay(TEST_DISPLAY);
Parameters parameters = new Parameters();
parameters.getParameterFirstRep().setName("result").setValue(new BooleanType(true));
mockFhirResourceRetrieval("/ValueSet/Test/$validate-code?code=" + urlencode(code.getCode()) + "&system=" + urlencode(code.getSystem()) + "&_format=json", parameters);
boolean result = provider.in(code, info);
assertTrue(result);
}
Aggregations