From d044206610aba5c4e36ec2f6875dfd37b0a7edf2 Mon Sep 17 00:00:00 2001 From: Christopher Hubert Date: Fri, 13 Oct 2023 11:35:41 -0400 Subject: [PATCH 1/2] Add check for direct data reference codes --- .../service/DataCriteriaService.java | 5 ++-- .../service/DataCriteriaServiceTest.java | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaService.java b/src/main/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaService.java index ffef4abe..2bcdf67e 100644 --- a/src/main/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaService.java +++ b/src/main/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaService.java @@ -114,7 +114,9 @@ public List getSourceDataCriteria(String cql, String accessT DataCriteria dataCriteria = parseDataCriteriaFromCql(cql, accessToken); Map> criteriaWithValueSet = dataCriteria.getDataCriteriaWithValueSets(); - if (MapUtils.isEmpty(criteriaWithValueSet)) { + + Map> criteriaWithCodes = dataCriteria.getDataCriteriaWithCodes(); + if (MapUtils.isEmpty(criteriaWithValueSet) && MapUtils.isEmpty(criteriaWithCodes)) { log.info("Data criteria not found for given cql"); return Collections.emptyList(); } @@ -127,7 +129,6 @@ public List getSourceDataCriteria(String cql, String accessT .collect(Collectors.toList()); // data criteria from direct reference codes - Map> criteriaWithCodes = dataCriteria.getDataCriteriaWithCodes(); List codeCriteria = criteriaWithCodes.entrySet().stream() .map(criteria -> buildSourceDataCriteriaForCode(criteria.getKey(), criteria.getValue())) diff --git a/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java b/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java index 00033739..26386edb 100644 --- a/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java +++ b/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java @@ -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\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 = + dataCriteriaService.getSourceDataCriteria(cql, token); + + assertThat(sourceDataCriteria.size(), is(equalTo(1))); + } + @Test void testGetSourceDataCriteriaWhenNoCqlProvided() { List sourceDataCriteria = From 27f8a625df1fc888d387af16354fa308dc4711ae Mon Sep 17 00:00:00 2001 From: Christopher Hubert Date: Tue, 17 Oct 2023 10:26:29 -0400 Subject: [PATCH 2/2] fix test --- .../cql_elm_translation/service/DataCriteriaServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java b/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java index f21e2ed8..0ae3393f 100644 --- a/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java +++ b/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java @@ -136,7 +136,7 @@ void testGetSourceDataCriteriaWithCriteriaWithCodes() { RequestData data = requestData.toBuilder().cqlData(cql).build(); CqlTranslator translator = TranslationResource.getInstance(false) - .buildTranslator(data.getCqlDataInputStream(), data.createMap()); + .buildTranslator(data.getCqlDataInputStream(), data.createMap(), data.getSourceInfo()); Mockito.doNothing() .when(cqlConversionService)