Skip to content

Commit

Permalink
Merge pull request #106 from MeasureAuthoringTool/feature/MAT-6312
Browse files Browse the repository at this point in the history
Updated translatedLibraryMap to store versionedIdentifier.getId() as …
  • Loading branch information
RohitKandimalla authored Oct 18, 2023
2 parents c0d2e0a + b813008 commit bdecdc8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,12 +43,18 @@ private CQLTools parseCql(String cql, String accessToken) {
cqlConversionService.setUpLibrarySourceProvider(cql, accessToken);
CqlTranslator cqlTranslator = runTranslator(cql);

Map<String, CompiledLibrary> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class CQLTools {

private Map<String, String> qdmTypeInfoMap = new HashMap<>();

private Map<VersionedIdentifier, CompiledLibrary> CompiledLibraryMap;
private Map<String, CompiledLibrary> CompiledLibraryMap;

/** Map in the form of <LibraryName-x.x.xxx, <ExpressionName, ReturnType>>. */
private Map<String, Map<String, String>> allNamesToReturnTypeMap = new HashMap<>();
Expand All @@ -79,26 +79,12 @@ public class CQLTools {
Set<String> usedCodeSystems = new HashSet<>();
DataCriteria dataCriteria = new DataCriteria();

public CQLTools(
String parentLibraryString,
Map<String, String> childrenLibraries,
List<String> parentExpressions,
CqlTranslator translator) {

this(
parentLibraryString,
childrenLibraries,
parentExpressions,
translator,
translator.getTranslatedLibraries());
}

public CQLTools(
String parentLibraryString,
Map<String, String> childrenLibraries,
List<String> parentExpressions,
CqlTranslator translator,
Map<VersionedIdentifier, CompiledLibrary> translatedLibraries) {
Map<String, CompiledLibrary> translatedLibraries) {

this.parentLibraryString = parentLibraryString;
this.translator = translator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class Cql2ElmListener extends cqlBaseListener {
private final CompiledLibrary library;

/** The map of the other libraries in the current library */
Map<VersionedIdentifier, CompiledLibrary> translatedLibraryMap;
Map<String, CompiledLibrary> translatedLibraryMap;

/** The current context, aka which expression are we currently in. */
private String currentContext;
Expand All @@ -84,7 +84,7 @@ public class Cql2ElmListener extends cqlBaseListener {
public Cql2ElmListener(
CQLGraph graph,
CompiledLibrary library,
Map<VersionedIdentifier, CompiledLibrary> translatedLibraryMap,
Map<String, CompiledLibrary> translatedLibraryMap,
Map<String, String> childrenLibraries) {
this.graph = graph;
this.library = library;
Expand All @@ -97,7 +97,7 @@ public Cql2ElmListener(
String libraryIdentifier,
CQLGraph graph,
CompiledLibrary library,
Map<VersionedIdentifier, CompiledLibrary> translatedLibraryMap,
Map<String, CompiledLibrary> translatedLibraryMap,
Map<String, String> childrenLibraries) {
this.graph = graph;
this.library = library;
Expand Down

0 comments on commit bdecdc8

Please sign in to comment.