-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not error for INDIVIDUAL reports for multiple SDEs. Centralize the…
… logic for converting report types to eval types. (#595) * Do not error out when building an INDIVIDUAL report for multiple SDEs. Centralize the logic for converting report types to eval types. * Add new proper Measure test to prove effect of production code change. * Add more scenarios to test. * Spotless.
- Loading branch information
1 parent
187daa0
commit 70801bc
Showing
12 changed files
with
331 additions
and
57 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
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
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
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
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
77 changes: 77 additions & 0 deletions
77
cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureMultipleSdeTest.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,77 @@ | ||
package org.opencds.cqf.fhir.cr.measure.r4; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsInAnyOrder; | ||
import static org.hamcrest.Matchers.greaterThanOrEqualTo; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import jakarta.annotation.Nullable; | ||
import org.hl7.fhir.r4.model.Extension; | ||
import org.hl7.fhir.r4.model.Reference; | ||
import org.hl7.fhir.r4.model.StringType; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
import org.opencds.cqf.fhir.cr.measure.r4.Measure.Given; | ||
|
||
public class MeasureMultipleSdeTest { | ||
private static final Given GIVEN_MULTIPLE_SDE_MEASURE_REPO = | ||
Measure.given().repositoryFor("BreastCancerScreeningFHIR"); | ||
|
||
@ParameterizedTest | ||
@CsvSource( | ||
value = { | ||
"null,null", | ||
"subject,null", | ||
"subject-list,null", | ||
"population,null", | ||
"null,Patient/numer-EXM125", | ||
"subject,Patient/numer-EXM125", | ||
"subject-list,Patient/numer-EXM125", | ||
"population,Patient/numer-EXM125", | ||
"null,Patient/denom-EXM125", | ||
"subject,Patient/denom-EXM125", | ||
"subject-list,Patient/denom-EXM125", | ||
"population,Patient/denom-EXM125", | ||
"null,Patient/numer-EXM125", | ||
"subject,Patient/numer-EXM125", | ||
"subject-list,Patient/numer-EXM125", | ||
"population,Patient/numer-EXM125", | ||
}, | ||
nullValues = {"null"}) | ||
void evaluateSucceedsMultipleSdesReportTypeSubjectAndSubjectNull( | ||
@Nullable String reportType, @Nullable String subject) { | ||
var when = GIVEN_MULTIPLE_SDE_MEASURE_REPO | ||
.when() | ||
.reportType(reportType) | ||
.subject(subject) | ||
.measureId("measure-EXM108-8.3.000") | ||
.evaluate(); | ||
|
||
var report = when.then().report(); | ||
assertNotNull(report); | ||
assertEquals(1, report.getGroup().size()); | ||
assertEquals(4, report.getGroupFirstRep().getPopulation().size()); | ||
|
||
var extensions = report.getExtension(); | ||
assertThat(extensions.size(), greaterThanOrEqualTo(4)); | ||
|
||
var extensionValues = extensions.stream() | ||
.map(Extension::getValue) | ||
.filter(Reference.class::isInstance) | ||
.map(Reference.class::cast) | ||
.map(Reference::getExtension) | ||
.filter(innerExtensions -> innerExtensions.size() == 1) | ||
.map(innerExtensions -> innerExtensions.get(0)) | ||
.map(Extension::getValue) | ||
.filter(StringType.class::isInstance) | ||
.map(StringType.class::cast) | ||
.map(StringType::getValue) | ||
.distinct() | ||
.toList(); | ||
|
||
assertThat(extensionValues, hasSize(3)); | ||
assertThat(extensionValues, containsInAnyOrder("sde-sex", "sde-race", "sde-ethnicity")); | ||
} | ||
} |
Oops, something went wrong.