Skip to content

Commit

Permalink
MAT-5932 added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sb-prateekkeerthi committed Nov 18, 2024
1 parent 5c40754 commit c101aa2
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ private List<MeasureReport.MeasureReportGroupComponent> buildMeasureReportGroupC
population, groups, population.getGroupId(), true));
} else {
measureReportGroupComponent.setStratifier(
buildGroupStratifierComponent(
population, groups, population.getGroupId(), false));
buildGroupStratifierComponent(population, null, null, false));
}
}
return measureReportGroupComponent;
Expand Down Expand Up @@ -366,7 +365,7 @@ private List<MeasureReport.StratifierGroupComponent> buildStratum(
// Non-patient based measures
stratifierGroupComponent.setValue(new CodeableConcept().setText(testCaseStratificationName));
stratifierGroupComponent.setPopulation(
FhirResourceHelpers.buildStratumPopulation(testCaseStratificationValue, true, false));
FhirResourceHelpers.buildStratumPopulation(testCaseStratificationValue, null, false));
stratum.add(stratifierGroupComponent);
}
return stratum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static int getExpectedInverseValue(int expectedValue) {

public static List<MeasureReport.StratifierGroupPopulationComponent> buildStratumPopulation(
TestCaseStratificationValue testCaseStratificationValue,
boolean valueIndex,
Boolean valueIndex,
boolean isPatientBased) {
var measureTestCaseStratificationComponents =
testCaseStratificationValue.getPopulationValues().stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package gov.cms.madie.madiefhirservice.utils;

import gov.cms.madie.models.measure.PopulationType;
import gov.cms.madie.models.measure.TestCasePopulationValue;
import gov.cms.madie.models.measure.TestCaseStratificationValue;
import org.hl7.fhir.r4.model.MeasureReport;
import org.junit.jupiter.api.Test;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class FhirResourceHelpersTest {
@Test
void testexpectedInverseValue() {
assertEquals(1, FhirResourceHelpers.getExpectedInverseValue(0));
assertEquals(0, FhirResourceHelpers.getExpectedInverseValue(1));
}

@Test
void testBuildStratumPopulationForValueIndexOfTrue() {
TestCaseStratificationValue stratValue1 =
TestCaseStratificationValue.builder().name("Strata-1").expected(1).build();
stratValue1.setPopulationValues(
List.of(
TestCasePopulationValue.builder()
.id("1")
.name(PopulationType.INITIAL_POPULATION)
.expected(1)
.build(),
TestCasePopulationValue.builder()
.id("2")
.name(PopulationType.DENOMINATOR)
.expected(1)
.build(),
TestCasePopulationValue.builder()
.id("3")
.name(PopulationType.NUMERATOR)
.expected(0)
.build()));

List<MeasureReport.StratifierGroupPopulationComponent> stratifierGroupPopulationComponents =
FhirResourceHelpers.buildStratumPopulation(stratValue1, true, true);

assertEquals(stratifierGroupPopulationComponents.size(), 3);
assertEquals(
stratifierGroupPopulationComponents.get(0).getCode().getCoding().get(0).getCode(),
"initial-population");
assertEquals(stratifierGroupPopulationComponents.get(0).getCount(), 1);
assertEquals(
stratifierGroupPopulationComponents.get(1).getCode().getCoding().get(0).getCode(),
"denominator");
assertEquals(stratifierGroupPopulationComponents.get(1).getCount(), 1);
assertEquals(
stratifierGroupPopulationComponents.get(2).getCode().getCoding().get(0).getCode(),
"numerator");
assertEquals(stratifierGroupPopulationComponents.get(2).getCount(), 0);
}

@Test
void testBuildStratumPopulationForValueIndexOfFalse() {
TestCaseStratificationValue stratValue1 =
TestCaseStratificationValue.builder().name("Strata-1").expected(1).build();
stratValue1.setPopulationValues(
List.of(
TestCasePopulationValue.builder()
.id("1")
.name(PopulationType.INITIAL_POPULATION)
.expected(1)
.build(),
TestCasePopulationValue.builder()
.id("2")
.name(PopulationType.DENOMINATOR)
.expected(1)
.build(),
TestCasePopulationValue.builder()
.id("3")
.name(PopulationType.NUMERATOR)
.expected(0)
.build()));

List<MeasureReport.StratifierGroupPopulationComponent> stratifierGroupPopulationComponents =
FhirResourceHelpers.buildStratumPopulation(stratValue1, false, true);

assertEquals(stratifierGroupPopulationComponents.size(), 3);
assertEquals(
stratifierGroupPopulationComponents.get(0).getCode().getCoding().get(0).getCode(),
"initial-population");
assertEquals(stratifierGroupPopulationComponents.get(0).getCount(), 0);
assertEquals(
stratifierGroupPopulationComponents.get(1).getCode().getCoding().get(0).getCode(),
"denominator");
assertEquals(stratifierGroupPopulationComponents.get(1).getCount(), 0);
assertEquals(
stratifierGroupPopulationComponents.get(2).getCode().getCoding().get(0).getCode(),
"numerator");
assertEquals(stratifierGroupPopulationComponents.get(2).getCount(), 1);
}

@Test
void testBuildStratumPopulationForNonPatientBasedMeasures() {
TestCaseStratificationValue stratValue1 =
TestCaseStratificationValue.builder().name("Strata-1").expected(1).build();
stratValue1.setPopulationValues(
List.of(
TestCasePopulationValue.builder()
.id("1")
.name(PopulationType.INITIAL_POPULATION)
.expected(5)
.build(),
TestCasePopulationValue.builder()
.id("2")
.name(PopulationType.DENOMINATOR)
.expected(4)
.build(),
TestCasePopulationValue.builder()
.id("3")
.name(PopulationType.NUMERATOR)
.expected(2)
.build()));

List<MeasureReport.StratifierGroupPopulationComponent> stratifierGroupPopulationComponents =
FhirResourceHelpers.buildStratumPopulation(stratValue1, null, false);

assertEquals(stratifierGroupPopulationComponents.size(), 3);
assertEquals(
stratifierGroupPopulationComponents.get(0).getCode().getCoding().get(0).getCode(),
"initial-population");
assertEquals(stratifierGroupPopulationComponents.get(0).getCount(), 5);
assertEquals(
stratifierGroupPopulationComponents.get(1).getCode().getCoding().get(0).getCode(),
"denominator");
assertEquals(stratifierGroupPopulationComponents.get(1).getCount(), 4);
assertEquals(
stratifierGroupPopulationComponents.get(2).getCode().getCoding().get(0).getCode(),
"numerator");
assertEquals(stratifierGroupPopulationComponents.get(2).getCount(), 2);
}
}

0 comments on commit c101aa2

Please sign in to comment.