Skip to content

Commit

Permalink
Only Copy Necessary Information into Obfuscated Measure Report
Browse files Browse the repository at this point in the history
Check measure report for containing an initial-population.
Always use default time period in measure report.
  • Loading branch information
EmteZogaf committed Dec 21, 2023
1 parent 667db6b commit 64db33a
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import java.util.Objects;

import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.MEASURE_REPORT_PERIOD_END;
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_ID;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.VARIABLE_MEASURE_REPORT;

Expand Down Expand Up @@ -52,8 +54,8 @@ protected void doExecute(DelegateExecution execution, Variables variables) {
private MeasureReport executeEvaluateMeasure(String measureId) {
logger.debug("Evaluate measure {}", measureId);
return storeClient.operation().onInstance("Measure/" + measureId).named("evaluate-measure")
.withParameter(Parameters.class, "periodStart", new DateType(1900, 1, 1))
.andParameter("periodEnd", new DateType(2100, 1, 1))
.withParameter(Parameters.class, "periodStart", new DateType(MEASURE_REPORT_PERIOD_START))
.andParameter("periodEnd", new DateType(MEASURE_REPORT_PERIOD_END))
.useHttpGet()
.returnResourceType(MeasureReport.class)
.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupComponent;
import org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupPopulationComponent;
import org.hl7.fhir.r4.model.Period;
import org.joda.time.LocalDate;
import org.springframework.beans.factory.InitializingBean;

import java.io.IOException;
Expand All @@ -23,6 +22,8 @@

import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.CODESYSTEM_MEASURE_POPULATION;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.CODESYSTEM_MEASURE_POPULATION_VALUE_INITIAL_POPULATION;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.MEASURE_REPORT_PERIOD_END;
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_LIBRARY;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.VARIABLE_MEASURE;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.VARIABLE_MEASURE_REPORT;
Expand Down Expand Up @@ -78,8 +79,8 @@ private MeasureReport buildMeasureReport(String measureRef, int feasibility) {
.setDate(new Date())
.setMeasure(measureRef)
.setPeriod(new Period()
.setStart(new LocalDate(1900, 1, 1).toDate())
.setEnd(new LocalDate(2100, 1, 1).toDate()));
.setStart(MEASURE_REPORT_PERIOD_START)
.setEnd(MEASURE_REPORT_PERIOD_END));

var populationGroup = new MeasureReportGroupPopulationComponent()
.setCount(feasibility)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
import dev.dsf.bpe.v1.activity.AbstractServiceDelegate;
import dev.dsf.bpe.v1.variables.Variables;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.MeasureReport;
import org.hl7.fhir.r4.model.MeasureReport.MeasureReportGroupPopulationComponent;
import org.hl7.fhir.r4.model.Period;
import org.springframework.beans.factory.InitializingBean;

import java.util.Objects;

import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.CODESYSTEM_MEASURE_POPULATION;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.CODESYSTEM_MEASURE_POPULATION_VALUE_INITIAL_POPULATION;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.MEASURE_REPORT_PERIOD_END;
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.MeasureReportType.SUMMARY;

public class ObfuscateEvaluationResult extends AbstractServiceDelegate
implements InitializingBean {
Expand All @@ -35,11 +45,32 @@ protected void doExecute(DelegateExecution execution, Variables variables) {
}

private MeasureReport obfuscateFeasibilityCount(MeasureReport measureReport) {
var obfuscatedFeasibilityCount = obfuscator.obfuscate(measureReport.getGroupFirstRep().
getPopulationFirstRep().getCount());
var obfuscatedFeasibilityCount = obfuscator.obfuscate(extractInitialPopulation(measureReport).getCount());

var obfuscatedMeasureReport = new MeasureReport()
.setStatus(COMPLETE)
.setType(SUMMARY)
.setMeasure(measureReport.getMeasure())
.setPeriod(new Period()
.setStart(MEASURE_REPORT_PERIOD_START)
.setEnd(MEASURE_REPORT_PERIOD_END));

obfuscatedMeasureReport.getGroupFirstRep().getPopulationFirstRep()
.setCode(new CodeableConcept().addCoding(new Coding().setSystem(CODESYSTEM_MEASURE_POPULATION)
.setCode(CODESYSTEM_MEASURE_POPULATION_VALUE_INITIAL_POPULATION)))
.setCount(obfuscatedFeasibilityCount);

var obfuscatedMeasureReport = measureReport.copy();
obfuscatedMeasureReport.getGroupFirstRep().getPopulationFirstRep().setCount(obfuscatedFeasibilityCount);
return obfuscatedMeasureReport;
}

private MeasureReportGroupPopulationComponent extractInitialPopulation(MeasureReport measureReport) {
return measureReport.getGroupFirstRep().getPopulation().stream()
.filter((p) -> p.getCode().getCoding().stream()
.anyMatch((c) -> c.getSystem().equals(CODESYSTEM_MEASURE_POPULATION) && c.getCode()
.equals(CODESYSTEM_MEASURE_POPULATION_VALUE_INITIAL_POPULATION)))
.findFirst()
.orElseThrow(() -> new RuntimeException(
format("Missing population with coding '%s' in measure report (id '%s').",
CODESYSTEM_MEASURE_POPULATION_VALUE_INITIAL_POPULATION, measureReport.getId())));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package de.medizininformatik_initiative.feasibility_dsf_process.variables;

import org.joda.time.LocalDate;

import java.util.Date;

public interface ConstantsFeasibility {
String VARIABLE_MEASURE = "measure";
String VARIABLE_LIBRARY = "library";
Expand All @@ -23,4 +27,7 @@ public interface ConstantsFeasibility {

String FEASIBILITY_REQUEST_PROCESS_ID = "medizininformatik-initiativede_feasibilityRequest";
String FEASIBILITY_EXECUTE_PROCESS_ID = "medizininformatik-initiativede_feasibilityExecute";

Date MEASURE_REPORT_PERIOD_START = new LocalDate(1900, 1, 1).toDate();
Date MEASURE_REPORT_PERIOD_END = new LocalDate(2100, 1, 1).toDate();
}
Loading

0 comments on commit 64db33a

Please sign in to comment.