Skip to content

Commit

Permalink
MAT-5932 refactored code to move stratifications into seperate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sb-prateekkeerthi committed Nov 15, 2024
1 parent f915dfe commit a7e97d5
Showing 1 changed file with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ private List<MeasureReport.MeasureReportGroupComponent> buildMeasureReportGroupC
.map(
population -> {
var measureReportGroupComponent = new MeasureReport.MeasureReportGroupComponent();

if (population.getPopulationValues() != null) {
var measureReportGroupPopulationComponents =
population.getPopulationValues().stream()
Expand All @@ -266,35 +265,41 @@ private List<MeasureReport.MeasureReportGroupComponent> buildMeasureReportGroupC
measureReportGroupComponent.setPopulation(measureReportGroupPopulationComponents);
}

if (population.getStratificationValues() != null) {
var measureReportGroupStratifierComponents =
population.getStratificationValues().stream()
.map(
testCaseStratificationValue -> {
List<CodeableConcept> code = new ArrayList<CodeableConcept>();
code.add(
new CodeableConcept()
.setText(
getStratificationDefinition(
groups,
population.getGroupId(),
testCaseStratificationValue.getId())));

var stratifierComponent =
new MeasureReport.MeasureReportGroupStratifierComponent()
.setCode(code)
.setStratum(buildStratum(testCaseStratificationValue));
stratifierComponent.setId(testCaseStratificationValue.getId());
return stratifierComponent;
})
.collect(Collectors.toList());
measureReportGroupComponent.setStratifier(measureReportGroupStratifierComponents);
// adding stratification for patient basis
if (population.getStratificationValues() != null
&& StringUtils.equalsIgnoreCase("boolean", population.getPopulationBasis())) {
measureReportGroupComponent.setStratifier(
buildGroupStratifierComponentForPatientBasisMeasures(
population, groups, population.getGroupId()));
}
return measureReportGroupComponent;
})
.collect(Collectors.toList());
}

private List<MeasureReport.MeasureReportGroupStratifierComponent>
buildGroupStratifierComponentForPatientBasisMeasures(
TestCaseGroupPopulation population, List<Group> groups, String populationGroupId) {
return population.getStratificationValues().stream()
.map(
testCaseStratificationValue -> {
List<CodeableConcept> code = new ArrayList<CodeableConcept>();
code.add(
new CodeableConcept()
.setText(
getStratificationDefinition(
groups, populationGroupId, testCaseStratificationValue.getId())));

var stratifierComponent =
new MeasureReport.MeasureReportGroupStratifierComponent()
.setCode(code)
.setStratum(buildStratum(testCaseStratificationValue));
stratifierComponent.setId(testCaseStratificationValue.getId());
return stratifierComponent;
})
.collect(Collectors.toList());
}

private String getStratificationDefinition(
List<Group> groups, String populationId, String testCaseStratificationId) {
Group filteredGroup =
Expand Down

0 comments on commit a7e97d5

Please sign in to comment.