Skip to content

Commit

Permalink
Only Process Completed Measure Reports
Browse files Browse the repository at this point in the history
  • Loading branch information
EmteZogaf committed Dec 21, 2023
1 parent 64db33a commit 2db03a1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.MEASURE_REPORT_PERIOD_START;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.VARIABLE_MEASURE_REPORT;
import static java.lang.String.format;
import static org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus.COMPLETE;
import static org.hl7.fhir.r4.model.MeasureReport.MeasureReportType.SUMMARY;

public class ObfuscateEvaluationResult extends AbstractServiceDelegate
Expand All @@ -41,7 +42,13 @@ public void afterPropertiesSet() throws Exception {
@Override
protected void doExecute(DelegateExecution execution, Variables variables) {
var measureReport = (MeasureReport) variables.getResource(VARIABLE_MEASURE_REPORT);
variables.setResource(VARIABLE_MEASURE_REPORT, obfuscateFeasibilityCount(measureReport));

if (measureReport.getStatus() == COMPLETE) {
variables.setResource(VARIABLE_MEASURE_REPORT, obfuscateFeasibilityCount(measureReport));
} else {
throw new RuntimeException(format("Expected status '%s' but actually is '%s' for measure report (id '%s').",
COMPLETE, measureReport.getStatus(), measureReport.getId()));
}
}

private MeasureReport obfuscateFeasibilityCount(MeasureReport measureReport) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus.COMPLETE;
import static org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus.PENDING;
import static org.hl7.fhir.r4.model.MeasureReport.MeasureReportType.SUMMARY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -254,4 +255,27 @@ void doExecuteFailsOnNoPopulationInMeasureReport() throws Exception {
}).hasMessage("Missing population with coding '%s' in measure report (id '%s').",
CODESYSTEM_MEASURE_POPULATION_VALUE_INITIAL_POPULATION, reportId);
}

@Test
@DisplayName("execution fails on incomplete measure report")
void doExecuteFailsOnWrongMeasureReportStatus() throws Exception {
var reportDate = new Date();
var measureUrl = "http://localhost/fhir/Measure/123456";
var reportId = "id-181407";
var measureReport = new MeasureReport()
.setStatus(PENDING)
.setType(SUMMARY)
.setMeasure(measureUrl)
.setDate(reportDate)
.setPeriod(new Period()
.setStart(new LocalDate(1312, 4, 9).toDate())
.setEnd(new LocalDate(1314, 1, 8).toDate()))
.setId(reportId);
when(variables.getResource(VARIABLE_MEASURE_REPORT)).thenReturn(measureReport);

assertThatThrownBy(() -> {
service.doExecute(execution, variables);
}).hasMessage("Expected status '%s' but actually is '%s' for measure report (id '%s').",
COMPLETE, PENDING, reportId);
}
}

0 comments on commit 2db03a1

Please sign in to comment.