Skip to content

Commit

Permalink
Merge pull request #140 from medizininformatik-initiative/119-fix-ref…
Browse files Browse the repository at this point in the history
…erence-comparison-for-multi-valued-paths

Fix Reference Comparison for Multi-Valued Paths
  • Loading branch information
alexanderkiel authored Jul 12, 2024
2 parents cd27cba + 8cf1754 commit 2757176
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Container<QueryExpression> updateQuery(MappingContext mappingContext, Con
var referenceExpr = InvocationExpression.of(query.sourceAlias(), path);
var alias = StandardIdentifierExpression.of(targetType.substring(0, 1));
var ref = AdditionExpressionTerm.of(StringLiteralExpression.of(targetType + "/"), InvocationExpression.of(alias, "id"));
var comparatorExpr = ComparatorExpression.equal(referenceExpr, ref);
var comparatorExpr = MembershipExpression.contains(referenceExpr, ref);
return query.appendQueryInclusionClause(WithClause.of(AliasedQuerySource.of(referencesExprName, alias), comparatorExpr));
}));
}
Expand Down
23 changes: 21 additions & 2 deletions src/test/java/de/numcodex/sq2cql/AcceptanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.slf4j.Logger;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class AcceptanceTest {
private static final Logger logger = LoggerFactory.getLogger(AcceptanceTest.class);

private final GenericContainer<?> blaze = new GenericContainer<>(
DockerImageName.parse("samply/blaze:0.27"))
DockerImageName.parse("samply/blaze:0.28"))
.withImagePullPolicy(PullPolicy.alwaysPull())
.withEnv("LOG_LEVEL", "debug")
.withExposedPorts(8080)
Expand Down Expand Up @@ -158,7 +159,8 @@ public void consent() throws Exception {
}

@ParameterizedTest
@ValueSource(strings = {"large-query-worst-case-with-time-constraints.json", "test-large-query-more-crit-time-rest-1.json"})
@ValueSource(strings = {"large-query-worst-case-with-time-constraints.json",
"test-large-query-more-crit-time-rest-1.json"})
public void largeQuery(String filename) throws Exception {
var structuredQuery = new ObjectMapper().readValue(slurp(filename), StructuredQuery.class);
var cql = translator.toCql(structuredQuery).print();
Expand All @@ -168,6 +170,23 @@ public void largeQuery(String filename) throws Exception {
assertEquals(0, report.getGroupFirstRep().getPopulationFirstRep().getCount());
}

@ParameterizedTest
@CsvSource({
"SpecimenSQ.json, 0",
"SpecimenSQExclusion.json, 159",
"SpecimenSQTwoInclusion.json, 0",
"SpecimenSQTwoReferenceCriteria.json, 0",
"SpecimenSQAndBodySite.json, 0"
})
public void specimenQuery(String filename, int count) throws Exception {
var structuredQuery = new ObjectMapper().readValue(slurp(filename), StructuredQuery.class);
var cql = translator.toCql(structuredQuery).print();
var measureUri = createMeasureAndLibrary(cql);
var report = evaluateMeasure(measureUri);

assertEquals(count, report.getGroupFirstRep().getPopulationFirstRep().getCount());
}

private String createMeasureAndLibrary(String cql) throws Exception {
var libraryUri = "urn:uuid" + UUID.randomUUID();
var library = appendCql(parseResource(Library.class, slurp("Library.json")).setUrl(libraryUri), cql);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/de/numcodex/sq2cql/EvaluationIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class EvaluationIT {
static final Map<String, String> CODE_SYSTEM_ALIASES = Map.of("http://loinc.org", "loinc");

@Container
private final GenericContainer<?> blaze = new GenericContainer<>(DockerImageName.parse("samply/blaze:0.27"))
private final GenericContainer<?> blaze = new GenericContainer<>(DockerImageName.parse("samply/blaze:0.28"))
.withImagePullPolicy(PullPolicy.alwaysPull())
.withExposedPorts(8080)
.waitingFor(Wait.forHttp("/health").forStatusCode(200))
Expand Down
Loading

0 comments on commit 2757176

Please sign in to comment.