Skip to content

Commit

Permalink
MAT-7934: add index for measure observation on human readable (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
chubert-sb authored Nov 21, 2024
1 parent 712b88b commit ae98239
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,16 @@ List<HumanReadablePopulationModel> buildMeasureObservation(
return Collections.emptyList();
}

AtomicInteger index = new AtomicInteger(1);
return group.getMeasureObservations().stream()
.map(
measureObservation -> {
String display = PopulationType.MEASURE_OBSERVATION.getDisplay();
String display =
group.getMeasureObservations().size() > 1
? PopulationType.MEASURE_OBSERVATION.getDisplay()
+ " "
+ index.getAndIncrement()
: PopulationType.MEASURE_OBSERVATION.getDisplay();

if ("Ratio".equals(group.getScoring())) {
Population population =
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/gov/cms/madie/services/HumanReadableServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,30 @@ public void testBuildMeasureObservationForRatioAssociatedPopulationHasNoName() {
assertTrue(model.get(0).getDisplay().contains("None"));
}

@Test
public void testBuildMeasureObservationForRatioMultipleObservations() {
Group group = measure.getGroups().get(0);
group.setScoring("Ratio");
group.setMeasureObservations(
List.of(
MeasureObservation.builder()
.definition("Local Function")
.aggregateMethod("Average")
.criteriaReference("p1")
.build(),
MeasureObservation.builder()
.definition("Test Function")
.aggregateMethod("Average")
.criteriaReference("p1")
.build()));

List<HumanReadablePopulationModel> model =
humanReadableService.buildMeasureObservation(group, allDefinitions);
assertThat(CollectionUtils.isEmpty(model), is(false));
assertTrue(model.get(0).getDisplay().contains("Measure Observation 1"));
assertTrue(model.get(1).getDisplay().contains("Measure Observation 2"));
}

@Test
public void testBuildPopulationsNull() {
Group group = measure.getGroups().get(0);
Expand Down

0 comments on commit ae98239

Please sign in to comment.