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..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 @@ -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,18 @@ private CQLTools parseCql(String cql, String accessToken) { cqlConversionService.setUpLibrarySourceProvider(cql, accessToken); CqlTranslator cqlTranslator = runTranslator(cql); + Map translatedLibraries = new HashMap<>(); + cqlTranslator + .getTranslatedLibraries() + .forEach((key, value) -> translatedLibraries.put(key.getId(), value)); + 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..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 @@ -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,12 @@ 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, - 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;