diff --git a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SemanticTests.java b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SemanticTests.java index c0093dc27..5a615f5ea 100644 --- a/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SemanticTests.java +++ b/Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/SemanticTests.java @@ -718,6 +718,31 @@ public void testIfConditionalReturnTypes() throws IOException { assertTrue("Expected return types are String and Boolean: ", actualChoiceTypes.equals(expectedChoiceTypes)); } + @Test + public void testIssue1225() throws IOException { + CqlTranslator translator = TestUtils.runSemanticTest("Issue1225.cql", 0); + Library library = translator.toELM(); + Map defs = new HashMap<>(); + + if (library.getStatements() != null) { + for (ExpressionDef def : library.getStatements().getDef()) { + defs.put(def.getName(), def); + } + } + /* Execute CQL for USCore v3.1.1 Patient.address.line and Patient.address.line[0] */ + ExpressionDef def = defs.get("Address"); + assertThat(def.getExpression(), instanceOf(Flatten.class)); + def = defs.get("Address Line 1"); + assertThat(def.getExpression(), instanceOf(Indexer.class)); + Indexer i = (Indexer)def.getExpression(); + assertThat(i.getOperand().size(), is(2)); + assertThat(i.getOperand().get(0), instanceOf(Flatten.class)); + Flatten f = (Flatten)i.getOperand().get(0); + assertThat(f.getOperand(), instanceOf(Query.class)); + Query q = (Query)f.getOperand(); + assertThat(q.getSource().size(), is(1)); + } + private CqlTranslator runSemanticTest(String testFileName) throws IOException { return runSemanticTest(testFileName, 0); } diff --git a/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/Issue1225.cql b/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/Issue1225.cql new file mode 100644 index 000000000..17d14fc53 --- /dev/null +++ b/Src/java/cql-to-elm/src/test/resources/org/cqframework/cql/cql2elm/Issue1225.cql @@ -0,0 +1,13 @@ +library Issue1225 + +using USCore version '3.1.1' + +include FHIRHelpers version '4.0.1' + +context Patient + +define "Address": + Patient.address.line + +define "Address Line 1": + Patient.address.line[0] \ No newline at end of file