diff --git a/pom.xml b/pom.xml
index 6d4c3c9a7..8e14434d0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -138,7 +138,7 @@
gov.cms.madie
madie-rest-commons
- 0.0.6-SNAPSHOT
+ 0.0.8-SNAPSHOT
ca.uhn.hapi.fhir
diff --git a/src/main/java/cms/gov/madie/measure/services/ElmTranslatorClient.java b/src/main/java/cms/gov/madie/measure/services/ElmTranslatorClient.java
index f9a138ada..522bf7996 100644
--- a/src/main/java/cms/gov/madie/measure/services/ElmTranslatorClient.java
+++ b/src/main/java/cms/gov/madie/measure/services/ElmTranslatorClient.java
@@ -15,6 +15,7 @@
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
@@ -28,7 +29,7 @@ public class ElmTranslatorClient {
public ElmJson getElmJson(final String cql, String measureModel, String accessToken) {
try {
- URI uri = getElmJsonURI(measureModel, false);
+ URI uri = getElmJsonURI(measureModel);
HttpEntity cqlEntity = getCqlHttpEntity(cql, accessToken, null, null);
return elmTranslatorRestTemplate
.exchange(uri, HttpMethod.PUT, cqlEntity, ElmJson.class)
@@ -55,13 +56,25 @@ public boolean hasErrors(ElmJson elmJson) {
}
}
- protected URI getElmJsonURI(String measureModel, boolean isForMatTransferred) {
+ protected URI getElmJsonURI(String measureModel) {
var isQdm = StringUtils.equals(measureModel, ModelType.QDM_5_6.getValue());
String baseUrl =
isQdm
? elmTranslatorClientConfig.getQdmCqlElmServiceBaseUrl()
: elmTranslatorClientConfig.getFhirCqlElmServiceBaseUrl();
- return URI.create(baseUrl + elmTranslatorClientConfig.getCqlElmServiceElmJsonUri());
+ URI uri = null;
+ if (!isQdm) {
+ uri =
+ UriComponentsBuilder.fromHttpUrl(
+ baseUrl + elmTranslatorClientConfig.getCqlElmServiceElmJsonUri())
+ .queryParam("checkContext", true)
+ .build()
+ .encode()
+ .toUri();
+ } else {
+ uri = URI.create(baseUrl + elmTranslatorClientConfig.getCqlElmServiceElmJsonUri());
+ }
+ return uri;
}
protected HttpEntity getCqlHttpEntity(
diff --git a/src/main/java/cms/gov/madie/measure/utils/TestCaseServiceUtil.java b/src/main/java/cms/gov/madie/measure/utils/TestCaseServiceUtil.java
index 14b07087f..c023994f9 100644
--- a/src/main/java/cms/gov/madie/measure/utils/TestCaseServiceUtil.java
+++ b/src/main/java/cms/gov/madie/measure/utils/TestCaseServiceUtil.java
@@ -316,13 +316,15 @@ && isEmpty(group.getStratificationValues()))
// Mismatch between target and import Stratification, don't set any expected values
boolean measureHasStrats =
- measureGroups.stream().allMatch(group -> isNotEmpty(group.getStratifications()));
+ measureGroups != null
+ ? measureGroups.stream().allMatch(group -> isNotEmpty(group.getStratifications()))
+ : false;
if ((measureHasStrats && isEmpty(stratification))
|| (!measureHasStrats && isNotEmpty(stratification))) {
return null;
}
- if (measureGroups.size() > 1 && isNotEmpty(stratification)) {
+ if (measureGroups != null && measureGroups.size() > 1 && isNotEmpty(stratification)) {
Deque stratificationQueue = new ArrayDeque<>(stratification);
try {
do {
diff --git a/src/test/java/cms/gov/madie/measure/services/ElmTranslatorClientTest.java b/src/test/java/cms/gov/madie/measure/services/ElmTranslatorClientTest.java
index 5f1bb3a1a..6de013442 100644
--- a/src/test/java/cms/gov/madie/measure/services/ElmTranslatorClientTest.java
+++ b/src/test/java/cms/gov/madie/measure/services/ElmTranslatorClientTest.java
@@ -2,6 +2,7 @@
import cms.gov.madie.measure.config.ElmTranslatorClientConfig;
import cms.gov.madie.measure.exceptions.CqlElmTranslationServiceException;
+import gov.cms.madie.models.common.ModelType;
import gov.cms.madie.models.measure.ElmJson;
import org.junit.jupiter.api.BeforeEach;
@@ -11,6 +12,7 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -22,6 +24,7 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -36,8 +39,13 @@ class ElmTranslatorClientTest {
@InjectMocks private ElmTranslatorClient elmTranslatorClient;
+ private final String HEADER_1 = "api-key";
+
@BeforeEach
void beforeEach() {
+ lenient()
+ .when(elmTranslatorClientConfig.getFhirCqlElmServiceBaseUrl())
+ .thenReturn("http://test");
lenient()
.when(elmTranslatorClientConfig.getQdmCqlElmServiceBaseUrl())
.thenReturn("http://test");
@@ -129,4 +137,19 @@ void testHasErrorsReturnsFalseForMissingField() {
boolean output = elmTranslatorClient.hasErrors(elmJson);
assertThat(output, is(false));
}
+
+ @Test
+ void testQiCoreGetElmJsonURI() {
+ URI uri = elmTranslatorClient.getElmJsonURI(ModelType.QI_CORE.getValue());
+ assertEquals("http://test/cql/translator/cql?checkContext=true", uri.toString());
+ }
+
+ @Test
+ void testGetCqlHttpEntity() {
+ HttpEntity httpEntity =
+ elmTranslatorClient.getCqlHttpEntity("test cql", null, HEADER_1 + "1", "HARP_ID1");
+ HttpHeaders headers = httpEntity.getHeaders();
+ assertEquals(headers.get(HEADER_1).get(0), HEADER_1 + "1");
+ assertEquals(headers.get("harp-id").get(0), "HARP_ID1");
+ }
}