Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukedegruchy committed Dec 17, 2024
1 parent 377e753 commit 0617b2f
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 167 deletions.
5 changes: 0 additions & 5 deletions cqf-fhir-cr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
<artifactId>slf4j-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ protected Measure resolveById(IdType id) {
return this.repository.read(Measure.class, id);
}

// LUKETODO: Additional CQL parameter test
private Map<String, Object> resolveParameterMap(Parameters parameters) {
Map<String, Object> parameterMap = new HashMap<>();
R4FhirModelResolver modelResolver = new R4FhirModelResolver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ protected void scoreGroup(
var score = calcProportionScore(
getCountFromGroupPopulation(mrgc.getPopulation(), NUMERATOR),
getCountFromGroupPopulation(mrgc.getPopulation(), DENOMINATOR));
// LUKETODO: improvement notation
// LUKETODO: new feature in cdr $qpp-build since cdr assumes increase always
// LUKETODO: vituity authored the measures incorrectly as decrease.... maybe ... but Jusin needs to think about it
if (score != null) {
if (isIncreaseImprovementNotation) {
mrgc.setMeasureScore(new Quantity(score));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import jakarta.annotation.Nullable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
Expand All @@ -19,10 +20,8 @@
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jakarta.annotation.Nullable;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.MeasureReport;
import org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupComponent;
import org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupStratifierComponent;
import org.hl7.fhir.r4.model.MeasureReport.StratifierGroupComponent;
import org.hl7.fhir.r4.model.MeasureReport.StratifierGroupPopulationComponent;
Expand Down Expand Up @@ -117,28 +116,30 @@ void measure_eval_with_additional_data() {
assertEquals("2022-01-31", formatter.format(report.getPeriod().getEnd()));
}


private static Stream<Arguments> parametersTestParams() {
return Stream.of(
Arguments.of(null, 0, 0),
Arguments.of(Parameters.parameters(Parameters.part("encounter", "2d0ecfb4-9dec-4daa-a261-e37e426d0d7b")), 1, 1)
);
Arguments.of(null, 0, 0),
Arguments.of(
Parameters.parameters(Parameters.part("encounter", "2d0ecfb4-9dec-4daa-a261-e37e426d0d7b")),
1,
1));
}

@ParameterizedTest
@MethodSource("parametersTestParams")
void measure_eval_with_parameters_mega(@Nullable org.hl7.fhir.r4.model.Parameters parameters, int expectedMeasureScore, int expectedMeasureCount) {
void measure_eval_with_parameters_mega(
@Nullable org.hl7.fhir.r4.model.Parameters parameters, int expectedMeasureScore, int expectedMeasureCount) {
// This test should fail on numerator due to the encounter parameter not being set
var when = Measure.given()
.repositoryFor("ANC")
.when()
.measureId("ANCIND01")
.subject("Patient/457865b6-8f02-49e2-8a77-21b73eb266d4")
.periodStart("2018-01-01")
.periodEnd("2030-12-31")
.reportType("subject")
.parameters(parameters)
.evaluate();
.repositoryFor("ANC")
.when()
.measureId("ANCIND01")
.subject("Patient/457865b6-8f02-49e2-8a77-21b73eb266d4")
.periodStart("2018-01-01")
.periodEnd("2030-12-31")
.reportType("subject")
.parameters(parameters)
.evaluate();
MeasureReport report = when.then().report();
assertNotNull(report);
assertEquals(1, report.getGroup().size());
Expand All @@ -155,29 +156,33 @@ void measure_eval_with_parameters_mega(@Nullable org.hl7.fhir.r4.model.Parameter

private static Stream<Arguments> simpleParametersParams2() {
return Stream.of(
Arguments.of(null, 0),
Arguments.of(Parameters.parameters(Parameters.part("practitionerParam", "bogus")), 0),
Arguments.of(Parameters.parameters(Parameters.part("bogusPractitionerParam", "simpleCqlParamsPractitioner1")), 0),
Arguments.of(Parameters.parameters(Parameters.part("encounterParam", "bogus")), 0),
Arguments.of(Parameters.parameters(Parameters.part("bogusEncounterParam", "simpleCqlParamsEncounter1")), 0),
Arguments.of(Parameters.parameters(Parameters.part("practitionerParam", "simpleCqlParamsPractitioner1")), 1),
Arguments.of(Parameters.parameters(Parameters.part("encounterParam", "simpleCqlParamsEncounter1")), 1)
);
Arguments.of(null, 0),
Arguments.of(Parameters.parameters(Parameters.part("practitionerParam", "bogus")), 0),
Arguments.of(
Parameters.parameters(
Parameters.part("bogusPractitionerParam", "simpleCqlParamsPractitioner1")),
0),
Arguments.of(Parameters.parameters(Parameters.part("encounterParam", "bogus")), 0),
Arguments.of(
Parameters.parameters(Parameters.part("bogusEncounterParam", "simpleCqlParamsEncounter1")), 0),
Arguments.of(
Parameters.parameters(Parameters.part("practitionerParam", "simpleCqlParamsPractitioner1")), 1),
Arguments.of(Parameters.parameters(Parameters.part("encounterParam", "simpleCqlParamsEncounter1")), 1));
}

@ParameterizedTest
@MethodSource("simpleParametersParams2")
void simpleParameters(@Nullable org.hl7.fhir.r4.model.Parameters parameters, int expectedMeasureCount) {
var when = Measure.given()
.repositoryFor("SimpleCqlParameters")
.when()
.measureId("simpleCqlParameters")
.subject("Patient/simpleCqlParamsPatient1")
.periodStart("2018-01-01")
.periodEnd("2030-12-31")
.reportType("subject")
.parameters(parameters)
.evaluate();
.repositoryFor("SimpleCqlParameters")
.when()
.measureId("simpleCqlParameters")
.subject("Patient/simpleCqlParamsPatient1")
.periodStart("2018-01-01")
.periodEnd("2030-12-31")
.reportType("subject")
.parameters(parameters)
.evaluate();

var report = when.then().report();
assertNotNull(report);
Expand All @@ -191,8 +196,7 @@ void simpleParameters(@Nullable org.hl7.fhir.r4.model.Parameters parameters, int
}

private void assertPopulation(
int expectedMeasureCount,
MeasureReport.MeasureReportGroupPopulationComponent population) {
int expectedMeasureCount, MeasureReport.MeasureReportGroupPopulationComponent population) {
assertTrue(population.hasCount());
assertTrue(population.hasCode());
assertTrue(population.getCode().hasCoding());
Expand All @@ -215,27 +219,26 @@ private void assertStratifiers(
List<MeasureReportGroupStratifierComponent> stratifiers) {

var stratifierGroupComponents = stratifiers.stream()
.map(MeasureReportGroupStratifierComponent::getStratum)
.filter(not(Collection::isEmpty))
.map(strat -> strat.get(0))
.toList();

.map(MeasureReportGroupStratifierComponent::getStratum)
.filter(not(Collection::isEmpty))
.map(strat -> strat.get(0))
.toList();

var stratumScores = stratifierGroupComponents.stream()
.map(StratifierGroupComponent::getMeasureScore)
.map(Quantity::getValue)
.map(BigDecimal::intValue)
.toList();
.map(StratifierGroupComponent::getMeasureScore)
.map(Quantity::getValue)
.map(BigDecimal::intValue)
.toList();

assertEquals(1, stratumScores.size());
assertEquals(expectedMeasureScore, stratumScores.get(0));

var stratCountByPopType = stratifierGroupComponents.stream()
.map(StratifierGroupComponent::getPopulation)
.flatMap(List::stream)
.collect(Collectors.toMap(
pop -> pop.getCode().getCodingFirstRep().getCode(),
StratifierGroupPopulationComponent::getCount));
.map(StratifierGroupComponent::getPopulation)
.flatMap(List::stream)
.collect(Collectors.toMap(
pop -> pop.getCode().getCodingFirstRep().getCode(),
StratifierGroupPopulationComponent::getCount));

assertEquals(1, stratCountByPopType.get("initial-population"));
assertEquals(1, stratCountByPopType.get("denominator"));
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 0617b2f

Please sign in to comment.