Skip to content

Commit

Permalink
#1407: Set preserve to true for included value sets
Browse files Browse the repository at this point in the history
  • Loading branch information
antvaset committed Aug 29, 2024
1 parent 100ebe3 commit b321013
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,9 @@ public Expression resolveAccessor(Expression left, String memberIdentifier) {
ValueSetRef result =
of.createValueSetRef().withLibraryName(libraryName).withName(memberIdentifier);
result.setResultType(element.getResultType());
if (isCompatibleWith("1.5")) {
result.setPreserve(true);
}
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

import java.io.IOException;
import java.util.HashMap;
Expand Down Expand Up @@ -759,6 +757,26 @@ void issue863() throws IOException {
TestUtils.runSemanticTest("Issue863.cql", 0);
}

@Test
void issue1407() throws IOException {
assertNull(issue1407GetIsPreserve("1.4"));
assertTrue(issue1407GetIsPreserve("1.5"));
}

private Boolean issue1407GetIsPreserve(String compatibilityLevel) throws IOException {
CqlTranslator translator = runSemanticTest(
"LibraryTests/Issue1407.cql", 0, new CqlCompilerOptions().withCompatibilityLevel(compatibilityLevel));
var library = translator.toELM();
var testExpression = library.getStatements().getDef().stream()
.filter(def -> def.getName().equals("TestStatement"))
.findFirst()
.orElseThrow()
.getExpression();

assertThat(testExpression, instanceOf(ValueSetRef.class));
return ((ValueSetRef) testExpression).isPreserve();
}

private CqlTranslator runSemanticTest(String testFileName) throws IOException {
return runSemanticTest(testFileName, 0);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library Issue1407

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1' called FHIRHelpers

include Issue1407ValueSets

context Patient

define TestStatement: Issue1407ValueSets.TestValueSet
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library Issue1407ValueSets

using FHIR version '4.0.1'

valueset TestValueSet: 'garb'

0 comments on commit b321013

Please sign in to comment.