Skip to content

Commit

Permalink
MAT-7300: change signature level to overloads (#9)
Browse files Browse the repository at this point in the history
* MAT-7300: change signature level to overloads

* MAT-7300: update tests
  • Loading branch information
chubert-sb authored Jul 22, 2024
1 parent 2039787 commit 2d44cc5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public CqlTranslator buildTranslator(
VersionedIdentifier sourceInfo) {
try {
UcumService ucumService = null;
LibraryBuilder.SignatureLevel signatureLevel = LibraryBuilder.SignatureLevel.None;
LibraryBuilder.SignatureLevel signatureLevel = LibraryBuilder.SignatureLevel.Overloads;
List<CqlCompilerOptions.Options> optionsList = new ArrayList<>();

for (String key : params.keySet()) {
Expand Down Expand Up @@ -147,6 +147,7 @@ public CqlTranslator buildTranslator(
NamespaceInfo nsInfo = null;

libraryManager.setUcumService(ucumService);
libraryManager.getCqlCompilerOptions().setSignatureLevel(signatureLevel);
libraryManager.getCqlCompilerOptions().setOptions(options);
CqlTranslator translator =
CqlTranslator.fromStream(nsInfo, sourceInfo, cqlStream, libraryManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.extern.slf4j.Slf4j;
import org.cqframework.cql.cql2elm.CqlCompilerOptions;
import org.cqframework.cql.cql2elm.CqlTranslator;
import org.cqframework.cql.cql2elm.LibraryBuilder;
import org.cqframework.cql.cql2elm.LibraryManager;
import org.cqframework.cql.cql2elm.model.CompiledLibrary;
import org.cqframework.cql.elm.requirements.fhir.DataRequirementsProcessor;
Expand Down Expand Up @@ -60,6 +61,7 @@ public org.hl7.fhir.r5.model.Library getEffectiveDataRequirements(
var dqReqTrans = new DataRequirementsProcessor();
CqlCompilerOptions options = CqlCompilerOptions.defaultOptions();
options.setCollapseDataRequirements(true); // removing duplicate data requirements
options.setSignatureLevel(LibraryBuilder.SignatureLevel.Overloads);

org.hl7.fhir.r5.model.Library effectiveDataRequirements =
dqReqTrans.gatherDataRequirements(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.apache.commons.collections4.CollectionUtils;
import org.cqframework.cql.cql2elm.CqlCompilerOptions;
import org.cqframework.cql.cql2elm.LibraryBuilder;
import org.cqframework.cql.cql2elm.model.CompiledLibrary;
import org.cqframework.cql.cql2elm.preprocessor.CqlPreprocessorVisitor;
Expand Down Expand Up @@ -651,8 +652,9 @@ private void parseChildLibraries(IncludeDef def) throws IOException {

// Add CqlCompilerOptions from LibraryManager to prevent NPE while walking through CQL
LibraryBuilder libraryBuilder = new LibraryBuilder(translationResource.getLibraryManager());
libraryBuilder.setCompilerOptions(
translationResource.getLibraryManager().getCqlCompilerOptions());
CqlCompilerOptions options = translationResource.getLibraryManager().getCqlCompilerOptions();
options.setSignatureLevel(LibraryBuilder.SignatureLevel.Overloads);
libraryBuilder.setCompilerOptions(options);
CqlPreprocessorVisitor preprocessor = new CqlPreprocessorVisitor(libraryBuilder, tokens);
preprocessor.visit(tree);
ParseTreeWalker walker = new ParseTreeWalker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,14 @@ void process_Good() {
}

@Test
void process_SignatureLevelNone() {
void process_SignatureLevelOverloads() {
String jsonDefault = getJson();

signatureLevel = LibraryBuilder.SignatureLevel.None;
signatureLevel = LibraryBuilder.SignatureLevel.Overloads;

String jsonSignatureLevelNone = getJson();

// NO change expected null signatureLevel and LibraryBuilder.SignatureLevel.None behave the same
assertEquals(jsonDefault, jsonSignatureLevelNone);
}

@Test
void process_SignatureLevelAll() {
String jsonDefault = getJson();

signatureLevel = LibraryBuilder.SignatureLevel.All;

String jsonSignatureLevelNone = getJson();
String jsonSignatureLevel = getJson();

assertEquals(jsonDefault, jsonSignatureLevelNone); // NO change TODO not expected
assertEquals(jsonDefault, jsonSignatureLevel);
}

@Test
Expand Down

0 comments on commit 2d44cc5

Please sign in to comment.