mirror of
https://github.com/pcvolkmer/onkostar-plugin-dnpm.git
synced 2025-07-02 01:02:55 +00:00
Standardmethode zum Ermitteln und Anwenden des Protokollmappers hinzugefügt
This commit is contained in:
@ -7,6 +7,7 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Standardimplementierung des MtbService
|
||||
@ -32,14 +33,17 @@ public class DefaultMtbService implements MtbService {
|
||||
*/
|
||||
@Override
|
||||
public String getProtocol(List<Procedure> procedures) {
|
||||
return procedures.stream()
|
||||
return this.sortedDistinctProcedureProtocolList(procedures.stream())
|
||||
.collect(Collectors.joining("\n\n"));
|
||||
}
|
||||
|
||||
private Stream<String> sortedDistinctProcedureProtocolList(Stream<Procedure> procedures) {
|
||||
return procedures
|
||||
.sorted(Comparator.comparing(Procedure::getStartDate))
|
||||
.map(procedure -> this.procedureToProtocolMapper(procedure).apply(procedure))
|
||||
.map(this::selectAndApplyMapper)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.distinct()
|
||||
.collect(Collectors.joining("\n\n"));
|
||||
|
||||
.distinct();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,6 +3,7 @@ package DNPM.services.mtb;
|
||||
import de.itc.onkostar.api.Procedure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface MtbService {
|
||||
/**
|
||||
@ -18,4 +19,13 @@ public interface MtbService {
|
||||
* @return Mapper für diese Prozedur
|
||||
*/
|
||||
ProcedureToProtocolMapper procedureToProtocolMapper(Procedure procedure);
|
||||
|
||||
/**
|
||||
* Select mapper using method {@link #procedureToProtocolMapper(Procedure)} and apply procedure
|
||||
* @param procedure The Procedure to select mapper for and apply
|
||||
* @return {@link Optional} with protocol or empty {@link Optional}
|
||||
*/
|
||||
default Optional<String> selectAndApplyMapper(Procedure procedure) {
|
||||
return this.procedureToProtocolMapper(procedure).apply(procedure);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user