mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-03 17:52:53 +00:00
Alternative Implementierung des Mappings Prozedur zu Protokollauszug
Diese Implementierung basiert auf der Zuordnung zum Formularnamen. Unbekannte Formulare werden zum leeren String gemappt.
This commit is contained in:
@ -38,8 +38,8 @@ public class PluginConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MtbService mtbService(final SettingsService settingsService) {
|
||||
return new DefaultMtbService(settingsService);
|
||||
public MtbService mtbService() {
|
||||
return new DefaultMtbService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -1,40 +1,32 @@
|
||||
package DNPM.services.mtb;
|
||||
|
||||
import DNPM.services.SettingsService;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Standardimplementierung des MtbService
|
||||
*
|
||||
* @since 0.0.2
|
||||
*/
|
||||
public class DefaultMtbService implements MtbService {
|
||||
|
||||
private final SettingsService settingsService;
|
||||
|
||||
public DefaultMtbService(final SettingsService settingsService) {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol(List<Procedure> procedures) {
|
||||
ProcedureToProtocolMapper mapper = null;
|
||||
var sid = settingsService.getSID();
|
||||
return procedures.stream()
|
||||
.sorted(Comparator.comparing(Procedure::getStartDate))
|
||||
.map(procedure -> {
|
||||
var mapper = MtbService.procedureToProtocolMapper(procedure);
|
||||
return mapper.apply(procedure);
|
||||
})
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.distinct()
|
||||
.collect(Collectors.joining("\n\n"));
|
||||
|
||||
if (sid.isPresent()) {
|
||||
switch (sid.get()) {
|
||||
case "2011":
|
||||
case "20119":
|
||||
mapper = new OsTumorkonferenzVarianteUkwToProtocolMapper();
|
||||
default:
|
||||
if (!settingsService.multipleMtbsInMtbEpisode()) {
|
||||
mapper = new OsTumorkonferenzToProtocolMapper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null == mapper) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return mapper.apply(procedures).orElse("");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,19 @@ package DNPM.services.mtb;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface MtbService {
|
||||
String getProtocol(List<Procedure> procedures);
|
||||
|
||||
static ProcedureToProtocolMapper procedureToProtocolMapper(Procedure procedure) {
|
||||
switch (procedure.getFormName()) {
|
||||
case "OS.Tumorkonferenz":
|
||||
return new OsTumorkonferenzToProtocolMapper();
|
||||
case "OS.Tumorkonferenz.VarianteUKW":
|
||||
return new OsTumorkonferenzVarianteUkwToProtocolMapper();
|
||||
default:
|
||||
return p -> Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,17 @@ package DNPM.services.mtb;
|
||||
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
* Mapper zum Ermitteln des Protokollauszugs für Formular "OS.Tumorkonferenz"
|
||||
*
|
||||
* @since 0.0.2
|
||||
*/
|
||||
public class OsTumorkonferenzToProtocolMapper implements ProcedureToProtocolMapper {
|
||||
@Override
|
||||
public Optional<String> apply(List<Procedure> procedures) {
|
||||
assert(procedures.size() == 1);
|
||||
|
||||
var procedure = procedures.get(0);
|
||||
|
||||
public Optional<String> apply(Procedure procedure) {
|
||||
assert(procedure.getFormName().equals("OS.Tumorkonferenz"));
|
||||
|
||||
var fragestellung = procedure.getValue("Fragestellung");
|
||||
|
@ -2,41 +2,31 @@ package DNPM.services.mtb;
|
||||
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Mapper zum Ermitteln des Protokollauszugs für Formular "OS.Tumorkonferenz.VarianteUKW"
|
||||
*
|
||||
* @since 0.0.2
|
||||
*/
|
||||
public class OsTumorkonferenzVarianteUkwToProtocolMapper implements ProcedureToProtocolMapper {
|
||||
@Override
|
||||
public Optional<String> apply(List<Procedure> procedures) {
|
||||
procedures.forEach(procedure -> {
|
||||
assert (procedure.getFormName().equals("OS.Tumorkonferenz.VarianteUKW"));
|
||||
});
|
||||
public Optional<String> apply(Procedure procedure) {
|
||||
assert (procedure.getFormName().equals("OS.Tumorkonferenz.VarianteUKW"));
|
||||
|
||||
procedures.sort(Comparator.comparing(Procedure::getStartDate));
|
||||
var fragestellung = procedure.getValue("Fragestellung");
|
||||
var empfehlung = procedure.getValue("Empfehlung");
|
||||
|
||||
var result = procedures.stream().map(procedure -> {
|
||||
var fragestellung = procedure.getValue("Fragestellung");
|
||||
var empfehlung = procedure.getValue("Empfehlung");
|
||||
|
||||
if (
|
||||
null != fragestellung && !fragestellung.getString().isBlank()
|
||||
&& null != empfehlung && !empfehlung.getString().isBlank()
|
||||
) {
|
||||
return String.format("Fragestellung:\n%s\n\nEmpfehlung:\n%s", fragestellung.getString().trim(), empfehlung.getString().trim());
|
||||
} else if (null != fragestellung && !fragestellung.getString().isBlank()) {
|
||||
return fragestellung.getString().trim();
|
||||
} else if (null != empfehlung && !empfehlung.getString().isBlank()) {
|
||||
return empfehlung.getString().trim();
|
||||
}
|
||||
return "";
|
||||
}).collect(Collectors.joining("\n\n"));
|
||||
|
||||
if (!result.isBlank()) {
|
||||
return Optional.of(result);
|
||||
if (
|
||||
null != fragestellung && !fragestellung.getString().isBlank()
|
||||
&& null != empfehlung && !empfehlung.getString().isBlank()
|
||||
) {
|
||||
return Optional.of(String.format("Fragestellung:\n%s\n\nEmpfehlung:\n%s", fragestellung.getString().trim(), empfehlung.getString().trim()));
|
||||
} else if (null != fragestellung && !fragestellung.getString().isBlank()) {
|
||||
return Optional.of(fragestellung.getString().trim());
|
||||
} else if (null != empfehlung && !empfehlung.getString().isBlank()) {
|
||||
return Optional.of(empfehlung.getString().trim());
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,8 @@ package DNPM.services.mtb;
|
||||
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ProcedureToProtocolMapper extends Function<List<Procedure>, Optional<String>> {}
|
||||
public interface ProcedureToProtocolMapper extends Function<Procedure, Optional<String>> {}
|
||||
|
Reference in New Issue
Block a user