diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/RSSPoc2Service.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/RSSPoc2Service.java index 7ab1b50..c6b9212 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/RSSPoc2Service.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/RSSPoc2Service.java @@ -170,7 +170,7 @@ public class RSSPoc2Service { if (oecdIn(oecd, Set.of("402", "403", "404", "405", "425", "429", "436", "471"))) { - resultMap.put(STUDY_CONCLUSION, getFirstEntryOrElse(redactionLog, "study_conclusion", "")); + resultMap.put(STUDY_CONCLUSION, combineValuesOfFirstFoundSection(redactionLog, "study_conclusion", " ", "")); var guidelineDeviationSentences = getAsSentences(redactionLog, "guideline_deviation"); int i = 1; @@ -363,6 +363,28 @@ public class RSSPoc2Service { } + private SCMComponent combineValuesOfFirstFoundSection(RedactionLog redactionLog, String type, String seperator, String elseValue){ + + String transformation = String.format("Combine paragraphs of '%s' with seperator '%s' in first Section found", type, seperator); + + var entries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).toList(); + + if(entries.isEmpty()){ + return SCMComponent.builder().originalValue(elseValue).transformation(transformation).build(); + } + + int firstSectionNr = entries.get(0).getSectionNumber(); + + String value = entries.stream().filter(e -> e.getSectionNumber() == firstSectionNr).map(RedactionLogEntry::getValue).collect(Collectors.joining(seperator)).trim(); + + return SCMComponent.builder() + .originalValue(value) + .scmAnnotations(entries.stream().map(this::toScmAnnotations).collect(Collectors.toList())) + .transformation(transformation) + .build(); + } + + private SCMComponent getFirstEntryOrElse(RedactionLog redactionLog, String type, String elseValue) { String transformation = String.format("First found value of type '%s' or else '%s'", type, elseValue);