use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class MeasureSupplementalDataEvaluationTest method testProcessAccumulators_notSDESex.
@Test
public void testProcessAccumulators_notSDESex() {
/*
* Jill - I don't like how this part of the code works. The code grabs everything after (and including) the "-",
* and then looks for that to exist as an extension on the Patient resource. This works for race and ethnicity
* on the US-core patient profile, but since we already calculated this in the populate SDE accumulator method
* the only reason it's "recalculating" is because the system and display aren't on the passed in map.
* Plus, it's coded assuming there is a list of extensions within the extension (which is how US-Core handles race and eth)
* and it magically grabs the first one... so if you have multiple this doesn't match all of them.
*/
Code white = new Code();
white.setCode(WHITE_CODE);
Map<String, Map<String, Integer>> sdeAccumulators = getSDEAccumulators(SDE_RACE, null, white, new HashMap<>());
MeasureReport report = new MeasureReport();
Patient mockPatient = mockPatient();
Extension raceExtension = new Extension();
// This can be anything as long as it includes "-race"
raceExtension.setUrl("something-race");
// This example was stolen from https://www.hl7.org/fhir/us/core/Patient-example.xml.html
Extension valueExtension = new Extension();
valueExtension.setUrl("ombCategory");
valueExtension.setValue(getWhiteCoding());
raceExtension.setExtension(Arrays.asList(valueExtension));
Mockito.when(mockPatient.getExtension()).thenReturn(Arrays.asList(raceExtension));
MeasureSupplementalDataEvaluation.processAccumulators(report, sdeAccumulators, true, Arrays.asList(mockPatient));
assertNotNull(report);
// EvaluatedResource should contain a reference to an observation record created for supplemental data
assertEquals(1, report.getEvaluatedResource().size());
// The observation record mentioned previously should exist within the contained resources of the measure report
assertEquals(1, report.getContained().size());
assertTrue(report.getContained().get(0) instanceof Observation);
Observation obs = (Observation) report.getContained().get(0);
// For a single patient, the code of the observation should be the supplemental data text
assertEquals(SDE_RACE, obs.getCode().getText());
// For a single patient, the value of the observation should be the result of the appropriate define
assertTrue(obs.getValue() instanceof CodeableConcept);
assertEquals(WHITE_CODE, ((CodeableConcept) obs.getValue()).getCoding().get(0).getCode());
}
use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class MeasureSupplementalDataEvaluationTest method getMaleCode.
private Code getMaleCode() {
Code male = new Code();
male.setCode(MALE_CODE);
male.setSystem(AdministrativeGender.MALE.getSystem());
male.setDisplay(AdministrativeGender.MALE.getDisplay());
return male;
}
use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class CQLToFHIRMeasureReportHelperTest method testConcept.
@Test
public void testConcept() {
String codeString1 = "code1";
String system1 = "system1";
String display1 = "display1";
String version1 = "version1";
String codeString2 = "code2";
String system2 = "system2";
String display2 = "display2";
String version2 = "version2";
String conceptDisplay = "conceptDisplay";
Code code1 = new Code().withCode(codeString1).withSystem(system1).withDisplay(display1).withVersion(version1);
Code code2 = new Code().withCode(codeString2).withSystem(system2).withDisplay(display2).withVersion(version2);
Concept concept = new Concept().withCodes(Arrays.asList(code1, code2)).withDisplay(conceptDisplay);
IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(concept);
assertTrue(fhirTypeValue instanceof CodeableConcept);
CodeableConcept castResult = (CodeableConcept) fhirTypeValue;
List<Coding> codingList = castResult.getCoding();
boolean code1Found = false;
boolean code2Found = false;
for (Coding coding : codingList) {
if (coding.getCode().equals(codeString1)) {
verifyBaseTypeAsCode(coding, codeString1, system1, display1, version1);
code1Found = true;
} else if (coding.getCode().equals(codeString2)) {
verifyBaseTypeAsCode(coding, codeString2, system2, display2, version2);
code2Found = true;
} else {
Assert.fail();
}
}
assertTrue(code1Found && code2Found);
assertEquals(2, codingList.size());
}
use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class CQLToFHIRMeasureReportHelperTest method testCode.
@Test
public void testCode() {
String codeString = "code";
String system = "system";
String display = "display";
String version = "version";
Code code = new Code().withCode(codeString).withSystem(system).withDisplay(display).withVersion(version);
verifyBaseTypeAsCode(CQLToFHIRMeasureReportHelper.getFhirTypeValue(code), codeString, system, display, version);
}
use of org.opencds.cqf.cql.engine.runtime.Code in project quality-measure-and-cohort-service by Alvearie.
the class RetrieveCacheCodeTest method create.
@Test
public void create() {
String code = "code";
String system = "system";
String display = "display";
String version = "version";
Code source = new Code().withCode(code).withSystem(system).withDisplay(display).withVersion(version);
RetrieveCacheCode expected = new RetrieveCacheCode(code, system, display, version);
RetrieveCacheCode actual = RetrieveCacheCode.create(source);
Assert.assertEquals(expected, actual);
}
Aggregations