translatedLibraries) {
-
- this.parentLibraryString = parentLibraryString;
- this.translator = translator;
- this.library = translator.getTranslatedLibrary();
- this.childrenLibraries = childrenLibraries;
- this.CompiledLibraryMap = translatedLibraries;
- this.parentExpressions = parentExpressions;
- }
-
- /**
- * The CQL Filter Entry Point.
- *
- * This function will find all of the used CQL expressions, create a valueset - datatype map and code - datatype map,
- * and find return types for each expression.
- *
- * @throws IOException
- */
- public void generate() throws IOException {
- InputStream stream = new ByteArrayInputStream(this.parentLibraryString.getBytes(StandardCharsets.UTF_8));
- cqlLexer lexer = new cqlLexer(CharStreams.fromStream(stream));
- CommonTokenStream tokens = new CommonTokenStream(lexer);
- cqlParser parser = new cqlParser(tokens);
-
- CQLGraph graph = new CQLGraph();
- Cql2ElmListener listener = new Cql2ElmListener(graph, library, CompiledLibraryMap, childrenLibraries);
- ParseTree tree = parser.library();
- CqlPreprocessorVisitor preprocessor = new CqlPreprocessorVisitor();
- preprocessor.setTokenStream(tokens);
- preprocessor.visit(tree);
- ParseTreeWalker walker = new ParseTreeWalker();
- walker.walk(listener, tree);
-
- Set librariesSet = new HashSet<>(listener.getLibraries());
- Set valuesetsSet = new HashSet<>(listener.getValuesets());
- Set codesSet = new HashSet<>(listener.getCodes());
- Set codesystemsSet = new HashSet<>(listener.getCodesystems());
- Set parametersSet = new HashSet<>(listener.getParameters());
- Set definitionsSet = new HashSet<>(listener.getDefinitions());
- Set functionsSet = new HashSet<>(listener.getFunctions());
- Map>> valuesetMap = new HashMap<>(listener.getValueSetDataTypeMap());
- Map>> codeMap = new HashMap<>(listener.getCodeDataTypeMap());
- Map valueSetOids = new HashMap<>(listener.getValueSetOids());
-
- collectUsedExpressions(graph, librariesSet, valuesetsSet, codesSet, codesystemsSet, parametersSet, definitionsSet, functionsSet);
- collectValueSetCodeDataType(valuesetMap, codeMap);
- collectReturnTypeMap();
- collectDataCriteria(valueSetOids);
- }
- private void collectDataCriteria(Map valueSetOids) {
- valuesetDataTypeMap.keySet().forEach(vs ->
- dataCriteria.getDataCriteriaWithValueSets().put(
- CQLValueSet.builder()
- .name(vs)
- .oid(valueSetOids.get(vs))
- .build(),
- valuesetDataTypeMap.get(vs)));
-
- codeDataTypeMap.keySet().forEach(code ->
- dataCriteria.getDataCriteriaWithCodes().put(
- CQLCode.builder()
- .codeName(code)
- //TODO lookup code & code system details
- .codeOID("shrug")
- .codeSystemName("shrug")
- .codeSystemOID("shrug")
- .build(),
- codeDataTypeMap.get(code)));
- }
-
- private void collectUsedExpressions(CQLGraph graph, Set librariesSet, Set valuesetsSet, Set codesSet,
- Set codesystemsSet, Set parametersSet, Set definitionsSet,
- Set functionsSet) {
- List libraries = new ArrayList<>(librariesSet);
- List valuesets = new ArrayList<>(valuesetsSet);
- List codes = new ArrayList<>(codesSet);
- List codesystems = new ArrayList<>(codesystemsSet);
- List parameters = new ArrayList<>(parametersSet);
- List definitions = new ArrayList<>(definitionsSet);
- List functions = new ArrayList<>(functionsSet);
-
- for (String parentExpression : parentExpressions) {
- collectUsedLibraries(graph, libraries, parentExpression);
- collectUsedValuesets(graph, valuesets, parentExpression);
- collectUsedCodes(graph, codes, parentExpression);
- collectUsedCodeSystems(graph, codesystems, parentExpression);
- collectUsedParameters(graph, parameters, parentExpression);
- collectUsedDefinitions(graph, definitions, parentExpression);
- collectUsedFunctions(graph, functions, parentExpression);
- }
- }
-
- /**
- * For every function reference from the listener, checks if the parent expression and the function make a path.
- * If it does make a path, that means the function is used and should therefore be added to the used functions list.
- *
- * @param graph the graph
- * @param functions the function references from the listener
- * @param parentExpression the parent expression to check
- */
- private void collectUsedFunctions(CQLGraph graph, List functions, String parentExpression) {
- for (String function : functions) {
- if (graph.isPath(parentExpression, function)) {
- usedFunctions.add(function);
- }
- }
- }
-
- /**
- * For every definition reference from the listener, checks if the parent expression and the definition make a path.
- * If it does make a path, that means the definition is used and should therefore be added to the used definitions list.
- *
- * @param graph the graph
- * @param definitions the definition references from the listener
- * @param parentExpression the parent expression to check
- */
- private void collectUsedDefinitions(CQLGraph graph, List definitions, String parentExpression) {
- for (String definition : definitions) {
- if (graph.isPath(parentExpression, definition) && !definition.equalsIgnoreCase("Patient") && !definition.equalsIgnoreCase("Population")) {
- usedDefinitions.add(definition);
- }
- }
- }
-
- /**
- * For every parameter reference from the listener, checks if the parent expression and the parameter make a path.
- * If it does make a path, that means the parameter is used and should therefore be added to the used parameters list.
- *
- * @param graph the graph
- * @param parameters the parameter references from the listener
- * @param parentExpression the parent expression to check
- */
- private void collectUsedParameters(CQLGraph graph, List parameters, String parentExpression) {
- for (String parameter : parameters) {
- if (graph.isPath(parentExpression, parameter)) {
- usedParameters.add(parameter);
- }
- }
- }
-
- /**
- * For every code reference from the listener, checks if the parent expression and the code make a path.
- * If it does make a path, that means the code is used and should therefore be added to the used codes list.
- *
- * @param graph the graph
- * @param codes the code references from the listener
- * @param parentExpression the parent expression to check
- */
- private void collectUsedCodes(CQLGraph graph, List codes, String parentExpression) {
- for (String code : codes) {
- if (graph.isPath(parentExpression, code)) {
- usedCodes.add(code);
- }
- }
- }
-
- /**
- * For every codesystem reference from the listener, checks if the parent expression and the codesystem make a path.
- * If it does make a path, that means the codesystem is used and should therefore be added to the used codesystems list.
- *
- * @param graph the graph
- * @param codesystems the code references from the listener
- * @param parentExpression the parent expression to check
- */
- private void collectUsedCodeSystems(CQLGraph graph, List codesystems, String parentExpression) {
- for (String codesystem : codesystems) {
- if (graph.isPath(parentExpression, codesystem)) {
- usedCodeSystems.add(codesystem);
- }
- }
- }
-
- /**
- * For every valueset reference from the listener, checks if the parent expression and the valueset make a path.
- * If it does make a path, that means the valueset is used and should therefore be added to the used valuesets list.
- *
- * @param graph the graph
- * @param valuesets the valueset references from the listener
- * @param parentExpression the parent expression to check
- */
- private void collectUsedValuesets(CQLGraph graph, List valuesets, String parentExpression) {
- for (String valueset : valuesets) {
- if (graph.isPath(parentExpression, valueset)) {
- usedValuesets.add(valueset);
- }
+ private String parentLibraryString;
+ private Map childrenLibraries;
+ private CompiledLibrary library;
+ private CqlTranslator translator;
+
+ /** Maps a valueset identifier to the datatypes it is using. */
+ private Map> valuesetDataTypeMap = new HashMap<>();
+
+ /** Maps a code identifier to the datatypes it is using */
+ private Map> codeDataTypeMap = new HashMap<>();
+
+ /** Maps an expression, to it's internal valueset - datatype map */
+ private Map>> expressionNameToValuesetDataTypeMap =
+ new HashMap<>();
+
+ /** Maps an expression, to it's internal code - datatype map */
+ private Map>> expressionNameToCodeDataTypeMap = new HashMap<>();
+
+ /** Maps an expression name to its return type (only function and definitions) */
+ private Map nameToReturnTypeMap = new HashMap<>();
+
+ /**
+ * The list of parent expressions. Often times, these are populations from MAT. Anything that can
+ * be reached from this node in the graph should be considered used.
+ */
+ private List parentExpressions = new ArrayList<>();
+
+ private Map qdmTypeInfoMap = new HashMap<>();
+
+ private Map CompiledLibraryMap;
+
+ /** Map in the form of >. */
+ private Map> allNamesToReturnTypeMap = new HashMap<>();
+
+ private Map expressionToReturnTypeMap = new HashMap<>();
+
+ // used expression sets
+ Set usedLibraries = new HashSet<>();
+ Set usedCodes = new HashSet<>();
+ Set usedValuesets = new HashSet<>();
+ Set usedParameters = new HashSet<>();
+ Set usedDefinitions = new HashSet<>();
+ Set usedFunctions = new HashSet<>();
+ 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) {
+
+ this.parentLibraryString = parentLibraryString;
+ this.translator = translator;
+ this.library = translator.getTranslatedLibrary();
+ this.childrenLibraries = childrenLibraries;
+ this.CompiledLibraryMap = translatedLibraries;
+ this.parentExpressions = parentExpressions;
+ }
+
+ /**
+ * The CQL Filter Entry Point.
+ *
+ * This function will find all of the used CQL expressions, create a valueset - datatype map
+ * and code - datatype map, and find return types for each expression.
+ *
+ * @throws IOException
+ */
+ public void generate() throws IOException {
+ InputStream stream =
+ new ByteArrayInputStream(this.parentLibraryString.getBytes(StandardCharsets.UTF_8));
+ cqlLexer lexer = new cqlLexer(CharStreams.fromStream(stream));
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ cqlParser parser = new cqlParser(tokens);
+
+ CQLGraph graph = new CQLGraph();
+ Cql2ElmListener listener =
+ new Cql2ElmListener(graph, library, CompiledLibraryMap, childrenLibraries);
+ ParseTree tree = parser.library();
+ CqlPreprocessorVisitor preprocessor = new CqlPreprocessorVisitor();
+ preprocessor.setTokenStream(tokens);
+ preprocessor.visit(tree);
+ ParseTreeWalker walker = new ParseTreeWalker();
+ walker.walk(listener, tree);
+
+ Set librariesSet = new HashSet<>(listener.getLibraries());
+ Set valuesetsSet = new HashSet<>(listener.getValuesets());
+ Set codesSet = new HashSet<>(listener.getCodes());
+ Set codesystemsSet = new HashSet<>(listener.getCodesystems());
+ Set parametersSet = new HashSet<>(listener.getParameters());
+ Set definitionsSet = new HashSet<>(listener.getDefinitions());
+ Set functionsSet = new HashSet<>(listener.getFunctions());
+ Map>> valuesetMap =
+ new HashMap<>(listener.getValueSetDataTypeMap());
+ Map>> codeMap = new HashMap<>(listener.getCodeDataTypeMap());
+ Map valueSetOids = new HashMap<>(listener.getValueSetOids());
+
+ collectUsedExpressions(
+ graph,
+ librariesSet,
+ valuesetsSet,
+ codesSet,
+ codesystemsSet,
+ parametersSet,
+ definitionsSet,
+ functionsSet);
+ collectValueSetCodeDataType(valuesetMap, codeMap);
+ collectReturnTypeMap();
+ collectDataCriteria(valueSetOids);
+ }
+
+ private void collectDataCriteria(Map valueSetOids) {
+ valuesetDataTypeMap
+ .keySet()
+ .forEach(
+ vs ->
+ dataCriteria
+ .getDataCriteriaWithValueSets()
+ .put(
+ CQLValueSet.builder().name(vs).oid(valueSetOids.get(vs)).build(),
+ valuesetDataTypeMap.get(vs)));
+
+ codeDataTypeMap
+ .keySet()
+ .forEach(
+ code ->
+ dataCriteria
+ .getDataCriteriaWithCodes()
+ .put(
+ CQLCode.builder()
+ .codeName(code)
+ // TODO lookup code & code system details
+ .codeOID("shrug")
+ .codeSystemName("shrug")
+ .codeSystemOID("shrug")
+ .build(),
+ codeDataTypeMap.get(code)));
+ }
+
+ private void collectUsedExpressions(
+ CQLGraph graph,
+ Set librariesSet,
+ Set valuesetsSet,
+ Set codesSet,
+ Set codesystemsSet,
+ Set parametersSet,
+ Set definitionsSet,
+ Set functionsSet) {
+ List libraries = new ArrayList<>(librariesSet);
+ List valuesets = new ArrayList<>(valuesetsSet);
+ List codes = new ArrayList<>(codesSet);
+ List codesystems = new ArrayList<>(codesystemsSet);
+ List parameters = new ArrayList<>(parametersSet);
+ List definitions = new ArrayList<>(definitionsSet);
+ List functions = new ArrayList<>(functionsSet);
+
+ for (String parentExpression : parentExpressions) {
+ collectUsedLibraries(graph, libraries, parentExpression);
+ collectUsedValuesets(graph, valuesets, parentExpression);
+ collectUsedCodes(graph, codes, parentExpression);
+ collectUsedCodeSystems(graph, codesystems, parentExpression);
+ collectUsedParameters(graph, parameters, parentExpression);
+ collectUsedDefinitions(graph, definitions, parentExpression);
+ collectUsedFunctions(graph, functions, parentExpression);
+ }
+ }
+
+ /**
+ * For every function reference from the listener, checks if the parent expression and the
+ * function make a path. If it does make a path, that means the function is used and should
+ * therefore be added to the used functions list.
+ *
+ * @param graph the graph
+ * @param functions the function references from the listener
+ * @param parentExpression the parent expression to check
+ */
+ private void collectUsedFunctions(
+ CQLGraph graph, List functions, String parentExpression) {
+ for (String function : functions) {
+ if (graph.isPath(parentExpression, function)) {
+ usedFunctions.add(function);
+ }
+ }
+ }
+
+ /**
+ * For every definition reference from the listener, checks if the parent expression and the
+ * definition make a path. If it does make a path, that means the definition is used and should
+ * therefore be added to the used definitions list.
+ *
+ * @param graph the graph
+ * @param definitions the definition references from the listener
+ * @param parentExpression the parent expression to check
+ */
+ private void collectUsedDefinitions(
+ CQLGraph graph, List definitions, String parentExpression) {
+ for (String definition : definitions) {
+ if (graph.isPath(parentExpression, definition)
+ && !definition.equalsIgnoreCase("Patient")
+ && !definition.equalsIgnoreCase("Population")) {
+ usedDefinitions.add(definition);
+ }
+ }
+ }
+
+ /**
+ * For every parameter reference from the listener, checks if the parent expression and the
+ * parameter make a path. If it does make a path, that means the parameter is used and should
+ * therefore be added to the used parameters list.
+ *
+ * @param graph the graph
+ * @param parameters the parameter references from the listener
+ * @param parentExpression the parent expression to check
+ */
+ private void collectUsedParameters(
+ CQLGraph graph, List parameters, String parentExpression) {
+ for (String parameter : parameters) {
+ if (graph.isPath(parentExpression, parameter)) {
+ usedParameters.add(parameter);
+ }
+ }
+ }
+
+ /**
+ * For every code reference from the listener, checks if the parent expression and the code make a
+ * path. If it does make a path, that means the code is used and should therefore be added to the
+ * used codes list.
+ *
+ * @param graph the graph
+ * @param codes the code references from the listener
+ * @param parentExpression the parent expression to check
+ */
+ private void collectUsedCodes(CQLGraph graph, List codes, String parentExpression) {
+ for (String code : codes) {
+ if (graph.isPath(parentExpression, code)) {
+ usedCodes.add(code);
+ }
+ }
+ }
+
+ /**
+ * For every codesystem reference from the listener, checks if the parent expression and the
+ * codesystem make a path. If it does make a path, that means the codesystem is used and should
+ * therefore be added to the used codesystems list.
+ *
+ * @param graph the graph
+ * @param codesystems the code references from the listener
+ * @param parentExpression the parent expression to check
+ */
+ private void collectUsedCodeSystems(
+ CQLGraph graph, List codesystems, String parentExpression) {
+ for (String codesystem : codesystems) {
+ if (graph.isPath(parentExpression, codesystem)) {
+ usedCodeSystems.add(codesystem);
+ }
+ }
+ }
+
+ /**
+ * For every valueset reference from the listener, checks if the parent expression and the
+ * valueset make a path. If it does make a path, that means the valueset is used and should
+ * therefore be added to the used valuesets list.
+ *
+ * @param graph the graph
+ * @param valuesets the valueset references from the listener
+ * @param parentExpression the parent expression to check
+ */
+ private void collectUsedValuesets(
+ CQLGraph graph, List valuesets, String parentExpression) {
+ for (String valueset : valuesets) {
+ if (graph.isPath(parentExpression, valueset)) {
+ usedValuesets.add(valueset);
+ }
+ }
+ }
+
+ /**
+ * For every library reference from the listener, checks if the parent expression and the library
+ * make a path. If it does make a path, that means the library is used and should therefore be
+ * added to the used libraries list.
+ *
+ * @param graph the graph
+ * @param libraries the library references from the listener
+ * @param parentExpression the parent expression to check
+ */
+ private void collectUsedLibraries(
+ CQLGraph graph, List libraries, String parentExpression) {
+ for (String library : libraries) {
+ if (graph.isPath(parentExpression, library)) {
+ usedLibraries.add(library);
+ }
+ }
+ }
+
+ /** Collects and creates a mapping of expression names to return types. */
+ private void collectReturnTypeMap() {
+ // the following makes an assumption that a library can not have any duplicate libraries
+ // declared in it.
+
+ // statements contain all function and definitions.
+ Library.Statements statements = this.library.getLibrary().getStatements();
+ Library.Parameters parameters = this.library.getLibrary().getParameters();
+ String libraryName = this.library.getIdentifier().getId();
+ String libraryVersion = this.library.getIdentifier().getVersion();
+ this.allNamesToReturnTypeMap.put(libraryName + "-" + libraryVersion, new HashMap<>());
+
+ for (ExpressionDef expression : statements.getDef()) {
+ this.allNamesToReturnTypeMap
+ .get(libraryName + "-" + libraryVersion)
+ .put(expression.getName(), expression.getResultType().toString());
+ this.nameToReturnTypeMap.put(expression.getName(), expression.getResultType().toString());
+ this.expressionToReturnTypeMap.put(
+ expression.getName(), expression.getResultType().toString());
+ }
+
+ if (parameters != null) {
+ for (ParameterDef parameter : parameters.getDef()) {
+ this.allNamesToReturnTypeMap
+ .get(libraryName + "-" + libraryVersion)
+ .put(parameter.getName(), parameter.getResultType().toString());
+ this.nameToReturnTypeMap.put(parameter.getName(), parameter.getResultType().toString());
+ this.expressionToReturnTypeMap.put(
+ parameter.getName(), parameter.getResultType().toString());
+ }
+ }
+
+ if (null != this.library.getLibrary().getIncludes()) {
+ for (IncludeDef include : this.library.getLibrary().getIncludes().getDef()) {
+ // CompiledLibrary lib = this.CompiledLibraryMap.get(include.getPath() + "-"
+ // + include.getVersion());
+ CompiledLibrary lib = this.CompiledLibraryMap.get(include.getPath());
+
+ Library.Statements statementsFromIncludedLibrary = lib.getLibrary().getStatements();
+ Library.Parameters parametersFromIncludedLibrary = lib.getLibrary().getParameters();
+ String includedLibraryName = lib.getIdentifier().getId();
+ String includedLibraryVersion = lib.getIdentifier().getVersion();
+ this.allNamesToReturnTypeMap.put(
+ includedLibraryName + "-" + includedLibraryVersion, new HashMap<>());
+
+ for (ExpressionDef expression : statementsFromIncludedLibrary.getDef()) {
+ this.allNamesToReturnTypeMap
+ .get(includedLibraryName + "-" + includedLibraryVersion)
+ .put(expression.getName(), expression.getResultType().toString());
+ this.expressionToReturnTypeMap.put(
+ include.getLocalIdentifier() + "." + expression.getName(),
+ expression.getResultType().toString());
}
- }
- /**
- * For every library reference from the listener, checks if the parent expression and the library make a path.
- * If it does make a path, that means the library is used and should therefore be added to the used libraries list.
- *
- * @param graph the graph
- * @param libraries the library references from the listener
- * @param parentExpression the parent expression to check
- */
- private void collectUsedLibraries(CQLGraph graph, List libraries, String parentExpression) {
- for (String library : libraries) {
- if (graph.isPath(parentExpression, library)) {
- usedLibraries.add(library);
- }
+ if (parametersFromIncludedLibrary != null) {
+ for (ParameterDef parameter : parametersFromIncludedLibrary.getDef()) {
+ this.allNamesToReturnTypeMap
+ .get(includedLibraryName + "-" + includedLibraryVersion)
+ .put(parameter.getName(), parameter.getResultType().toString());
+ this.expressionToReturnTypeMap.put(
+ include.getLocalIdentifier() + "." + parameter.getName(),
+ parameter.getResultType().toString());
+ }
}
+ }
}
+ }
- /**
- * Collects and creates a mapping of expression names to return types.
- */
- private void collectReturnTypeMap() {
- // the following makes an assumption that a library can not have any duplicate libraries declared in it.
-
- // statements contain all function and definitions.
- Library.Statements statements = this.library.getLibrary().getStatements();
- Library.Parameters parameters = this.library.getLibrary().getParameters();
- String libraryName = this.library.getIdentifier().getId();
- String libraryVersion = this.library.getIdentifier().getVersion();
- this.allNamesToReturnTypeMap.put(libraryName + "-" + libraryVersion, new HashMap<>());
-
- for (ExpressionDef expression : statements.getDef()) {
- this.allNamesToReturnTypeMap.get(libraryName + "-" + libraryVersion).put(expression.getName(), expression.getResultType().toString());
- this.nameToReturnTypeMap.put(expression.getName(), expression.getResultType().toString());
- this.expressionToReturnTypeMap.put(expression.getName(), expression.getResultType().toString());
- }
+ /**
+ * Collects the valueset - datatype map and code - datatype map.
+ *
+ * It loos through each translator object from the parser, and then for each translator it
+ * loops through the retrieves. It then puts the valueset/code and it's corresponding data type
+ * into the correct map.
+ */
+ private void collectValueSetCodeDataType(
+ Map>> valuesetMap,
+ Map>> codeMap) {
+ this.expressionNameToValuesetDataTypeMap = valuesetMap;
+ this.expressionNameToCodeDataTypeMap = codeMap;
+ this.valuesetDataTypeMap = flattenMap(valuesetMap);
+ this.codeDataTypeMap = flattenMap(codeMap);
+ }
- if (parameters != null) {
- for (ParameterDef parameter : parameters.getDef()) {
- this.allNamesToReturnTypeMap.get(libraryName + "-" + libraryVersion).put(parameter.getName(), parameter.getResultType().toString());
- this.nameToReturnTypeMap.put(parameter.getName(), parameter.getResultType().toString());
- this.expressionToReturnTypeMap.put(parameter.getName(), parameter.getResultType().toString());
- }
- }
+ /**
+ * The valueset/code - datatype map will come to us in a format of >. We want to also have a flattened map which will be in the format of
+ *
+ *
+ * @return a map in the above format
+ */
+ private Map> flattenMap(Map>> mapToFlatten) {
+ Map> flattenedMap = new HashMap<>();
- if (null != this.library.getLibrary().getIncludes()) {
- for (IncludeDef include : this.library.getLibrary().getIncludes().getDef()) {
-// CompiledLibrary lib = this.CompiledLibraryMap.get(include.getPath() + "-" + include.getVersion());
- CompiledLibrary lib = this.CompiledLibraryMap.get(include.getPath());
-
- Library.Statements statementsFromIncludedLibrary = lib.getLibrary().getStatements();
- Library.Parameters parametersFromIncludedLibrary = lib.getLibrary().getParameters();
- String includedLibraryName = lib.getIdentifier().getId();
- String includedLibraryVersion = lib.getIdentifier().getVersion();
- this.allNamesToReturnTypeMap.put(includedLibraryName + "-" + includedLibraryVersion, new HashMap<>());
-
- for (ExpressionDef expression : statementsFromIncludedLibrary.getDef()) {
- this.allNamesToReturnTypeMap.get(includedLibraryName + "-" + includedLibraryVersion).put(expression.getName(), expression.getResultType().toString());
- this.expressionToReturnTypeMap.put(include.getLocalIdentifier() + "." + expression.getName(), expression.getResultType().toString());
- }
-
- if (parametersFromIncludedLibrary != null) {
- for (ParameterDef parameter : parametersFromIncludedLibrary.getDef()) {
- this.allNamesToReturnTypeMap.get(includedLibraryName + "-" + includedLibraryVersion).put(parameter.getName(), parameter.getResultType().toString());
- this.expressionToReturnTypeMap.put(include.getLocalIdentifier() + "." + parameter.getName(), parameter.getResultType().toString());
- }
- }
- }
- }
- }
+ Set keys = mapToFlatten.keySet();
+ for (String key : keys) {
+ Map> innerMap = mapToFlatten.get(key);
- /**
- * Collects the valueset - datatype map and code - datatype map.
- *
- * It loos through each translator object from the parser, and then for each translator it loops through the retrieves.
- * It then puts the valueset/code and it's corresponding data type into the correct map.
- */
- private void collectValueSetCodeDataType(Map>> valuesetMap,
- Map>> codeMap) {
- this.expressionNameToValuesetDataTypeMap = valuesetMap;
- this.expressionNameToCodeDataTypeMap = codeMap;
- this.valuesetDataTypeMap = flattenMap(valuesetMap);
- this.codeDataTypeMap = flattenMap(codeMap);
+ Set innerKeys = innerMap.keySet();
+ for (String innerKey : innerKeys) {
+ flattenedMap.computeIfAbsent(innerKey, k -> new HashSet<>(innerMap.get(innerKey)));
+ }
}
- /**
- * The valueset/code - datatype map will come to us in a format of >.
- * We want to also have a flattened map which will be in the format of
- *
- * @return a map in the above format
- */
- private Map> flattenMap(Map>> mapToFlatten) {
- Map> flattenedMap = new HashMap<>();
-
- Set keys = mapToFlatten.keySet();
- for (String key : keys) {
- Map> innerMap = mapToFlatten.get(key);
-
- Set innerKeys = innerMap.keySet();
- for (String innerKey : innerKeys) {
- flattenedMap.computeIfAbsent(innerKey, k -> new HashSet<>(innerMap.get(innerKey)));
- }
- }
-
- return flattenedMap;
- }
-
- public Map> getValuesetDataTypeMap() {
- Map> valuesetDataTypeMapWithList = new HashMap<>();
-
- List keySet = new ArrayList<>(valuesetDataTypeMap.keySet());
-
- for (String key : keySet) {
- List dataTypes = new ArrayList<>(valuesetDataTypeMap.get(key));
- valuesetDataTypeMapWithList.put(key, dataTypes);
- }
-
- return valuesetDataTypeMapWithList;
- }
+ return flattenedMap;
+ }
- public Map> getCodeDataTypeMap() {
- Map> codeDataTypeMapWithList = new HashMap<>();
+ public Map> getValuesetDataTypeMap() {
+ Map> valuesetDataTypeMapWithList = new HashMap<>();
+
+ List keySet = new ArrayList<>(valuesetDataTypeMap.keySet());
+
+ for (String key : keySet) {
+ List dataTypes = new ArrayList<>(valuesetDataTypeMap.get(key));
+ valuesetDataTypeMapWithList.put(key, dataTypes);
+ }
+
+ return valuesetDataTypeMapWithList;
+ }
+
+ public Map> getCodeDataTypeMap() {
+ Map> codeDataTypeMapWithList = new HashMap<>();
+
+ List keySet = new ArrayList<>(codeDataTypeMap.keySet());
+
+ for (String key : keySet) {
+ List dataTypes = new ArrayList<>(codeDataTypeMap.get(key));
+ codeDataTypeMapWithList.put(key, dataTypes);
+ }
+
+ return codeDataTypeMapWithList;
+ }
+
+ public Map getNameToReturnTypeMap() {
+ return nameToReturnTypeMap;
+ }
+
+ public void setNameToReturnTypeMap(Map nameToReturnTypeMap) {
+ this.nameToReturnTypeMap = nameToReturnTypeMap;
+ }
+
+ public List getUsedLibraries() {
+ return new ArrayList<>(usedLibraries);
+ }
+
+ private List formatUsedLibraries() {
+ Set usedLibraryFormatted = new HashSet<>();
+ for (String usedLibrary : usedLibraries) {
+ IncludeDef def = (IncludeDef) this.library.resolve(usedLibrary);
+ usedLibraryFormatted.add(def.getPath() + "-" + def.getVersion() + "|" + usedLibrary);
+ }
+
+ return new ArrayList<>(usedLibraryFormatted);
+ }
+
+ public List getUsedCodes() {
+ return new ArrayList<>(usedCodes);
+ }
+
+ public List getUsedCodeSystems() {
+ return new ArrayList<>(usedCodeSystems);
+ }
+
+ public List getUsedValuesets() {
+ return new ArrayList<>(usedValuesets);
+ }
+
+ public List getUsedParameters() {
+ return new ArrayList<>(usedParameters);
+ }
+
+ public List getUsedDefinitions() {
+ return new ArrayList<>(usedDefinitions);
+ }
+
+ public List getUsedFunctions() {
+ return new ArrayList<>(usedFunctions);
+ }
+
+ public Map>> getExpressionNameToValuesetDataTypeMap() {
+ return expressionNameToValuesetDataTypeMap;
+ }
+
+ public Map>> getExpressionNameToCodeDataTypeMap() {
+ return expressionNameToCodeDataTypeMap;
+ }
+
+ public DataCriteria getDataCriteria() {
+ return dataCriteria;
+ }
- List keySet = new ArrayList<>(codeDataTypeMap.keySet());
+ @Override
+ public String toString() {
- for (String key : keySet) {
- List dataTypes = new ArrayList<>(codeDataTypeMap.get(key));
- codeDataTypeMapWithList.put(key, dataTypes);
- }
-
- return codeDataTypeMapWithList;
- }
-
- public Map getNameToReturnTypeMap() {
- return nameToReturnTypeMap;
- }
-
- public void setNameToReturnTypeMap(Map nameToReturnTypeMap) {
- this.nameToReturnTypeMap = nameToReturnTypeMap;
- }
-
- public List getUsedLibraries() {
- return new ArrayList<>(usedLibraries);
- }
-
- private List formatUsedLibraries() {
- Set usedLibraryFormatted = new HashSet<>();
- for (String usedLibrary : usedLibraries) {
- IncludeDef def = (IncludeDef) this.library.resolve(usedLibrary);
- usedLibraryFormatted.add(def.getPath() + "-" + def.getVersion() + "|" + usedLibrary);
- }
-
- return new ArrayList<>(usedLibraryFormatted);
- }
-
- public List getUsedCodes() {
- return new ArrayList<>(usedCodes);
- }
-
- public List getUsedCodeSystems() {
- return new ArrayList<>(usedCodeSystems);
- }
-
- public List getUsedValuesets() {
- return new ArrayList<>(usedValuesets);
- }
-
- public List getUsedParameters() {
- return new ArrayList<>(usedParameters);
- }
-
- public List getUsedDefinitions() {
- return new ArrayList<>(usedDefinitions);
- }
-
- public List getUsedFunctions() {
- return new ArrayList<>(usedFunctions);
- }
-
- public Map>> getExpressionNameToValuesetDataTypeMap() {
- return expressionNameToValuesetDataTypeMap;
- }
-
- public Map>> getExpressionNameToCodeDataTypeMap() {
- return expressionNameToCodeDataTypeMap;
- }
-
- public DataCriteria getDataCriteria() {
- return dataCriteria;
- }
-
- @Override
- public String toString() {
-
- StringBuilder builder = new StringBuilder();
-
- builder.append("RETURN TYPE MAP: " + this.getAllNamesToReturnTypeMap());
- builder.append("\n");
- builder.append("VALUSET-DATATYPE MAP: " + this.getValuesetDataTypeMap());
- builder.append("\n");
- builder.append("CODE-DATATYPE MAP: " + this.getCodeDataTypeMap());
- builder.append("\n");
- builder.append("EXPRESSION NAME - VALUSET-DATATYPE MAP: " + this.getExpressionNameToValuesetDataTypeMap());
- builder.append("\n");
- builder.append("EXPRESSION NAME - CODE-DATATYPE MAP: " + this.getExpressionNameToCodeDataTypeMap());
- builder.append("\n");
- builder.append("USED LIBRARIES: " + this.getUsedLibraries());
- builder.append("\n");
- builder.append("USED VALUESETS: " + this.getUsedValuesets());
- builder.append("\n");
- builder.append("USED CODESYSTEMS: " + this.getUsedCodeSystems());
- builder.append("\n");
- builder.append("USED CODES: " + this.getUsedCodes());
- builder.append("\n");
- builder.append("USED PARAMETERS: " + this.getUsedParameters());
- builder.append("\n");
- builder.append("USED DEFINITIONS: " + this.getUsedDefinitions());
- builder.append("\n");
- builder.append("USED FUNCTIONS " + this.getUsedFunctions());
-
- return builder.toString();
- }
-
- public Map> getAllNamesToReturnTypeMap() {
- return allNamesToReturnTypeMap;
- }
-
- public Map getExpressionToReturnTypeMap() {
- return expressionToReturnTypeMap;
- }
+ StringBuilder builder = new StringBuilder();
+ builder.append("RETURN TYPE MAP: " + this.getAllNamesToReturnTypeMap());
+ builder.append("\n");
+ builder.append("VALUSET-DATATYPE MAP: " + this.getValuesetDataTypeMap());
+ builder.append("\n");
+ builder.append("CODE-DATATYPE MAP: " + this.getCodeDataTypeMap());
+ builder.append("\n");
+ builder.append(
+ "EXPRESSION NAME - VALUSET-DATATYPE MAP: " + this.getExpressionNameToValuesetDataTypeMap());
+ builder.append("\n");
+ builder.append(
+ "EXPRESSION NAME - CODE-DATATYPE MAP: " + this.getExpressionNameToCodeDataTypeMap());
+ builder.append("\n");
+ builder.append("USED LIBRARIES: " + this.getUsedLibraries());
+ builder.append("\n");
+ builder.append("USED VALUESETS: " + this.getUsedValuesets());
+ builder.append("\n");
+ builder.append("USED CODESYSTEMS: " + this.getUsedCodeSystems());
+ builder.append("\n");
+ builder.append("USED CODES: " + this.getUsedCodes());
+ builder.append("\n");
+ builder.append("USED PARAMETERS: " + this.getUsedParameters());
+ builder.append("\n");
+ builder.append("USED DEFINITIONS: " + this.getUsedDefinitions());
+ builder.append("\n");
+ builder.append("USED FUNCTIONS " + this.getUsedFunctions());
+
+ return builder.toString();
+ }
+
+ public Map> getAllNamesToReturnTypeMap() {
+ return allNamesToReturnTypeMap;
+ }
+
+ public Map getExpressionToReturnTypeMap() {
+ return expressionToReturnTypeMap;
+ }
}
diff --git a/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLUtilityClass.java b/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLUtilityClass.java
index b3eba14f..86c939b2 100644
--- a/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLUtilityClass.java
+++ b/src/main/java/gov/cms/mat/cql_elm_translation/utils/cql/CQLUtilityClass.java
@@ -3,586 +3,621 @@
import java.util.Scanner;
public final class CQLUtilityClass {
- private static final String PATIENT = "Patient";
+ private static final String PATIENT = "Patient";
- private static final String POPULATION = "Population";
+ private static final String POPULATION = "Population";
- public static final String VERSION = " version ";
+ public static final String VERSION = " version ";
- private CQLUtilityClass() {
- throw new IllegalStateException("CQL Utility class");
- }
-
- public static String replaceFirstWhitespaceInLineForExpression(String expression) {
- Scanner scanner = new Scanner(expression);
- StringBuilder builder = new StringBuilder();
+ private CQLUtilityClass() {
+ throw new IllegalStateException("CQL Utility class");
+ }
- // go through and rebuild the the format
- // this will remove the first whitespace in a line so
- // it properly displays in the ace editor.
- // without doing this, the the ace editor display
- // would be indented one too many
- while (scanner.hasNextLine()) {
- String line = scanner.nextLine();
+ public static String replaceFirstWhitespaceInLineForExpression(String expression) {
+ Scanner scanner = new Scanner(expression);
+ StringBuilder builder = new StringBuilder();
- if (!line.isEmpty()) {
- if (line.startsWith(CQLUtilityClass.getWhiteSpaceString(true, 2))) {
- line = line.replaceFirst(CQLUtilityClass.getWhiteSpaceString(true, 2), "");
- }
- }
+ // go through and rebuild the the format
+ // this will remove the first whitespace in a line so
+ // it properly displays in the ace editor.
+ // without doing this, the the ace editor display
+ // would be indented one too many
+ while (scanner.hasNextLine()) {
+ String line = scanner.nextLine();
- builder.append(line).append("\n");
+ if (!line.isEmpty()) {
+ if (line.startsWith(CQLUtilityClass.getWhiteSpaceString(true, 2))) {
+ line = line.replaceFirst(CQLUtilityClass.getWhiteSpaceString(true, 2), "");
}
+ }
- scanner.close();
- return builder.toString();
+ builder.append(line).append("\n");
}
- public static String getWhiteSpaceString(boolean isSpaces, int indentSize) {
- StringBuilder whiteSpaceString = new StringBuilder();
- for (int i = 0; i < indentSize; i++) {
- if (isSpaces) {
- whiteSpaceString.append(" ");
- } else {
- whiteSpaceString.append("\t");
- }
- }
+ scanner.close();
+ return builder.toString();
+ }
- return whiteSpaceString.toString();
+ public static String getWhiteSpaceString(boolean isSpaces, int indentSize) {
+ StringBuilder whiteSpaceString = new StringBuilder();
+ for (int i = 0; i < indentSize; i++) {
+ if (isSpaces) {
+ whiteSpaceString.append(" ");
+ } else {
+ whiteSpaceString.append("\t");
+ }
}
-// public static Pair getCqlString(CQLModel cqlModel, String toBeInserted) {
-// return getCqlString(cqlModel, toBeInserted, true, 2);
-// }
-//
-// public static Pair getCqlString(CQLModel cqlModel, String toBeInserted, boolean isSpaces, int indentSize) {
-// AtomicInteger size = new AtomicInteger(0);
-// StringBuilder cqlStr = new StringBuilder();
-// // library Name and Using
-// cqlStr.append(CQLUtilityClass.createLibraryNameSection(cqlModel));
-//
-// //includes
-// cqlStr.append(CQLUtilityClass.createIncludesSection(cqlModel.getCqlIncludeLibrarys()));
-//
-// //CodeSystems
-// // Not very clean but they use the code list instead of the code system section for codes.
-// // This adds all kinds of complexity but is needed for backwards compatibility.
-// cqlStr.append(CQLUtilityClass.createCodeSystemsSection(cqlModel.getCodeList()));
-//
-// //Valuesets
-// cqlStr.append(CQLUtilityClass.createValueSetsSection(cqlModel.getValueSetList(), cqlModel.isFhir()));
-//
-// //Codes
-// cqlStr.append(CQLUtilityClass.createCodesSection(cqlModel.getCodeList()));
-//
-// // parameters
-// CQLUtilityClass.createParameterSection(cqlModel.getCqlParameters(), cqlStr, toBeInserted, size);
-//
-// // Definitions and Functions by Context
-// if (!cqlModel.getDefinitionList().isEmpty() || !cqlModel.getCqlFunctions().isEmpty()) {
-// getDefineAndFunctionsByContext(cqlModel.getDefinitionList(),
-// cqlModel.getCqlFunctions(),
-// cqlStr,
-// toBeInserted,
-// isSpaces,
-// indentSize,
-// size,
-// cqlModel.isFhir());
-// } else {
-// cqlStr.append("context").append(" " + PATIENT).append("\n\n");
-// }
-// return Pair.of(cqlStr.toString(), size.get());
-// }
-//
-// private static String createLibraryNameSection(CQLModel cqlModel) {
-// StringBuilder sb = new StringBuilder();
-//
-// if (StringUtils.isNotBlank(cqlModel.getLibraryName())) {
-//
-// sb.append("library ").append(cqlModel.getLibraryName());
-// sb.append(VERSION).append("'" + cqlModel.getVersionUsed()).append("'");
-// sb.append(System.lineSeparator()).append(System.lineSeparator());
-//
-// if (StringUtils.isNotBlank(cqlModel.getLibraryComment())) {
-// sb.append(createCommentString(cqlModel.getLibraryComment()));
-// sb.append(System.lineSeparator()).append(System.lineSeparator());
-// }
-//
-// sb.append("using ").append(cqlModel.getUsingModel());
-// sb.append(VERSION);
-// sb.append("'").append(cqlModel.getUsingModelVersion()).append("'");
-// sb.append("\n\n");
-// }
-//
-// return sb.toString();
-// }
-//
-// /**
-// * Gets the define and funcs by context.
-// *
-// * @param defineList the define list
-// * @param functionsList the functions list
-// * @param cqlStr the cql str
-// * @param indentSize
-// * @param isSpaces
-// * @return the define and funcs by context
-// */
-// private static StringBuilder getDefineAndFunctionsByContext(
-// List defineList,
-// List functionsList,
-// StringBuilder cqlStr,
-// String toBeInserted,
-// boolean isSpaces,
-// int indentSize,
-// AtomicInteger size,
-// boolean isFhir) {
-// Map> contextToDefMap = new HashMap<>();
-// Map> funcToContextMap = new HashMap<>();
-//
-// if (!CollectionUtils.isEmpty(defineList)) {
-// defineList.forEach(d -> {
-// if (isFhir) {
-// addToListMap(contextToDefMap, StringUtils.defaultString(d.getContext()), d);
-// } else {
-// //For some reason in QDM it defaults to population.
-// if (StringUtils.equalsIgnoreCase(d.getContext(), PATIENT)) {
-// addToListMap(contextToDefMap, PATIENT, d);
-// } else {
-// addToListMap(contextToDefMap, POPULATION, d);
-// }
-// }
-// });
-// }
-// if (!CollectionUtils.isEmpty(functionsList)) {
-// functionsList.forEach(f -> {
-// if (isFhir) {
-// addToListMap(funcToContextMap, StringUtils.defaultString(f.getContext()), f);
-// } else {
-// //For some reason in QDM it defaults to population.
-// if (StringUtils.equalsIgnoreCase(f.getContext(), PATIENT)) {
-// addToListMap(funcToContextMap, PATIENT, f);
-// } else {
-// addToListMap(funcToContextMap, POPULATION, f);
-//
-// }
-// }
-// });
-// }
-//
-// Set keys = new HashSet<>();
-// keys.addAll(contextToDefMap.keySet());
-// keys.addAll(funcToContextMap.keySet());
-//
-// keys.forEach(k -> {
-// getDefineAndFunctionsByContext(contextToDefMap.get(k), funcToContextMap.get(k), k, cqlStr, toBeInserted, isSpaces, indentSize, size);
-// });
-//
-// return cqlStr;
-// }
-//
-// /**
-// * Gets the define and functions by context.
-// *
-// * @param definitionList the definition list
-// * @param functionsList the functions list
-// * @param context the context
-// * @param cqlStr the cql str
-// * @param indentSize
-// * @param isSpaces
-// * @return the define and functions by context
-// */
-// private static StringBuilder getDefineAndFunctionsByContext(
-// List definitionList,
-// List functionsList, String context,
-// final StringBuilder cqlStr, String toBeInserted, boolean isSpaces, int indentSize, AtomicInteger size) {
-//
-// if (StringUtils.isNotBlank(context)) {
-// cqlStr.append("context").append(" " + context).append("\n\n");
-// }
-//
-// if (!CollectionUtils.isEmpty(definitionList)) {
-// definitionList.forEach(definition -> {
-// if (StringUtils.isNotBlank(definition.getCommentString())) {
-// cqlStr.append(createCommentString(definition.getCommentString()));
-// cqlStr.append(System.lineSeparator());
-// }
-//
-// String def = "define " + "\"" + definition.getName() + "\"";
-//
-// cqlStr.append(def + ":\n");
-// cqlStr.append(getWhiteSpaceString(isSpaces, indentSize) + definition.getLogic().replaceAll("\\n", "\n" + getWhiteSpaceString(isSpaces, indentSize)));
-// cqlStr.append("\n\n");
-//
-// // if the the def we just appended is the current one, then
-// // find the size of the file at that time. ;-
-// // This will give us the end line of the definition we are trying to insert.
-// if (def.equalsIgnoreCase(toBeInserted)) {
-// size.set(getEndLine(cqlStr.toString()));
-// }
-// });
-// }
-// if (!CollectionUtils.isEmpty(functionsList)) {
-// functionsList.forEach(function -> {
-// if (StringUtils.isNotBlank(function.getCommentString())) {
-// cqlStr.append(createCommentString(function.getCommentString()));
-// cqlStr.append(System.lineSeparator());
-// }
-//
-// String func = "define function " + "\"" + function.getName() + "\"";
-//
-// cqlStr.append(func + "(");
-// if (function.getArgumentList() != null && !function.getArgumentList().isEmpty()) {
-// for (CQLFunctionArgument argument : function.getArgumentList()) {
-// StringBuilder argumentType = new StringBuilder();
-// if (argument.getArgumentType().equalsIgnoreCase("QDM Datatype")) {
-// argumentType = argumentType.append("\"").append(argument.getQdmDataType());
-// if (argument.getAttributeName() != null) {
-// argumentType = argumentType.append(".").append(argument.getAttributeName());
-// }
-// argumentType = argumentType.append("\"");
-// } else if (argument.getArgumentType().equalsIgnoreCase("FHIR Datatype")) {
-// argumentType = argumentType.append(argument.getQdmDataType());
-// } else if (argument.getArgumentType().equalsIgnoreCase(
-// CQLWorkSpaceConstants.CQL_OTHER_DATA_TYPE)) {
-// argumentType = argumentType.append(argument.getOtherType());
-// } else {
-// argumentType = argumentType.append(argument.getArgumentType());
-// }
-// cqlStr.append(argument.getArgumentName() + " " + argumentType + ", ");
-// }
-// cqlStr.deleteCharAt(cqlStr.length() - 2);
-// }
-//
-// cqlStr.append("):\n" + getWhiteSpaceString(isSpaces, indentSize) + function.getLogic().replaceAll("\\n", "\n" + getWhiteSpaceString(isSpaces, indentSize)));
-// cqlStr.append("\n\n");
-//
-// // if the the func we just appended is the current one, then
-// // find the size of the file at that time.
-// // This will give us the end line of the function we are trying to insert.
-// if (func.equalsIgnoreCase(toBeInserted)) {
-// size.set(getEndLine(cqlStr.toString()));
-// }
-// });
-// }
-// return cqlStr;
-// }
-//
-//
-// public static CQLModel getCQLModelFromXML(String xmlString) {
-// CQLModel cqlModel = new CQLModel();
-// XmlProcessor measureXMLProcessor = new XmlProcessor(xmlString);
-// String cqlLookUpXMLString = measureXMLProcessor.getXmlByTagName("cqlLookUp");
-//
-// if (StringUtils.isNotBlank(cqlLookUpXMLString)) {
-// try {
-// XMLMarshalUtil xmlMarshalUtil = new XMLMarshalUtil();
-// cqlModel = (CQLModel) xmlMarshalUtil.convertXMLToObject("CQLModelMapping.xml", cqlLookUpXMLString, CQLModel.class);
-// } catch (Exception e) {
-// logger.error("Error parsing CQL model from XML: " + e.getMessage(), e);
-// }
-// }
-//
-// if (!cqlModel.getValueSetList().isEmpty()) {
-// cqlModel.setValueSetList(filterValuesets(cqlModel.getValueSetList()));
-// ArrayList valueSetsList = new ArrayList<>();
-// valueSetsList.addAll(cqlModel.getValueSetList());
-// cqlModel.setAllValueSetAndCodeList(valueSetsList);
-// }
-//
-// if (!cqlModel.getCodeList().isEmpty()) {
-// sortCQLCodeDTO(cqlModel.getCodeList());
-// //Combine Codes and Value sets in allValueSetList for UI
-// List dtoList = convertCodesToQualityDataSetDTO(cqlModel.getCodeList());
-// if (!dtoList.isEmpty()) {
-// cqlModel.getAllValueSetAndCodeList().addAll(dtoList);
-// }
-// }
-// return cqlModel;
-// }
-//
-// public static String getXMLFromCQLModel(CQLModel cqlModel) {
-// String xml = "";
-//
-// try (ByteArrayOutputStream stream = new ByteArrayOutputStream();) {
-// Mapping mapping = new Mapping();
-// mapping.loadMapping(new ResourceLoader().getResourceAsURL("CQLModelMapping.xml"));
-// Marshaller marshaller = new Marshaller(new OutputStreamWriter(stream));
-// marshaller.setMapping(mapping);
-// marshaller.marshal(cqlModel);
-// xml = stream.toString();
-// } catch (MarshalException | ValidationException | IOException | MappingException e) {
-// logger.error("Error in getXMLFromCQLModel: " + e.getMessage(), e);
-// }
-//
-//
-// return xml;
-// }
-//
-// public static void getValueSet(CQLModel cqlModel, String cqlLookUpXMLString) {
-// CQLQualityDataModelWrapper valuesetWrapper;
-// try {
-// XMLMarshalUtil xmlMarshalUtil = new XMLMarshalUtil();
-// valuesetWrapper = (CQLQualityDataModelWrapper) xmlMarshalUtil.convertXMLToObject("ValueSetsMapping.xml", cqlLookUpXMLString, CQLQualityDataModelWrapper.class);
-// if (!valuesetWrapper.getQualityDataDTO().isEmpty()) {
-// cqlModel.setValueSetList(filterValuesets(valuesetWrapper.getQualityDataDTO()));
-// }
-// } catch (Exception e) {
-// logger.error("Error while getting valueset :" + e.getMessage(), e);
-// }
-//
-// }
-//
-//
-// private static List convertCodesToQualityDataSetDTO(List codeList) {
-// List convertedCQLDataSetList = new ArrayList();
-// for (CQLCode tempDataSet : codeList) {
-// CQLQualityDataSetDTO convertedCQLDataSet = new CQLQualityDataSetDTO();
-// convertedCQLDataSet.setName(tempDataSet.getName());
-// convertedCQLDataSet.setCodeSystemName(tempDataSet.getCodeSystemName());
-// convertedCQLDataSet.setCodeSystemOID(tempDataSet.getCodeSystemOID());
-//
-// convertedCQLDataSet.setCodeIdentifier(tempDataSet.getCodeIdentifier());
-// convertedCQLDataSet.setId(tempDataSet.getId());
-// convertedCQLDataSet.setOid(tempDataSet.getCodeOID());
-// convertedCQLDataSet.setVersion(tempDataSet.getCodeSystemVersion());
-// convertedCQLDataSet.setDisplayName(tempDataSet.getDisplayName());
-// convertedCQLDataSet.setSuffix(tempDataSet.getSuffix());
-//
-// convertedCQLDataSet.setReadOnly(tempDataSet.isReadOnly());
-//
-// convertedCQLDataSet.setType("code");
-// convertedCQLDataSetList.add(convertedCQLDataSet);
-//
-//
-// }
-// return convertedCQLDataSetList;
-//
-// }
-//
-// private static int getEndLine(String cqlString) {
-//
-// Scanner scanner = new Scanner(cqlString);
-//
-// int endLine = -1;
-// while (scanner.hasNextLine()) {
-// endLine++;
-// scanner.nextLine();
-// }
-//
-// scanner.close();
-// return endLine;
-// }
-//
-// public static List sortCQLQualityDataSetDto(List cqlQualityDataSetDTOs) {
-//
-// cqlQualityDataSetDTOs.sort((c1, c2) -> c1.getName().compareToIgnoreCase(c2.getName()));
-// return cqlQualityDataSetDTOs;
-// }
-//
-// public static List sortCQLCodeDTO(List cqlCodes) {
-//
-// cqlCodes.sort((c1, c2) -> c1.getName().compareToIgnoreCase(c2.getName()));
-// return cqlCodes;
-// }
-//
-// private static List filterValuesets(List cqlValuesets) {
-//
-// cqlValuesets.removeIf(c -> c.getDataType() != null &&
-// (c.getDataType().equalsIgnoreCase("Patient characteristic Birthdate")
-// || c.getDataType().equalsIgnoreCase("Patient characteristic Expired")));
-//
-// sortCQLQualityDataSetDto(cqlValuesets);
-//
-// return cqlValuesets;
-// }
-//
-// private static String createIncludesSection(List includeLibList) {
-// StringBuilder sb = new StringBuilder();
-// if (!CollectionUtils.isEmpty(includeLibList)) {
-// for (CQLIncludeLibrary includeLib : includeLibList) {
-// sb.append("include ").append(includeLib.getCqlLibraryName());
-// sb.append(VERSION).append("'").append(MeasureUtility.formatVersionText(includeLib.getVersion())).append("' ");
-// sb.append("called ").append(includeLib.getAliasName());
-// sb.append("\n");
-// }
-// sb.append("\n");
-// }
-// return sb.toString();
-// }
-//
-// private static String createCodeSystemsSection(List codeSystemList) {
-// StringBuilder sb = new StringBuilder();
-//
-// //Use a set to prevent duplicate entries automatically.
-// Set codeSystemAlreadyUsed = new HashSet<>();
-//
-// if (!CollectionUtils.isEmpty(codeSystemList)) {
-// for (CQLCode code : codeSystemList) {
-// if (code.getCodeSystemOID() != null && !code.getCodeSystemOID().isEmpty() && !"null".equals(code.getCodeSystemOID())) {
-// boolean isUrlCodeSystem = StringUtils.startsWith(code.getCodeSystemOID(), "http");
-// if (isUrlCodeSystem) {
-// String csName = code.getCodeSystemName();
-// String csVersionUri = code.getCodeSystemVersionUri();
-// if (code.isIsCodeSystemVersionIncluded()) {
-// csName = csName + ":" + code.getCodeSystemVersion();
-// }
-// if (!codeSystemAlreadyUsed.contains(csName)) {
-// // Fhir4 code system
-// // codesystem "SNOMEDCT:2017-09": 'http://snomed.info/sct/731000124108' version 'http://snomed.info/sct/731000124108/version/201709'
-// // or
-// // codesystem "SNOMEDCT:2017-09": 'http://snomed.info/sct/731000124108'
-// String csUri = code.getCodeSystemOID();
-// sb.append("codesystem \"").append(csName).append('"').append(": ").
-// append("'").append(csUri).append("' ");
-// if (StringUtils.isNotBlank(csVersionUri)) {
-// sb.append("version '" + csVersionUri + "'");
-// }
-// sb.append("\n");
-// codeSystemAlreadyUsed.add(csName);
-// }
-// } else {
-// // Legacy OID system.
-// String codeSysStr = code.getCodeSystemName();
-// String codeSysVersion = "";
-//
-// if (code.isIsCodeSystemVersionIncluded()) {
-// codeSysStr = codeSysStr + ":" + code.getCodeSystemVersion().replaceAll(" ", "%20");
-// codeSysVersion = "version 'urn:hl7:version:" + code.getCodeSystemVersion() + "'";
-// }
-//
-// if (!codeSystemAlreadyUsed.contains(codeSysStr)) {
-// sb.append("codesystem \"").append(codeSysStr).append('"').append(": ");
-// if(code.getCodeSystemOID().startsWith("urn:oid:")) {
-// sb.append('\'');
-// } else {
-// sb.append("'urn:oid:");
-// }
-// sb.append(code.getCodeSystemOID()).append("' ");
-// sb.append(codeSysVersion);
-// sb.append("\n");
-//
-// codeSystemAlreadyUsed.add(codeSysStr);
-// }
-// }
-// }
-// }
-//
-// sb.append("\n");
-// }
-//
-// return sb.toString();
-// }
-//
-// private static String createValueSetsSection(List valueSetList, boolean isFhir) {
-// StringBuilder sb = new StringBuilder();
-//
-// List valueSetAlreadyUsed = new ArrayList<>();
-//
-// if (!CollectionUtils.isEmpty(valueSetList)) {
-//
-// for (CQLQualityDataSetDTO valueset : valueSetList) {
-//
-// if (!valueSetAlreadyUsed.contains(valueset.getName())) {
-// if (isFhir) {
-// sb.append("valueset ").append('"').append(valueset.getName()).append('"');
-// sb.append(": '").append(valueset.getOid()).append("' ");
-// } else {
-// String version = valueset.getVersion().replaceAll(" ", "%20");
-// sb.append("valueset ").append('"').append(valueset.getName()).append('"');
-// sb.append(": 'urn:oid:").append(valueset.getOid()).append("' ");
-// //Check if QDM has expansion identifier or not.
-// if (StringUtils.isNotBlank(version) && !version.equals("1.0")) {
-// sb.append("version 'urn:hl7:version:").append(version).append("' ");
-// }
-// }
-// sb.append("\n");
-// valueSetAlreadyUsed.add(valueset.getName());
-// }
-// }
-// sb.append("\n");
-// }
-// return sb.toString();
-// }
-//
-// private static String createCodesSection(List codeList) {
-//
-// StringBuilder sb = new StringBuilder();
-//
-// List codeAlreadyUsed = new ArrayList<>();
-//
-// if (!CollectionUtils.isEmpty(codeList)) {
-//
-// for (CQLCode code : codeList) {
-// String codeStr = '"' + code.getCodeName() + '"' + ": " + "'" + code.getCodeOID() + "'";
-// String codeSysStr = code.getCodeSystemName();
-// if (code.isIsCodeSystemVersionIncluded()) {
-// codeSysStr = codeSysStr + ":" + code.getCodeSystemVersion().replaceAll(" ", "%20");
-// }
-//
-// if (!codeAlreadyUsed.contains(codeStr)) {
-// sb.append("code ").append(codeStr).append(" ").append("from ");
-// sb.append('"').append(codeSysStr).append('"').append(" ");
-// if (StringUtils.isNotEmpty(code.getDisplayName())) {
-// sb.append("display " + "'" + code.getDisplayName() + "'");
-// }
-// sb.append("\n");
-// codeAlreadyUsed.add(codeStr);
-// }
-// }
-//
-// sb.append("\n");
-// }
-//
-// return sb.toString();
-// }
-//
-// private static StringBuilder createParameterSection(List paramList,
-// StringBuilder cqlStr,
-// String toBeInserted,
-// AtomicInteger size) {
-// if (!CollectionUtils.isEmpty(paramList)) {
-//
-// for (CQLParameter parameter : paramList) {
-//
-// String param = "parameter " + "\"" + parameter.getName() + "\"";
-//
-// if (StringUtils.isNotBlank(parameter.getCommentString())) {
-// cqlStr.append(createCommentString(parameter.getCommentString()));
-// cqlStr.append(System.lineSeparator());
-// }
-//
-// cqlStr.append(param + " " + parameter.getLogic());
-// cqlStr.append("\n");
-//
-// // if the the param we just appended is the current one, then
-// // find the size of the file at that time.
-// // This will give us the end line of the parameter we are trying to insert.
-// if (param.equalsIgnoreCase(toBeInserted)) {
-// size.set(getEndLine(cqlStr.toString()));
-// }
-//
-// }
-//
-// cqlStr.append("\n");
-// }
-//
-// return cqlStr;
-// }
-//
-// public static String createCommentString(String comment) {
-// StringBuilder sb = new StringBuilder();
-// sb.append("/*").append(comment).append("*/");
-// return sb.toString();
-// }
-//
-// private static void addToListMap(Map> map, O key, T newElem) {
-// if (map != null) {
-// List l = map.get(key);
-// if (CollectionUtils.isEmpty(l)) {
-// l = new ArrayList();
-// map.put(key, l);
-// }
-// l.add(newElem);
-// }
-// }
+ return whiteSpaceString.toString();
+ }
+
+ // public static Pair getCqlString(CQLModel cqlModel, String toBeInserted) {
+ // return getCqlString(cqlModel, toBeInserted, true, 2);
+ // }
+ //
+ // public static Pair getCqlString(CQLModel cqlModel, String toBeInserted,
+ // boolean isSpaces, int indentSize) {
+ // AtomicInteger size = new AtomicInteger(0);
+ // StringBuilder cqlStr = new StringBuilder();
+ // // library Name and Using
+ // cqlStr.append(CQLUtilityClass.createLibraryNameSection(cqlModel));
+ //
+ // //includes
+ // cqlStr.append(CQLUtilityClass.createIncludesSection(cqlModel.getCqlIncludeLibrarys()));
+ //
+ // //CodeSystems
+ // // Not very clean but they use the code list instead of the code system section for
+ // codes.
+ // // This adds all kinds of complexity but is needed for backwards compatibility.
+ // cqlStr.append(CQLUtilityClass.createCodeSystemsSection(cqlModel.getCodeList()));
+ //
+ // //Valuesets
+ // cqlStr.append(CQLUtilityClass.createValueSetsSection(cqlModel.getValueSetList(),
+ // cqlModel.isFhir()));
+ //
+ // //Codes
+ // cqlStr.append(CQLUtilityClass.createCodesSection(cqlModel.getCodeList()));
+ //
+ // // parameters
+ // CQLUtilityClass.createParameterSection(cqlModel.getCqlParameters(), cqlStr,
+ // toBeInserted, size);
+ //
+ // // Definitions and Functions by Context
+ // if (!cqlModel.getDefinitionList().isEmpty() || !cqlModel.getCqlFunctions().isEmpty()) {
+ // getDefineAndFunctionsByContext(cqlModel.getDefinitionList(),
+ // cqlModel.getCqlFunctions(),
+ // cqlStr,
+ // toBeInserted,
+ // isSpaces,
+ // indentSize,
+ // size,
+ // cqlModel.isFhir());
+ // } else {
+ // cqlStr.append("context").append(" " + PATIENT).append("\n\n");
+ // }
+ // return Pair.of(cqlStr.toString(), size.get());
+ // }
+ //
+ // private static String createLibraryNameSection(CQLModel cqlModel) {
+ // StringBuilder sb = new StringBuilder();
+ //
+ // if (StringUtils.isNotBlank(cqlModel.getLibraryName())) {
+ //
+ // sb.append("library ").append(cqlModel.getLibraryName());
+ // sb.append(VERSION).append("'" + cqlModel.getVersionUsed()).append("'");
+ // sb.append(System.lineSeparator()).append(System.lineSeparator());
+ //
+ // if (StringUtils.isNotBlank(cqlModel.getLibraryComment())) {
+ // sb.append(createCommentString(cqlModel.getLibraryComment()));
+ // sb.append(System.lineSeparator()).append(System.lineSeparator());
+ // }
+ //
+ // sb.append("using ").append(cqlModel.getUsingModel());
+ // sb.append(VERSION);
+ // sb.append("'").append(cqlModel.getUsingModelVersion()).append("'");
+ // sb.append("\n\n");
+ // }
+ //
+ // return sb.toString();
+ // }
+ //
+ // /**
+ // * Gets the define and funcs by context.
+ // *
+ // * @param defineList the define list
+ // * @param functionsList the functions list
+ // * @param cqlStr the cql str
+ // * @param indentSize
+ // * @param isSpaces
+ // * @return the define and funcs by context
+ // */
+ // private static StringBuilder getDefineAndFunctionsByContext(
+ // List defineList,
+ // List functionsList,
+ // StringBuilder cqlStr,
+ // String toBeInserted,
+ // boolean isSpaces,
+ // int indentSize,
+ // AtomicInteger size,
+ // boolean isFhir) {
+ // Map> contextToDefMap = new HashMap<>();
+ // Map> funcToContextMap = new HashMap<>();
+ //
+ // if (!CollectionUtils.isEmpty(defineList)) {
+ // defineList.forEach(d -> {
+ // if (isFhir) {
+ // addToListMap(contextToDefMap, StringUtils.defaultString(d.getContext()), d);
+ // } else {
+ // //For some reason in QDM it defaults to population.
+ // if (StringUtils.equalsIgnoreCase(d.getContext(), PATIENT)) {
+ // addToListMap(contextToDefMap, PATIENT, d);
+ // } else {
+ // addToListMap(contextToDefMap, POPULATION, d);
+ // }
+ // }
+ // });
+ // }
+ // if (!CollectionUtils.isEmpty(functionsList)) {
+ // functionsList.forEach(f -> {
+ // if (isFhir) {
+ // addToListMap(funcToContextMap, StringUtils.defaultString(f.getContext()),
+ // f);
+ // } else {
+ // //For some reason in QDM it defaults to population.
+ // if (StringUtils.equalsIgnoreCase(f.getContext(), PATIENT)) {
+ // addToListMap(funcToContextMap, PATIENT, f);
+ // } else {
+ // addToListMap(funcToContextMap, POPULATION, f);
+ //
+ // }
+ // }
+ // });
+ // }
+ //
+ // Set keys = new HashSet<>();
+ // keys.addAll(contextToDefMap.keySet());
+ // keys.addAll(funcToContextMap.keySet());
+ //
+ // keys.forEach(k -> {
+ // getDefineAndFunctionsByContext(contextToDefMap.get(k), funcToContextMap.get(k), k,
+ // cqlStr, toBeInserted, isSpaces, indentSize, size);
+ // });
+ //
+ // return cqlStr;
+ // }
+ //
+ // /**
+ // * Gets the define and functions by context.
+ // *
+ // * @param definitionList the definition list
+ // * @param functionsList the functions list
+ // * @param context the context
+ // * @param cqlStr the cql str
+ // * @param indentSize
+ // * @param isSpaces
+ // * @return the define and functions by context
+ // */
+ // private static StringBuilder getDefineAndFunctionsByContext(
+ // List definitionList,
+ // List functionsList, String context,
+ // final StringBuilder cqlStr, String toBeInserted, boolean isSpaces, int indentSize,
+ // AtomicInteger size) {
+ //
+ // if (StringUtils.isNotBlank(context)) {
+ // cqlStr.append("context").append(" " + context).append("\n\n");
+ // }
+ //
+ // if (!CollectionUtils.isEmpty(definitionList)) {
+ // definitionList.forEach(definition -> {
+ // if (StringUtils.isNotBlank(definition.getCommentString())) {
+ // cqlStr.append(createCommentString(definition.getCommentString()));
+ // cqlStr.append(System.lineSeparator());
+ // }
+ //
+ // String def = "define " + "\"" + definition.getName() + "\"";
+ //
+ // cqlStr.append(def + ":\n");
+ // cqlStr.append(getWhiteSpaceString(isSpaces, indentSize) +
+ // definition.getLogic().replaceAll("\\n", "\n" + getWhiteSpaceString(isSpaces, indentSize)));
+ // cqlStr.append("\n\n");
+ //
+ // // if the the def we just appended is the current one, then
+ // // find the size of the file at that time. ;-
+ // // This will give us the end line of the definition we are trying to insert.
+ // if (def.equalsIgnoreCase(toBeInserted)) {
+ // size.set(getEndLine(cqlStr.toString()));
+ // }
+ // });
+ // }
+ // if (!CollectionUtils.isEmpty(functionsList)) {
+ // functionsList.forEach(function -> {
+ // if (StringUtils.isNotBlank(function.getCommentString())) {
+ // cqlStr.append(createCommentString(function.getCommentString()));
+ // cqlStr.append(System.lineSeparator());
+ // }
+ //
+ // String func = "define function " + "\"" + function.getName() + "\"";
+ //
+ // cqlStr.append(func + "(");
+ // if (function.getArgumentList() != null && !function.getArgumentList().isEmpty())
+ // {
+ // for (CQLFunctionArgument argument : function.getArgumentList()) {
+ // StringBuilder argumentType = new StringBuilder();
+ // if (argument.getArgumentType().equalsIgnoreCase("QDM Datatype")) {
+ // argumentType =
+ // argumentType.append("\"").append(argument.getQdmDataType());
+ // if (argument.getAttributeName() != null) {
+ // argumentType =
+ // argumentType.append(".").append(argument.getAttributeName());
+ // }
+ // argumentType = argumentType.append("\"");
+ // } else if (argument.getArgumentType().equalsIgnoreCase("FHIR Datatype"))
+ // {
+ // argumentType = argumentType.append(argument.getQdmDataType());
+ // } else if (argument.getArgumentType().equalsIgnoreCase(
+ // CQLWorkSpaceConstants.CQL_OTHER_DATA_TYPE)) {
+ // argumentType = argumentType.append(argument.getOtherType());
+ // } else {
+ // argumentType = argumentType.append(argument.getArgumentType());
+ // }
+ // cqlStr.append(argument.getArgumentName() + " " + argumentType + ", ");
+ // }
+ // cqlStr.deleteCharAt(cqlStr.length() - 2);
+ // }
+ //
+ // cqlStr.append("):\n" + getWhiteSpaceString(isSpaces, indentSize) +
+ // function.getLogic().replaceAll("\\n", "\n" + getWhiteSpaceString(isSpaces, indentSize)));
+ // cqlStr.append("\n\n");
+ //
+ // // if the the func we just appended is the current one, then
+ // // find the size of the file at that time.
+ // // This will give us the end line of the function we are trying to insert.
+ // if (func.equalsIgnoreCase(toBeInserted)) {
+ // size.set(getEndLine(cqlStr.toString()));
+ // }
+ // });
+ // }
+ // return cqlStr;
+ // }
+ //
+ //
+ // public static CQLModel getCQLModelFromXML(String xmlString) {
+ // CQLModel cqlModel = new CQLModel();
+ // XmlProcessor measureXMLProcessor = new XmlProcessor(xmlString);
+ // String cqlLookUpXMLString = measureXMLProcessor.getXmlByTagName("cqlLookUp");
+ //
+ // if (StringUtils.isNotBlank(cqlLookUpXMLString)) {
+ // try {
+ // XMLMarshalUtil xmlMarshalUtil = new XMLMarshalUtil();
+ // cqlModel = (CQLModel) xmlMarshalUtil.convertXMLToObject("CQLModelMapping.xml",
+ // cqlLookUpXMLString, CQLModel.class);
+ // } catch (Exception e) {
+ // logger.error("Error parsing CQL model from XML: " + e.getMessage(), e);
+ // }
+ // }
+ //
+ // if (!cqlModel.getValueSetList().isEmpty()) {
+ // cqlModel.setValueSetList(filterValuesets(cqlModel.getValueSetList()));
+ // ArrayList valueSetsList = new ArrayList<>();
+ // valueSetsList.addAll(cqlModel.getValueSetList());
+ // cqlModel.setAllValueSetAndCodeList(valueSetsList);
+ // }
+ //
+ // if (!cqlModel.getCodeList().isEmpty()) {
+ // sortCQLCodeDTO(cqlModel.getCodeList());
+ // //Combine Codes and Value sets in allValueSetList for UI
+ // List dtoList =
+ // convertCodesToQualityDataSetDTO(cqlModel.getCodeList());
+ // if (!dtoList.isEmpty()) {
+ // cqlModel.getAllValueSetAndCodeList().addAll(dtoList);
+ // }
+ // }
+ // return cqlModel;
+ // }
+ //
+ // public static String getXMLFromCQLModel(CQLModel cqlModel) {
+ // String xml = "";
+ //
+ // try (ByteArrayOutputStream stream = new ByteArrayOutputStream();) {
+ // Mapping mapping = new Mapping();
+ // mapping.loadMapping(new ResourceLoader().getResourceAsURL("CQLModelMapping.xml"));
+ // Marshaller marshaller = new Marshaller(new OutputStreamWriter(stream));
+ // marshaller.setMapping(mapping);
+ // marshaller.marshal(cqlModel);
+ // xml = stream.toString();
+ // } catch (MarshalException | ValidationException | IOException | MappingException e) {
+ // logger.error("Error in getXMLFromCQLModel: " + e.getMessage(), e);
+ // }
+ //
+ //
+ // return xml;
+ // }
+ //
+ // public static void getValueSet(CQLModel cqlModel, String cqlLookUpXMLString) {
+ // CQLQualityDataModelWrapper valuesetWrapper;
+ // try {
+ // XMLMarshalUtil xmlMarshalUtil = new XMLMarshalUtil();
+ // valuesetWrapper = (CQLQualityDataModelWrapper)
+ // xmlMarshalUtil.convertXMLToObject("ValueSetsMapping.xml", cqlLookUpXMLString,
+ // CQLQualityDataModelWrapper.class);
+ // if (!valuesetWrapper.getQualityDataDTO().isEmpty()) {
+ // cqlModel.setValueSetList(filterValuesets(valuesetWrapper.getQualityDataDTO()));
+ // }
+ // } catch (Exception e) {
+ // logger.error("Error while getting valueset :" + e.getMessage(), e);
+ // }
+ //
+ // }
+ //
+ //
+ // private static List convertCodesToQualityDataSetDTO(List
+ // codeList) {
+ // List convertedCQLDataSetList = new
+ // ArrayList();
+ // for (CQLCode tempDataSet : codeList) {
+ // CQLQualityDataSetDTO convertedCQLDataSet = new CQLQualityDataSetDTO();
+ // convertedCQLDataSet.setName(tempDataSet.getName());
+ // convertedCQLDataSet.setCodeSystemName(tempDataSet.getCodeSystemName());
+ // convertedCQLDataSet.setCodeSystemOID(tempDataSet.getCodeSystemOID());
+ //
+ // convertedCQLDataSet.setCodeIdentifier(tempDataSet.getCodeIdentifier());
+ // convertedCQLDataSet.setId(tempDataSet.getId());
+ // convertedCQLDataSet.setOid(tempDataSet.getCodeOID());
+ // convertedCQLDataSet.setVersion(tempDataSet.getCodeSystemVersion());
+ // convertedCQLDataSet.setDisplayName(tempDataSet.getDisplayName());
+ // convertedCQLDataSet.setSuffix(tempDataSet.getSuffix());
+ //
+ // convertedCQLDataSet.setReadOnly(tempDataSet.isReadOnly());
+ //
+ // convertedCQLDataSet.setType("code");
+ // convertedCQLDataSetList.add(convertedCQLDataSet);
+ //
+ //
+ // }
+ // return convertedCQLDataSetList;
+ //
+ // }
+ //
+ // private static int getEndLine(String cqlString) {
+ //
+ // Scanner scanner = new Scanner(cqlString);
+ //
+ // int endLine = -1;
+ // while (scanner.hasNextLine()) {
+ // endLine++;
+ // scanner.nextLine();
+ // }
+ //
+ // scanner.close();
+ // return endLine;
+ // }
+ //
+ // public static List