Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-6212: Add check for direct data reference codes #104

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -119,6 +119,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(), data.getSourceInfo());

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
Loading