use of org.hl7.fhir.r4.model.BooleanType in project cqf-ruler by DBCG.
the class CqlExecutionProviderIT method testDataBundleCqlExecutionProviderWithSubject.
@Test
public void testDataBundleCqlExecutionProviderWithSubject() throws Exception {
Parameters params = new Parameters();
Parameters libraryParameter = new Parameters();
params.addParameter().setName("subject").setValue(new StringType("Patient/SimplePatient"));
libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
params.addParameter().setName("library").setResource(libraryParameter);
params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
loadResource(packagePrefix + "SimpleDstu3Library.json");
loadResource(packagePrefix + "SimplePatient.json");
Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
params.addParameter().setName("data").setResource(data);
params.addParameter().setName("useServerData").setValue(new BooleanType(false));
Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
logger.debug("Results: ", results);
}
use of org.hl7.fhir.r4.model.BooleanType in project cqf-ruler by DBCG.
the class CqlExecutionProviderIT method testDataBundleCqlExecutionProvider.
@Test
public void testDataBundleCqlExecutionProvider() throws Exception {
Parameters params = new Parameters();
Parameters libraryParameter = new Parameters();
libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
params.addParameter().setName("library").setResource(libraryParameter);
params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
loadResource(packagePrefix + "SimpleDstu3Library.json");
loadResource(packagePrefix + "SimplePatient.json");
Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
params.addParameter().setName("data").setResource(data);
params.addParameter().setName("useServerData").setValue(new BooleanType(false));
Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
logger.debug("Results: ", results);
}
use of org.hl7.fhir.r4.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.r4.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.r4.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));
}
Aggregations