blob: 78a94eb476652d6d69bb30c1ca5a2e7241a2871c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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("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);
}
return Optional.empty();
}
}
|