1
0
mirror of https://github.com/pcvolkmer/onkostar-plugin-dnpm.git synced 2025-07-03 09:42:54 +00:00

Issue #11: Service zum Generieren des Protokollauszugs aus MTBs

Implementierungen vorhanden für die Formulare:
* OS.Tumorkonferenz
* OS.Tumorkonferenz.VarianteUKW
This commit is contained in:
2023-03-20 16:43:07 +01:00
parent ef5c91a352
commit 887221d5ae
6 changed files with 243 additions and 0 deletions

View File

@ -0,0 +1,39 @@
package DNPM.services.mtb;
import DNPM.services.SettingsService;
import de.itc.onkostar.api.Procedure;
import java.util.List;
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();
if (sid.isPresent()) {
switch (sid.get()) {
case "20119":
mapper = new OsTumorkonferenzVarianteUkwToProtocolMapper();
default:
if (!settingsService.multipleMtbsInMtbEpisode()) {
mapper = new OsTumorkonferenzToProtocolMapper();
}
}
}
if (null == mapper) {
return "";
}
return mapper.apply(procedures).orElse("");
}
}

View File

@ -0,0 +1,9 @@
package DNPM.services.mtb;
import de.itc.onkostar.api.Procedure;
import java.util.List;
public interface MtbService {
String getProtocol(List<Procedure> procedures);
}

View File

@ -0,0 +1,33 @@
package DNPM.services.mtb;
import de.itc.onkostar.api.Procedure;
import java.util.List;
import java.util.Optional;
public class OsTumorkonferenzToProtocolMapper implements ProcedureToProtocolMapper {
@Override
public Optional<String> apply(List<Procedure> procedures) {
assert(procedures.size() == 1);
var procedure = procedures.get(0);
assert(procedure.getFormName().equals("OS.Tumorkonferenz"));
var fragestellung = procedure.getValue("Fragestellung");
var empfehlung = procedure.getValue("Empfehlung");
if (
null != fragestellung && !fragestellung.getString().isBlank()
&& null != empfehlung && !empfehlung.getString().isBlank()
) {
return Optional.of(String.format("%s\n%s", fragestellung.getString(), empfehlung.getString()));
} else if (null != fragestellung && !fragestellung.getString().isBlank()) {
return Optional.of(fragestellung.getString());
} else if (null != empfehlung && !empfehlung.getString().isBlank()) {
return Optional.of(empfehlung.getString());
}
return Optional.empty();
}
}

View File

@ -0,0 +1,42 @@
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;
public class OsTumorkonferenzVarianteUkwToProtocolMapper implements ProcedureToProtocolMapper {
@Override
public Optional<String> apply(List<Procedure> procedures) {
procedures.forEach(procedure -> {
assert (procedure.getFormName().equals("OS.Tumorkonferenz.VarianteUKW"));
});
procedures.sort(Comparator.comparing(Procedure::getStartDate));
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("%s\n%s", fragestellung.getString(), empfehlung.getString());
} else if (null != fragestellung && !fragestellung.getString().isBlank()) {
return fragestellung.getString();
} else if (null != empfehlung && !empfehlung.getString().isBlank()) {
return empfehlung.getString();
}
return "";
}).collect(Collectors.joining("\n"));
if (!result.isBlank()) {
return Optional.of(result);
}
return Optional.empty();
}
}

View File

@ -0,0 +1,10 @@
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>> {}