Pull request #191: RSS-207: Added more compontent, fixed issues for SCM Report
Merge in RED/redaction-report-service from RSS-207 to master * commit '5f8fbf6794b30b229a7bb3ca9acdc01d244e0718': RSS-207: Added more compontent, fixed issues for SCM Report
This commit is contained in:
commit
2cfcd3789a
@ -93,6 +93,8 @@ public class RSSPoc2Service {
|
||||
Map<String, String> resultMap = new TreeMap<>();
|
||||
var redactionLog = redactionLogClient.getRedactionLog(dossierId, file.getId(), new ArrayList<>(), true, false);
|
||||
|
||||
sortRedactionLog(redactionLog);
|
||||
|
||||
redactionLog.getRedactionLogEntry().removeIf(r -> !r.isRedacted() || r.getChanges().get(r.getChanges().size() - 1).getType().equals(ChangeType.REMOVED));
|
||||
|
||||
resultMap.put("Study_Type_Number", oecd);
|
||||
@ -133,7 +135,6 @@ public class RSSPoc2Service {
|
||||
resultMap.put("Conclusion_Maximum_Confidence", getConfidenceMaximal(redactionLog));
|
||||
}
|
||||
|
||||
|
||||
if (oecdIn(oecd, Set.of("402", "403", "436"))) {
|
||||
resultMap.put("Necropsy_findings", getLongestBlock(redactionLog, "necropsy_findings"));
|
||||
}
|
||||
@ -142,13 +143,12 @@ public class RSSPoc2Service {
|
||||
resultMap.put("Conducted_with_4_hours_of_Exposure", getAsOneBlock(redactionLog, "4h_exposure"));
|
||||
}
|
||||
|
||||
|
||||
if (oecdIn(oecd, Set.of("406", "428", "438", "439", "471", "474", "487"))) {
|
||||
resultMap.put("Study_Design", getAsOneBlock(redactionLog, "study_design"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("406", "428", "438", "439", "474", "487"))) {
|
||||
resultMap.put("Results_and_Conclusions", getResultsAndConclusion(redactionLog));
|
||||
resultMap.put("Results_and_Conclusions", getJoinedValues(redactionLog, "results_and_conclusion", " "));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("402"))) {
|
||||
@ -193,16 +193,15 @@ public class RSSPoc2Service {
|
||||
if (oecdIn(oecd, Set.of("404"))) {
|
||||
resultMap.put("Dose_ml_per_animal", getDoseMlPerAnimal(redactionLog));
|
||||
// resultMap.put("Was_there_dilution_of_the_test_substance?", getDilution(redactionLog)); // Out of scope.
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("404", "405"))) {
|
||||
resultMap.put("Detailing_of_reported_changes", getAsOneBlock(redactionLog, "detailing"));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("405"))) {
|
||||
var sentences = getAsSentences(redactionLog, "detailing");
|
||||
int i = 1;
|
||||
for (String sentence : sentences) {
|
||||
resultMap.put("Detailing_of_reported_changes_" + i, sentence);
|
||||
i++;
|
||||
}
|
||||
if (oecdIn(oecd, Set.of("405", "429"))) {
|
||||
resultMap.put("Sex", getJoinedUniqueValues(redactionLog, "sex", ", "));
|
||||
resultMap.put("Number_of_Animals", getNumberOfAnimals(redactionLog));
|
||||
}
|
||||
|
||||
if (oecdIn(oecd, Set.of("425"))) {
|
||||
@ -245,6 +244,25 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private String getJoinedValues(RedactionLog redactionLog, String type, String seperator) {
|
||||
|
||||
return redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).map(RedactionLogEntry::getValue).collect(Collectors.joining(seperator)).trim();
|
||||
}
|
||||
|
||||
|
||||
private String getJoinedUniqueValues(RedactionLog redactionLog, String type, String seperator) {
|
||||
|
||||
return redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals(type))
|
||||
.map(RedactionLogEntry::getValue)
|
||||
.collect(Collectors.toSet())
|
||||
.stream()
|
||||
.collect(Collectors.joining(seperator))
|
||||
.trim();
|
||||
}
|
||||
|
||||
|
||||
private String getLongestBlock(RedactionLog redactionLog, String type) {
|
||||
|
||||
return redactionLog.getRedactionLogEntry()
|
||||
@ -282,7 +300,6 @@ public class RSSPoc2Service {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// private String getDilution(RedactionLog redactionLog) {
|
||||
//
|
||||
// var dilution = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dilution")).map(RedactionLogEntry::getValue).findFirst();
|
||||
@ -294,6 +311,28 @@ public class RSSPoc2Service {
|
||||
// }
|
||||
|
||||
|
||||
private String getNumberOfAnimals(RedactionLog redactionLog) {
|
||||
|
||||
var numberOfAnimals = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("number_of_animals")).map(RedactionLogEntry::getValue).findFirst();
|
||||
|
||||
if (numberOfAnimals.isPresent()) {
|
||||
return numberOfAnimals.get();
|
||||
}
|
||||
|
||||
var uniqueAnimalNumbers = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals("animal_number"))
|
||||
.map(RedactionLogEntry::getValue)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (uniqueAnimalNumbers.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return String.valueOf(uniqueAnimalNumbers.size());
|
||||
}
|
||||
|
||||
|
||||
private String getDoseMlPerAnimal(RedactionLog redactionLog) {
|
||||
|
||||
var doseMlPerAnimal = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dose_(ml_per_animal)")).map(RedactionLogEntry::getValue).findFirst();
|
||||
@ -302,32 +341,11 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private String getResultsAndConclusion(RedactionLog redactionLog) {
|
||||
|
||||
var resultsAndConclusion = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals("results_and_conclusion"))
|
||||
.map(RedactionLogEntry::getValue)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
Iterator<String> itty = resultsAndConclusion.iterator();
|
||||
while (itty.hasNext()) {
|
||||
stringBuilder.append(itty.next());
|
||||
if (itty.hasNext()) {
|
||||
stringBuilder.append(". ");
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
private Set<String> getEffectiveConcentrations(RedactionLog redactionLog) {
|
||||
|
||||
return redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("effective_concentration")).map(RedactionLogEntry::getValue).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
// private String getGsd(RedactionLog redactionLog) {
|
||||
//
|
||||
// var uniqueGsd = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("gsd")).map(RedactionLogEntry::getValue).collect(Collectors.toSet());
|
||||
@ -344,7 +362,6 @@ public class RSSPoc2Service {
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// private String getMmad(RedactionLog redactionLog) {
|
||||
//
|
||||
// var uniqueMmad = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("mmad")).map(RedactionLogEntry::getValue).collect(Collectors.toSet());
|
||||
@ -612,4 +629,19 @@ public class RSSPoc2Service {
|
||||
return "No mapping found for: " + guideline;
|
||||
}
|
||||
|
||||
|
||||
private void sortRedactionLog(RedactionLog redactionLog) {
|
||||
|
||||
redactionLog.getRedactionLogEntry().sort((entry1, entry2) -> {
|
||||
if (entry1.getPositions().get(0).getPage() == entry2.getPositions().get(0).getPage()) {
|
||||
if (entry1.getPositions().get(0).getTopLeft().getY() == entry2.getPositions().get(0).getTopLeft().getY()) {
|
||||
return entry1.getPositions().get(0).getTopLeft().getX() < entry2.getPositions().get(0).getTopLeft().getX() ? -1 : 1;
|
||||
} else {
|
||||
return entry1.getPositions().get(0).getTopLeft().getY() < entry2.getPositions().get(0).getTopLeft().getY() ? 1 : -1;
|
||||
}
|
||||
}
|
||||
return entry1.getPositions().get(0).getPage() < entry2.getPositions().get(0).getPage() ? -1 : 1;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user