Skip to content

Commit

Permalink
Add tests to validate package operation with new expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris0296 committed Apr 15, 2024
1 parent 711873e commit 8851e73
Show file tree
Hide file tree
Showing 3 changed files with 1,010 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.UsageContext;
import org.hl7.fhir.r4.model.ValueSet;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.opencds.cqf.cql.evaluator.fhir.util.Canonicals;
import org.opencds.cqf.ruler.cr.CrConfig;
Expand Down Expand Up @@ -1321,6 +1322,51 @@ void packageOperation_big_bundle() {
assertTrue(packagedBundle.getEntry().size() == loadedBundle.getEntry().size());
}

@Disabled
@Test
// We need to disable this as it requires VSAC credentials to expand Value Sets
void packageOperation_expansion() {
loadTransaction("small-expansion-bundle.json");
Parameters emptyParams = parameters();
Bundle packagedBundle = getClient().operation()
.onInstance("Library/SmallSpecificationLibrary")
.named("$package")
.withParameters(emptyParams)
.returnResourceType(Bundle.class)
.execute();

List<ValueSet> leafValueSets = packagedBundle.getEntry().stream()
.filter(entry -> entry.getResource().getResourceType() == ResourceType.ValueSet)
.map(entry -> ((ValueSet) entry.getResource()))
.filter(valueSet -> !valueSet.hasCompose() || (valueSet.hasCompose() && valueSet.getCompose().getIncludeFirstRep().getValueSet().size() == 0))
.collect(Collectors.toList());

// Ensure expansion is populated and each code has correct version for all leaf value sets
leafValueSets.forEach(valueSet -> assertNotNull(valueSet.getExpansion()));
leafValueSets.stream().allMatch(vs -> vs.getExpansion().getContains().stream().allMatch(c -> c.getVersion().equals("http://snomed.info/sct/731000124108/version/20230901")));
}

@Test
void packageOperation_naive_expansion() {
loadTransaction("small-naive-expansion-bundle.json");
Parameters emptyParams = parameters();
Bundle packagedBundle = getClient().operation()
.onInstance("Library/SmallSpecificationLibrary")
.named("$package")
.withParameters(emptyParams)
.returnResourceType(Bundle.class)
.execute();

List<ValueSet> leafValueSets = packagedBundle.getEntry().stream()
.filter(entry -> entry.getResource().getResourceType() == ResourceType.ValueSet)
.map(entry -> ((ValueSet) entry.getResource()))
.filter(valueSet -> !valueSet.hasCompose() || (valueSet.hasCompose() && valueSet.getCompose().getIncludeFirstRep().getValueSet().size() == 0))
.collect(Collectors.toList());

// Ensure expansion is populated for all leaf value sets
leafValueSets.forEach(valueSet -> assertNotNull(valueSet.getExpansion()));
}

@Test
void package_test_condition_missing() {
loadTransaction("ersd-small-approved-draft-no-conditions.json");
Expand Down
Loading

0 comments on commit 8851e73

Please sign in to comment.