diff --git a/src/main/java/gov/cms/madie/cqllibraryservice/config/EnvironmentConfig.java b/src/main/java/gov/cms/madie/cqllibraryservice/config/EnvironmentConfig.java index c630948..56c742a 100644 --- a/src/main/java/gov/cms/madie/cqllibraryservice/config/EnvironmentConfig.java +++ b/src/main/java/gov/cms/madie/cqllibraryservice/config/EnvironmentConfig.java @@ -8,8 +8,11 @@ @Configuration public class EnvironmentConfig { - @Value("${madie.cql-elm.service.base-url}") - private String cqlElmServiceBaseUrl; + @Value("${madie.cql-elm.service.qdm-base-url}") + private String qdmCqlElmServiceBaseUrl; + + @Value("${madie.cql-elm.service.fhir-base-url}") + private String fhirCqlElmServiceBaseUrl; @Value("${madie.cql-elm.service.elm-json-uri}") private String cqlElmServiceElmJsonUri; diff --git a/src/main/java/gov/cms/madie/cqllibraryservice/services/ElmTranslatorClient.java b/src/main/java/gov/cms/madie/cqllibraryservice/services/ElmTranslatorClient.java index 85f2526..eb0cbb8 100644 --- a/src/main/java/gov/cms/madie/cqllibraryservice/services/ElmTranslatorClient.java +++ b/src/main/java/gov/cms/madie/cqllibraryservice/services/ElmTranslatorClient.java @@ -27,13 +27,7 @@ public class ElmTranslatorClient { public ElmJson getElmJson(final String cql, String libraryModel, String accessToken) { try { - URI uri = - URI.create( - environmentConfig.getCqlElmServiceBaseUrl() - + (StringUtils.equals(libraryModel, ModelType.QDM_5_6.getValue()) - ? "/qdm" - : "/fhir") - + environmentConfig.getCqlElmServiceElmJsonUri()); + URI uri = getCqlElmTranslationSerivceUri(libraryModel); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); headers.set(HttpHeaders.AUTHORIZATION, accessToken); @@ -48,6 +42,16 @@ public ElmJson getElmJson(final String cql, String libraryModel, String accessTo } } + private URI getCqlElmTranslationSerivceUri(String libraryModel) { + var isQdm = StringUtils.equals(libraryModel, ModelType.QDM_5_6.getValue()); + String baseUrl = + isQdm + ? environmentConfig.getQdmCqlElmServiceBaseUrl() + : environmentConfig.getFhirCqlElmServiceBaseUrl(); + return URI.create( + baseUrl + (isQdm ? "/qdm" : "/fhir") + environmentConfig.getCqlElmServiceElmJsonUri()); + } + public boolean hasErrors(ElmJson elmJson) { if (elmJson == null) { return true; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2cada7d..4be3f80 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,7 +13,8 @@ madie: allowedApi: http://localhost:9000 cql-elm: service: - base-url: ${ELM_TRANSLATOR_SERVICE_URL:http://localhost:8084/api} + qdm-base-url: ${QDM_ELM_TRANSLATOR_SERVICE_URL:http://localhost:8084/api} + fhir-base-url: ${FHIR_ELM_TRANSLATOR_SERVICE_URL:http://localhost:8083/api} elm-json-uri: /cql/translator/cql management: endpoints: @@ -28,7 +29,7 @@ okta: audience: ${OKTA_AUDIENCE:api://default} lambda-api-key: ${LAMBDA_API_KEY:9202c9fa} - + mongock: migration-scan-package: - gov.cms.madie.cqllibraryservice.config diff --git a/src/test/java/gov/cms/madie/cqllibraryservice/services/ElmTranslatorClientTest.java b/src/test/java/gov/cms/madie/cqllibraryservice/services/ElmTranslatorClientTest.java index 17a27c9..692efc2 100644 --- a/src/test/java/gov/cms/madie/cqllibraryservice/services/ElmTranslatorClientTest.java +++ b/src/test/java/gov/cms/madie/cqllibraryservice/services/ElmTranslatorClientTest.java @@ -11,6 +11,7 @@ import gov.cms.madie.cqllibraryservice.config.EnvironmentConfig; import gov.cms.madie.cqllibraryservice.exceptions.CqlElmTranslationServiceException; +import gov.cms.madie.models.common.ModelType; import gov.cms.madie.models.measure.ElmJson; import java.net.URI; import org.junit.jupiter.api.BeforeEach; @@ -36,7 +37,12 @@ class ElmTranslatorClientTest { @BeforeEach void beforeEach() { - lenient().when(environmentConfig.getCqlElmServiceBaseUrl()).thenReturn("http://test"); + lenient() + .when(environmentConfig.getQdmCqlElmServiceBaseUrl()) + .thenReturn("http://test/api/qdm"); + lenient() + .when(environmentConfig.getFhirCqlElmServiceBaseUrl()) + .thenReturn("http://test/api/fhir"); lenient() .when(environmentConfig.getCqlElmServiceElmJsonUri()) .thenReturn("/cql/translator/cql"); @@ -58,7 +64,8 @@ void testRestTemplateReturnsElmJson() { when(restTemplate.exchange( any(URI.class), eq(HttpMethod.PUT), any(HttpEntity.class), any(Class.class))) .thenReturn(ResponseEntity.ok(elmJson)); - ElmJson output = elmTranslatorClient.getElmJson("TEST_CQL", "QDM v5.6", "TEST_TOKEN"); + ElmJson output = + elmTranslatorClient.getElmJson("TEST_CQL", ModelType.QI_CORE.getValue(), "TEST_TOKEN"); assertThat(output, is(equalTo(elmJson))); }