-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes for Union * More tests
- Loading branch information
Showing
7 changed files
with
138 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Src/java/engine-fhir/src/test/java/org/opencds/cqf/cql/engine/fhir/data/Issue1441.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.opencds.cqf.cql.engine.fhir.data; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertIterableEquals; | ||
|
||
import java.util.Collections; | ||
import org.hl7.fhir.r4.model.Encounter; | ||
import org.hl7.fhir.r4.model.Patient; | ||
import org.hl7.fhir.r4.model.Procedure; | ||
import org.junit.jupiter.api.Test; | ||
import org.opencds.cqf.cql.engine.data.CompositeDataProvider; | ||
import org.opencds.cqf.cql.engine.retrieve.RetrieveProvider; | ||
import org.opencds.cqf.cql.engine.runtime.Code; | ||
import org.opencds.cqf.cql.engine.runtime.Interval; | ||
|
||
// https://github.com/cqframework/clinical_quality_language/issues/1441 | ||
// unions without aliases are not working | ||
class Issue1441 extends FhirExecutionTestBase { | ||
|
||
@Test | ||
void unionsWithoutAliasesAreTheSameAsUnionsWithAliases() { | ||
var patient = new Patient().setId("123"); | ||
var observation = new Encounter().setId("456"); | ||
var procedure = new Procedure().setId("789"); | ||
|
||
var r = new RetrieveProvider() { | ||
@Override | ||
public Iterable<Object> retrieve( | ||
String context, | ||
String contextPath, | ||
Object contextValue, | ||
String dataType, | ||
String templateId, | ||
String codePath, | ||
Iterable<Code> codes, | ||
String valueSet, | ||
String datePath, | ||
String dateLowPath, | ||
String dateHighPath, | ||
Interval dateRange) { | ||
|
||
switch (dataType) { | ||
case "Patient": | ||
return Collections.singletonList(patient); | ||
case "Observation": | ||
return Collections.singletonList(observation); | ||
case "Procedure": | ||
return Collections.singletonList(procedure); | ||
default: | ||
return Collections.emptyList(); | ||
} | ||
} | ||
}; | ||
|
||
var engine = getEngine(); | ||
engine.getState() | ||
.getEnvironment() | ||
.registerDataProvider("http://hl7.org/fhir", new CompositeDataProvider(r4ModelResolver, r)); | ||
var result = engine.evaluate("Issue1441"); | ||
var x = (Iterable<?>) result.forExpression("x").value(); | ||
var y = (Iterable<?>) result.forExpression("y").value(); | ||
|
||
assertIterableEquals(x, y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Src/java/engine-fhir/src/test/resources/org/opencds/cqf/cql/engine/fhir/data/Issue1441.cql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
library "Issue1441" version '1' | ||
|
||
// https://github.com/cqframework/clinical_quality_language/issues/1441 | ||
// Unions of unaliased retrieves not working | ||
|
||
using FHIR version '4.0.1' | ||
|
||
context Patient | ||
|
||
define x: | ||
[Observation] a | ||
union [Procedure] b | ||
|
||
define y: | ||
[Observation] | ||
union [Procedure] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 12 additions & 1 deletion
13
Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/TestUnion.cql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters