From 100ebe301fee316b0552bc71f8b081a74397dbc9 Mon Sep 17 00:00:00 2001 From: Luke deGruchy Date: Mon, 26 Aug 2024 11:18:31 -0400 Subject: [PATCH] Ensure a CQL expression referencing an abstract class/non-retrievable class, such as DomainResource, will fail. (#1404) --- .../org/cqframework/cql/cql2elm/TranslationTests.java | 10 ++++++++++ .../cql/cql2elm/abstractClassNotRetrievable.cql | 10 ++++++++++ .../test/resources/org/hl7/cql/model/a-modelinfo.xml | 2 +- .../org/hl7/cql/model/fhir-modelinfo-4.0.1-1.5.1.xml | 2 +- .../cql/model/fhir-modelinfo-4.0.1-with-metadata.xml | 2 +- .../org/hl7/cql/model/fhir-modelinfo-4.0.1.xml | 2 +- .../org/hl7/cql/model/mat-fhir-modelinfo-4.0.1.xml | 2 +- .../org/hl7/cql/model/new-fhir-modelinfo-4.0.1.xml | 2 +- .../resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml | 2 +- 9 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/abstractClassNotRetrievable.cql diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TranslationTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TranslationTests.java index c996384fe..afcfa35f5 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TranslationTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/TranslationTests.java @@ -380,4 +380,14 @@ void hidingVariousUseCases() throws IOException { hidingLetFhir, hidingAliasLet)); } + + @Test + void abstractClassNotRetrievable() throws IOException { + // See: https://github.com/cqframework/clinical_quality_language/issues/1392 + final CqlTranslator translator = TestUtils.runSemanticTest("abstractClassNotRetrievable.cql", 1); + final List errors = translator.getErrors(); + final List errorMessages = + errors.stream().map(Throwable::getMessage).toList(); + assertThat(errorMessages, contains("Specified data type DomainResource does not support retrieval.")); + } } diff --git a/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/abstractClassNotRetrievable.cql b/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/abstractClassNotRetrievable.cql new file mode 100644 index 000000000..eaa2b1c8c --- /dev/null +++ b/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/abstractClassNotRetrievable.cql @@ -0,0 +1,10 @@ +library abstractClassNotRetrievable + +using FHIR version '4.0.1' + +include FHIRHelpers version '4.0.1' + +context Patient + +define "Bar": + [DomainResource] // should be marked non-retrievable, should give error/warning in translator diff --git a/Src/java/model/src/test/resources/org/hl7/cql/model/a-modelinfo.xml b/Src/java/model/src/test/resources/org/hl7/cql/model/a-modelinfo.xml index 85e4edb86..a52cd87d2 100644 --- a/Src/java/model/src/test/resources/org/hl7/cql/model/a-modelinfo.xml +++ b/Src/java/model/src/test/resources/org/hl7/cql/model/a-modelinfo.xml @@ -3562,7 +3562,7 @@ - + diff --git a/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-1.5.1.xml b/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-1.5.1.xml index 006937bff..40c007958 100644 --- a/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-1.5.1.xml +++ b/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-1.5.1.xml @@ -3562,7 +3562,7 @@ - + diff --git a/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-with-metadata.xml b/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-with-metadata.xml index 5105a4e70..ac7c247bd 100644 --- a/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-with-metadata.xml +++ b/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1-with-metadata.xml @@ -8753,7 +8753,7 @@ - + diff --git a/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1.xml b/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1.xml index f4e66fb74..fa9142aea 100644 --- a/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1.xml +++ b/Src/java/model/src/test/resources/org/hl7/cql/model/fhir-modelinfo-4.0.1.xml @@ -3562,7 +3562,7 @@ - + diff --git a/Src/java/model/src/test/resources/org/hl7/cql/model/mat-fhir-modelinfo-4.0.1.xml b/Src/java/model/src/test/resources/org/hl7/cql/model/mat-fhir-modelinfo-4.0.1.xml index bb79f42da..92d951d44 100644 --- a/Src/java/model/src/test/resources/org/hl7/cql/model/mat-fhir-modelinfo-4.0.1.xml +++ b/Src/java/model/src/test/resources/org/hl7/cql/model/mat-fhir-modelinfo-4.0.1.xml @@ -3685,7 +3685,7 @@ - + diff --git a/Src/java/model/src/test/resources/org/hl7/cql/model/new-fhir-modelinfo-4.0.1.xml b/Src/java/model/src/test/resources/org/hl7/cql/model/new-fhir-modelinfo-4.0.1.xml index fe7d6dea1..c628592aa 100644 --- a/Src/java/model/src/test/resources/org/hl7/cql/model/new-fhir-modelinfo-4.0.1.xml +++ b/Src/java/model/src/test/resources/org/hl7/cql/model/new-fhir-modelinfo-4.0.1.xml @@ -3562,7 +3562,7 @@ - + diff --git a/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml b/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml index ecee11d55..2c6996244 100644 --- a/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml +++ b/Src/java/quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml @@ -8753,7 +8753,7 @@ - +