From 0617b2f2a313e6411a8258ea0fc9feac27719754 Mon Sep 17 00:00:00 2001 From: Luke deGruchy Date: Tue, 17 Dec 2024 16:31:08 -0500 Subject: [PATCH] Cleanup. --- cqf-fhir-cr/pom.xml | 5 - .../cr/measure/r4/R4MeasureProcessor.java | 1 - .../cr/measure/r4/R4MeasureReportScorer.java | 3 - .../r4/MeasureProcessorEvaluateTest.java | 101 +++++++++--------- .../fhir/cr/measure/r4/ANC/cql/ANC_SIMPLE.cql | 25 ----- .../resources/library/library-ANC_SIMPLE.json | 19 ---- .../r4/ANC/resources/measure/ANC_SIMPLE.json | 65 ----------- 7 files changed, 52 insertions(+), 167 deletions(-) delete mode 100644 cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/cql/ANC_SIMPLE.cql delete mode 100644 cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/resources/library/library-ANC_SIMPLE.json delete mode 100644 cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/resources/measure/ANC_SIMPLE.json diff --git a/cqf-fhir-cr/pom.xml b/cqf-fhir-cr/pom.xml index 5d95d062a..b6085b044 100644 --- a/cqf-fhir-cr/pom.xml +++ b/cqf-fhir-cr/pom.xml @@ -76,11 +76,6 @@ slf4j-test test - - org.junit.platform - junit-platform-engine - test - diff --git a/cqf-fhir-cr/src/main/java/org/opencds/cqf/fhir/cr/measure/r4/R4MeasureProcessor.java b/cqf-fhir-cr/src/main/java/org/opencds/cqf/fhir/cr/measure/r4/R4MeasureProcessor.java index 6cd744c69..86a4dcd3d 100644 --- a/cqf-fhir-cr/src/main/java/org/opencds/cqf/fhir/cr/measure/r4/R4MeasureProcessor.java +++ b/cqf-fhir-cr/src/main/java/org/opencds/cqf/fhir/cr/measure/r4/R4MeasureProcessor.java @@ -179,7 +179,6 @@ protected Measure resolveById(IdType id) { return this.repository.read(Measure.class, id); } - // LUKETODO: Additional CQL parameter test private Map resolveParameterMap(Parameters parameters) { Map parameterMap = new HashMap<>(); R4FhirModelResolver modelResolver = new R4FhirModelResolver(); diff --git a/cqf-fhir-cr/src/main/java/org/opencds/cqf/fhir/cr/measure/r4/R4MeasureReportScorer.java b/cqf-fhir-cr/src/main/java/org/opencds/cqf/fhir/cr/measure/r4/R4MeasureReportScorer.java index 21674918e..ed4c5b0e0 100644 --- a/cqf-fhir-cr/src/main/java/org/opencds/cqf/fhir/cr/measure/r4/R4MeasureReportScorer.java +++ b/cqf-fhir-cr/src/main/java/org/opencds/cqf/fhir/cr/measure/r4/R4MeasureReportScorer.java @@ -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)); diff --git a/cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureProcessorEvaluateTest.java b/cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureProcessorEvaluateTest.java index e3035abaf..097103f0c 100644 --- a/cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureProcessorEvaluateTest.java +++ b/cqf-fhir-cr/src/test/java/org/opencds/cqf/fhir/cr/measure/r4/MeasureProcessorEvaluateTest.java @@ -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; @@ -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; @@ -117,28 +116,30 @@ void measure_eval_with_additional_data() { assertEquals("2022-01-31", formatter.format(report.getPeriod().getEnd())); } - private static Stream 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()); @@ -155,29 +156,33 @@ void measure_eval_with_parameters_mega(@Nullable org.hl7.fhir.r4.model.Parameter private static Stream 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); @@ -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()); @@ -215,27 +219,26 @@ private void assertStratifiers( List 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")); diff --git a/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/cql/ANC_SIMPLE.cql b/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/cql/ANC_SIMPLE.cql deleted file mode 100644 index 9e4c3c756..000000000 --- a/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/cql/ANC_SIMPLE.cql +++ /dev/null @@ -1,25 +0,0 @@ -library ANC_SIMPLE - -using FHIR version '4.0.1' - -include FHIRHelpers version '4.0.1' called FHIRHelpers - -include ANCStratifiers called Stratifiers - -parameter "Measurement Period" Interval default Interval[@2024-01-01T00:00:00, @2024-12-31T23:59:59] - -// cql parameter that can pass in fhir id of an encounter -parameter practitionerParam String - -context Patient - -define "Matching General Practitioner": - [Patient] p - where Last(Split(First(p.generalPractitioner.reference),'/')) = Last(Split(practitionerParam,'/')) - -/* -Disaggregation: Age (10-14, 15-19, 20+) -*/ -define "Age Stratifier": - Stratifiers."By Age" - diff --git a/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/resources/library/library-ANC_SIMPLE.json b/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/resources/library/library-ANC_SIMPLE.json deleted file mode 100644 index 19e3f2cac..000000000 --- a/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/resources/library/library-ANC_SIMPLE.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "resourceType": "Library", - "id": "ANC_SIMPLE", - "url": "http://fhir.org/guides/who/anc-cds/Library/ANC_SIMPLE", - "name": "ANC_SIMPLE", - "title": "ANC_SIMPLE", - "status": "active", - "type": { - "coding": [ { - "system": "http://terminology.hl7.org/CodeSystem/library-type", - "code": "logic-library" - } ] - }, - "content": [ { - "contentType": "text/cql", - "url": "../../cql/ANC_SIMPLE.cql" - } - ] -} \ No newline at end of file diff --git a/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/resources/measure/ANC_SIMPLE.json b/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/resources/measure/ANC_SIMPLE.json deleted file mode 100644 index 953e62dfc..000000000 --- a/cqf-fhir-cr/src/test/resources/org/opencds/cqf/fhir/cr/measure/r4/ANC/resources/measure/ANC_SIMPLE.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "resourceType": "Measure", - "id": "ANC_SIMPLE", - "url": "http://fhir.org/guides/who/anc-cds/Measure/ANC_SIMPLE", - "name": "ANC_SIMPLE", - "relatedArtifact": [ { - "type": "depends-on", - "display": "Library Stratifiers", - "resource": "http://fhir.org/guides/who/anc-cds/Library/ANCStratifiers" - } ], - "library": [ "http://fhir.org/guides/who/anc-cds/Library/ANCIND01" ], - "scoring": { - "coding": [ { - "system": "http://terminology.hl7.org/CodeSystem/measure-scoring", - "code": "proportion" - } ] - }, - "group": [ { - "id": "group-1", - "population": [ { - "id": "initial-population", - "code": { - "coding": [ { - "system": "http://terminology.hl7.org/CodeSystem/measure-population", - "code": "initial-population" - } ] - }, - "criteria": { - "language": "text/cql-identifier", - "expression": "Initial Population" - } - }, { - "id": "denominator", - "code": { - "coding": [ { - "system": "http://terminology.hl7.org/CodeSystem/measure-population", - "code": "denominator" - } ] - }, - "criteria": { - "language": "text/cql-identifier", - "expression": "Denominator" - } - }, { - "id": "numerator", - "code": { - "coding": [ { - "system": "http://terminology.hl7.org/CodeSystem/measure-population", - "code": "numerator" - } ] - }, - "criteria": { - "language": "text/cql-identifier", - "expression": "Numerator" - } - } ], - "stratifier": [ { - "id": "by-age", - "criteria": { - "language": "text/cql-identifier", - "expression": "Age Stratifier" - } - } ] - } ] -} \ No newline at end of file