Skip to content

Commit

Permalink
Add check for direct data reference codes
Browse files Browse the repository at this point in the history
  • Loading branch information
chubert-sb committed Oct 13, 2023
1 parent d6f700c commit d044206
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ public List<SourceDataCriteria> getSourceDataCriteria(String cql, String accessT
DataCriteria dataCriteria = parseDataCriteriaFromCql(cql, accessToken);
Map<CQLValueSet, Set<String>> criteriaWithValueSet =
dataCriteria.getDataCriteriaWithValueSets();
if (MapUtils.isEmpty(criteriaWithValueSet)) {

Map<CQLCode, Set<String>> criteriaWithCodes = dataCriteria.getDataCriteriaWithCodes();
if (MapUtils.isEmpty(criteriaWithValueSet) && MapUtils.isEmpty(criteriaWithCodes)) {
log.info("Data criteria not found for given cql");
return Collections.emptyList();
}
Expand All @@ -127,7 +129,6 @@ public List<SourceDataCriteria> getSourceDataCriteria(String cql, String accessT
.collect(Collectors.toList());

// data criteria from direct reference codes
Map<CQLCode, Set<String>> criteriaWithCodes = dataCriteria.getDataCriteriaWithCodes();
List<SourceDataCriteria> codeCriteria =
criteriaWithCodes.entrySet().stream()
.map(criteria -> buildSourceDataCriteriaForCode(criteria.getKey(), criteria.getValue()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,36 @@ void testGetSourceDataCriteriaWhenNoSourceCriteriaFound() {
assertThat(sourceDataCriteria.size(), is(equalTo(0)));
}

@Test
void testGetSourceDataCriteriaWithCriteriaWithCodes() {
String cql =
"library DRCTest version '0.0.000'\n"
+ "using QDM version '5.6'\n"
+ "codesystem \"LOINC\": 'urn:oid:2.16.840.1.113883.6.1'\n"
+ "valueset \"Palliative Care Encounter\": 'urn:oid:2.16.840.1.113883.3.464.1003.101.12.1090'\n"
+ "code \"Functional Assessment of Chronic Illness Therapy - Palliative Care Questionnaire (FACIT-Pal)\": '71007-9' from \"LOINC\" display 'Functional Assessment of Chronic Illness Therapy - Palliative Care Questionnaire (FACIT-Pal)'\n"
+ "parameter \"Measurement Period\" Interval<DateTime>\n"
+ "context Patient\n"
+ "define \"Palliative Care in the Measurement Period\":\n"
+ "( [\"Encounter, Performed\": \"Functional Assessment of Chronic Illness Therapy - Palliative Care Questionnaire (FACIT-Pal)\"]\n"
+ ")";

RequestData data = requestData.toBuilder().cqlData(cql).build();
CqlTranslator translator =
TranslationResource.getInstance(false)
.buildTranslator(data.getCqlDataInputStream(), data.createMap());

Mockito.doNothing()
.when(cqlConversionService)
.setUpLibrarySourceProvider(anyString(), anyString());
when(cqlConversionService.processCqlData(any(RequestData.class))).thenReturn(translator);

List<SourceDataCriteria> sourceDataCriteria =
dataCriteriaService.getSourceDataCriteria(cql, token);

assertThat(sourceDataCriteria.size(), is(equalTo(1)));
}

@Test
void testGetSourceDataCriteriaWhenNoCqlProvided() {
List<SourceDataCriteria> sourceDataCriteria =
Expand Down

0 comments on commit d044206

Please sign in to comment.