From ace56bb2584576d1e88ada921fbc0626819582e1 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Wed, 18 Dec 2024 20:45:34 -0700 Subject: [PATCH 1/3] Change default signature level from None to Overloads --- .../java/org/cqframework/cql/cql2elm/CqlCompilerOptions.java | 2 +- .../src/test/resources/org/cqframework/cql/cql2elm/options.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/CqlCompilerOptions.java b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/CqlCompilerOptions.java index 11bae46ce..27f179744 100644 --- a/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/CqlCompilerOptions.java +++ b/Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/CqlCompilerOptions.java @@ -29,7 +29,7 @@ public enum Options { private boolean enableCqlOnly = false; private String compatibilityLevel = "1.5"; private CqlCompilerException.ErrorSeverity errorLevel = CqlCompilerException.ErrorSeverity.Info; - private LibraryBuilder.SignatureLevel signatureLevel = LibraryBuilder.SignatureLevel.None; + private LibraryBuilder.SignatureLevel signatureLevel = LibraryBuilder.SignatureLevel.Overloads; private boolean analyzeDataRequirements = false; private boolean collapseDataRequirements = false; diff --git a/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/options.json b/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/options.json index 1834225ea..83c1d815a 100644 --- a/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/options.json +++ b/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/options.json @@ -1 +1 @@ -{"options":["EnableAnnotations","EnableLocators","DisableListDemotion","DisableListPromotion"],"formats":[ "XML"],"validateUnits":true,"verifyOnly":false,"errorLevel":"Info","signatureLevel":"None"} \ No newline at end of file +{"options":["EnableAnnotations","EnableLocators","DisableListDemotion","DisableListPromotion"],"formats":[ "XML"],"validateUnits":true,"verifyOnly":false,"errorLevel":"Info","signatureLevel":"Overloads"} \ No newline at end of file From 49ca70e03d75d01a4a5205bf721d0a6a81a49455 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Thu, 19 Dec 2024 14:59:21 -0700 Subject: [PATCH 2/3] Fix tests --- .../cql/engine/fhir/data/TestFHIRHelpers.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java index ed88db13f..7528dd65c 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java @@ -18,35 +18,31 @@ class TestFHIRHelpers extends FhirExecutionTestBase { @Test - void testWithUnambiguousCompilerOptions() { - // Test with non-ambiguous compiler options. Should pass. + void testWithAmbiguousCompilerOptions() { + // This tests the behavior of the engine when the compiler + // options are set to allow ambiguous overloads + // It's expected that the engine will throw an exception + // + // If we update the FHIRHelpers content to not have ambiguous overloads + // the results of this test will change var compilerOptions = CqlCompilerOptions.defaultOptions(); - compilerOptions.setSignatureLevel(LibraryBuilder.SignatureLevel.Overloads); + compilerOptions.setSignatureLevel(LibraryBuilder.SignatureLevel.None); var modelManager = new ModelManager(); var libraryManager = new LibraryManager(modelManager, compilerOptions); libraryManager.getLibrarySourceLoader().clearProviders(); libraryManager.getLibrarySourceLoader().registerProvider(new FhirLibrarySourceProvider()); libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider()); - var engine = new CqlEngine(new Environment(libraryManager)); - engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider); + var badOptionsEngine = new CqlEngine(new Environment(libraryManager)); + badOptionsEngine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider); - runTest(engine); + assertThrows(CqlException.class, () -> badOptionsEngine.evaluate(library.getIdentifier())); } @Test - void standardCompilerOptions() { - // Test with standard compiler options. Should throw an Exception as of the - // time this test is written because the default compiler options produce - // ambiguous ELM output. This test is intended to fail, and if we change the - // compiler options to be non-ambiguous, this test should be updated to expect - // a different (presumably passing) result. + void testFhirHelpers() { var engine = getEngine(); engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider); - assertThrows(CqlException.class, () -> runTest(engine)); - } - - void runTest(CqlEngine engine) { var results = engine.evaluate(library.getIdentifier()); // Primitives From 29b2cbdef2a74fc4f1cd5185403bd92a22d11442 Mon Sep 17 00:00:00 2001 From: Jonathan Percival Date: Thu, 19 Dec 2024 15:17:46 -0700 Subject: [PATCH 3/3] Remove potential thrown exception from Lambda --- .../org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java index 7528dd65c..0dc4fe0c0 100644 --- a/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java +++ b/Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/TestFHIRHelpers.java @@ -36,7 +36,8 @@ void testWithAmbiguousCompilerOptions() { var badOptionsEngine = new CqlEngine(new Environment(libraryManager)); badOptionsEngine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider); - assertThrows(CqlException.class, () -> badOptionsEngine.evaluate(library.getIdentifier())); + var identifier = library.getIdentifier(); + assertThrows(CqlException.class, () -> badOptionsEngine.evaluate(identifier)); } @Test