use of com.ibm.cohort.cql.evaluation.parameters.CodeParameter in project quality-measure-and-cohort-service by Alvearie.
the class ParameterHelper method resolveCodeParameter.
/**
* Decode command-line encoded parameter
*
* @param value encoded parameter value
* @return decoded parameter value
*/
public static CodeParameter resolveCodeParameter(String value) {
CodeParameter typedValue;
String[] parts;
parts = value.trim().split(":");
typedValue = new CodeParameter().setValue(parts[0]).setSystem(parts[1]).setDisplay(parts[2]);
return typedValue;
}
use of com.ibm.cohort.cql.evaluation.parameters.CodeParameter in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testCoding__shouldReturnCodeParameter.
@Test
public void testCoding__shouldReturnCodeParameter() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("Coding");
Coding fhirValue = makeCoding("sys", "val", "dis", "ver");
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
CodeParameter expectedParameter = new CodeParameter().setSystem("sys").setValue("val").setDisplay("dis").setVersion("ver");
assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
use of com.ibm.cohort.cql.evaluation.parameters.CodeParameter in project quality-measure-and-cohort-service by Alvearie.
the class ParameterHelperTest method testResolveCodeParameter.
@Test
public void testResolveCodeParameter() {
Map<String, Parameter> params = ParameterHelper.parseParameterArguments(Arrays.asList("test:code:1.2.3:SNOMEDCT:Hernia"));
assertEquals(1, params.size());
CodeParameter p = (CodeParameter) params.get("test");
assertNotNull("Parameter with expected name not found", p);
assertEquals("Unexpected value", "1.2.3", p.getValue());
assertEquals("Unexpected value", "SNOMEDCT", p.getSystem());
assertEquals("Unexpected value", "Hernia", p.getDisplay());
}
use of com.ibm.cohort.cql.evaluation.parameters.CodeParameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_report_generated___named_parameters_on_measure_report.
@Test
public void measure_report_generated___named_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);
mockFhirResourceRetrieval(measure);
Map<String, Parameter> parameterMap = new HashMap<>();
parameterMap.put("integerParam", new IntegerParameter(1));
parameterMap.put("decimalParam", new DecimalParameter("1.0"));
parameterMap.put("stringParam", new StringParameter("1"));
parameterMap.put("booleanParam", new BooleanParameter(false));
parameterMap.put("datetimeParam", new DatetimeParameter("2020-01-01"));
parameterMap.put("dateParam", new DateParameter("2020-01-01"));
parameterMap.put("timeParam", new TimeParameter("01:00:00"));
parameterMap.put("quantityParam", new QuantityParameter("1.0", "ml"));
parameterMap.put("ratioParam", new RatioParameter(new QuantityParameter("1.0", "ml"), new QuantityParameter("2.0", "ml")));
parameterMap.put("codeParam", new CodeParameter("1", "2", "3", "4"));
parameterMap.put("conceptParam", new ConceptParameter("1", new CodeParameter("1", "2", "3", "4")));
parameterMap.put("datetimeIntervalParam", new IntervalParameter(new DatetimeParameter("2020-01-01"), true, new DatetimeParameter("2021-01-01"), true));
parameterMap.put("quantityIntervalParam", new IntervalParameter(new QuantityParameter("1.0", "ml"), true, new QuantityParameter("2.0", "ml"), true));
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), parameterMap);
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(parameterMap.size() + 2, parameterNames.size());
assertTrue(parameterNames.containsAll(parameterMap.keySet()));
assertTrue(parameterNames.contains(CDMConstants.MEASUREMENT_PERIOD));
assertTrue(parameterNames.contains(CDMConstants.PRODUCT_LINE));
}
use of com.ibm.cohort.cql.evaluation.parameters.CodeParameter in project quality-measure-and-cohort-service by Alvearie.
the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testCodeableConcept__shouldReturnConceptParameter.
@Test
public void testCodeableConcept__shouldReturnConceptParameter() {
ParameterDefinition parameterDefinition = getBaseParameterDefinition("CodeableConcept");
CodeableConcept fhirValue = new CodeableConcept();
fhirValue.setText("plainText");
fhirValue.addCoding(makeCoding("s1", "val1", "d1", "ver1"));
fhirValue.addCoding(makeCoding("s2", "val2", "d2", "ver2"));
parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
List<CodeParameter> expectedCodeParameters = new ArrayList<>();
expectedCodeParameters.add(new CodeParameter().setSystem("s1").setValue("val1").setDisplay("d1").setVersion("ver1"));
expectedCodeParameters.add(new CodeParameter().setSystem("s2").setValue("val2").setDisplay("d2").setVersion("ver2"));
ConceptParameter expectedParameter = new ConceptParameter().setDisplay("plainText");
expectedParameter.setCodes(expectedCodeParameters);
assertEquals(expectedParameter, R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Aggregations