From eba02a853e075d9ad599f3716d5773e7c063dd58 Mon Sep 17 00:00:00 2001 From: Rohit Kandimalla Date: Wed, 18 Oct 2023 13:01:07 -0400 Subject: [PATCH 1/3] Updated translatedLibraryMap to store versionedIdentifier.getId() as a string --- .../service/DataCriteriaService.java | 14 ++++++++- .../utils/cql/CQLTools.java | 30 +++++++++---------- .../utils/cql/parsing/Cql2ElmListener.java | 6 ++-- 3 files changed, 31 insertions(+), 19 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 2bcdf67e..1230349b 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 @@ -18,6 +18,7 @@ import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.LibraryBuilder; import org.cqframework.cql.cql2elm.model.CompiledLibrary; +import org.hl7.elm.r1.VersionedIdentifier; import org.springframework.stereotype.Service; import java.io.IOException; @@ -42,12 +43,23 @@ private CQLTools parseCql(String cql, String accessToken) { cqlConversionService.setUpLibrarySourceProvider(cql, accessToken); CqlTranslator cqlTranslator = runTranslator(cql); + Map translatedLibraries = new HashMap<>(); + + for (Map.Entry entry : + cqlTranslator.getTranslatedLibraries().entrySet()) { + VersionedIdentifier versionedIdentifier = entry.getKey(); + CompiledLibrary compiledLibrary = entry.getValue(); + String id = versionedIdentifier.getId(); + translatedLibraries.put(id, compiledLibrary); + } + CQLTools cqlTools = new CQLTools( cql, getIncludedLibrariesCql(librarySourceProvider, cqlTranslator), getParentExpressions(cql), - cqlTranslator); + cqlTranslator, + translatedLibraries); try { cqlTools.generate(); diff --git a/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLTools.java b/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLTools.java index 12864f63..e2bb21ee 100644 --- a/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLTools.java +++ b/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLTools.java @@ -62,7 +62,7 @@ public class CQLTools { private Map qdmTypeInfoMap = new HashMap<>(); - private Map CompiledLibraryMap; + private Map CompiledLibraryMap; /** Map in the form of >. */ private Map> allNamesToReturnTypeMap = new HashMap<>(); @@ -79,26 +79,26 @@ public class CQLTools { Set usedCodeSystems = new HashSet<>(); DataCriteria dataCriteria = new DataCriteria(); - public CQLTools( - String parentLibraryString, - Map childrenLibraries, - List parentExpressions, - CqlTranslator translator) { - - this( - parentLibraryString, - childrenLibraries, - parentExpressions, - translator, - translator.getTranslatedLibraries()); - } + // public CQLTools( + // String parentLibraryString, + // Map childrenLibraries, + // List parentExpressions, + // CqlTranslator translator) { + // + // this( + // parentLibraryString, + // childrenLibraries, + // parentExpressions, + // translator, + // translator.getTranslatedLibraries()); + // } public CQLTools( String parentLibraryString, Map childrenLibraries, List parentExpressions, CqlTranslator translator, - Map translatedLibraries) { + Map translatedLibraries) { this.parentLibraryString = parentLibraryString; this.translator = translator; diff --git a/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/parsing/Cql2ElmListener.java b/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/parsing/Cql2ElmListener.java index f0782f07..8c2ec4eb 100644 --- a/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/parsing/Cql2ElmListener.java +++ b/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/parsing/Cql2ElmListener.java @@ -60,7 +60,7 @@ public class Cql2ElmListener extends cqlBaseListener { private final CompiledLibrary library; /** The map of the other libraries in the current library */ - Map translatedLibraryMap; + Map translatedLibraryMap; /** The current context, aka which expression are we currently in. */ private String currentContext; @@ -84,7 +84,7 @@ public class Cql2ElmListener extends cqlBaseListener { public Cql2ElmListener( CQLGraph graph, CompiledLibrary library, - Map translatedLibraryMap, + Map translatedLibraryMap, Map childrenLibraries) { this.graph = graph; this.library = library; @@ -97,7 +97,7 @@ public Cql2ElmListener( String libraryIdentifier, CQLGraph graph, CompiledLibrary library, - Map translatedLibraryMap, + Map translatedLibraryMap, Map childrenLibraries) { this.graph = graph; this.library = library; From 506ca55bc26ec07af43da01f29536aa78c5ef7b7 Mon Sep 17 00:00:00 2001 From: Rohit Kandimalla Date: Wed, 18 Oct 2023 14:01:03 -0400 Subject: [PATCH 2/3] Refractored the transformation --- .../service/DataCriteriaService.java | 11 +++-------- src/main/resources/application.yaml | 4 ++-- 2 files changed, 5 insertions(+), 10 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 1230349b..835632cb 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 @@ -44,14 +44,9 @@ private CQLTools parseCql(String cql, String accessToken) { CqlTranslator cqlTranslator = runTranslator(cql); Map translatedLibraries = new HashMap<>(); - - for (Map.Entry entry : - cqlTranslator.getTranslatedLibraries().entrySet()) { - VersionedIdentifier versionedIdentifier = entry.getKey(); - CompiledLibrary compiledLibrary = entry.getValue(); - String id = versionedIdentifier.getId(); - translatedLibraries.put(id, compiledLibrary); - } + cqlTranslator + .getTranslatedLibraries() + .forEach((key, value) -> translatedLibraries.put(key.getId(), value)); CQLTools cqlTools = new CQLTools( diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index d99a3e35..be9f560f 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -25,7 +25,7 @@ info: madie: library: service: - baseUrl: ${CQL_LIBRARY_SERVICE_URL:http://localhost:8082/api} + baseUrl: ${CQL_LIBRARY_SERVICE_URL:http://localhost:8083/api} cql: uri: /cql-libraries/cql @@ -41,7 +41,7 @@ logging: okta: oauth2: - issuer: ${OKTA_ISSUER:https://dev-18092578.okta.com/oauth2/default} + issuer: ${OKTA_ISSUER:https://dev-53861726.okta.com/oauth2/default} audience: ${OKTA_AUDIENCE:api://default} lambda-api-key: ${LAMBDA_API_KEY:9202c9fa} From b81300870e5642073087039e681cc3006b8cd4d5 Mon Sep 17 00:00:00 2001 From: Rohit Kandimalla Date: Wed, 18 Oct 2023 14:18:19 -0400 Subject: [PATCH 3/3] Resetting application.yaml to its original configs and removing dead code --- .../cql_elm_translation/utils/cql/CQLTools.java | 14 -------------- src/main/resources/application.yaml | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLTools.java b/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLTools.java index e2bb21ee..dc45aa61 100644 --- a/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLTools.java +++ b/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLTools.java @@ -79,20 +79,6 @@ public class CQLTools { Set usedCodeSystems = new HashSet<>(); DataCriteria dataCriteria = new DataCriteria(); - // public CQLTools( - // String parentLibraryString, - // Map childrenLibraries, - // List parentExpressions, - // CqlTranslator translator) { - // - // this( - // parentLibraryString, - // childrenLibraries, - // parentExpressions, - // translator, - // translator.getTranslatedLibraries()); - // } - public CQLTools( String parentLibraryString, Map childrenLibraries, diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index be9f560f..d99a3e35 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -25,7 +25,7 @@ info: madie: library: service: - baseUrl: ${CQL_LIBRARY_SERVICE_URL:http://localhost:8083/api} + baseUrl: ${CQL_LIBRARY_SERVICE_URL:http://localhost:8082/api} cql: uri: /cql-libraries/cql @@ -41,7 +41,7 @@ logging: okta: oauth2: - issuer: ${OKTA_ISSUER:https://dev-53861726.okta.com/oauth2/default} + issuer: ${OKTA_ISSUER:https://dev-18092578.okta.com/oauth2/default} audience: ${OKTA_AUDIENCE:api://default} lambda-api-key: ${LAMBDA_API_KEY:9202c9fa}