RSS-225: Improved logic for dose mortality
This commit is contained in:
parent
9d33894b46
commit
b7399b4fb1
@ -160,7 +160,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put(DEVIATION_FROM_THE_GUIDELINE_SENTENCE + i, guidelineDeviationSentence);
|
||||
i++;
|
||||
}
|
||||
if(guidelineDeviationSentences.isEmpty()){
|
||||
if (guidelineDeviationSentences.isEmpty()) {
|
||||
resultMap.put(DEVIATION_FROM_THE_GUIDELINE_SENTENCE + 1, "");
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put(NECROPSY_FINDINGS_SENTENCE + i, sentence);
|
||||
i++;
|
||||
}
|
||||
if(sentences.isEmpty()){
|
||||
if (sentences.isEmpty()) {
|
||||
resultMap.put(NECROPSY_FINDINGS_SENTENCE + 1, "");
|
||||
}
|
||||
}
|
||||
@ -215,7 +215,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put(WEIGHT_BEHAVIOR_CHANGES_SENTENCE + i, sentence);
|
||||
i++;
|
||||
}
|
||||
if(weightBehaviorChangesSentences.isEmpty()){
|
||||
if (weightBehaviorChangesSentences.isEmpty()) {
|
||||
resultMap.put(WEIGHT_BEHAVIOR_CHANGES_SENTENCE + 1, "");
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put(CLINICAL_OBSERVATIONS_SENTENCE + i, sentence);
|
||||
i++;
|
||||
}
|
||||
if(sentences.isEmpty()){
|
||||
if (sentences.isEmpty()) {
|
||||
resultMap.put(CLINICAL_OBSERVATIONS_SENTENCE + 1, "");
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put(BODY_WEIGHT_CHANGES_SENTENCE + i, sentence);
|
||||
i++;
|
||||
}
|
||||
if(sentences.isEmpty()){
|
||||
if (sentences.isEmpty()) {
|
||||
resultMap.put(BODY_WEIGHT_CHANGES_SENTENCE + 1, "");
|
||||
}
|
||||
}
|
||||
@ -278,7 +278,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put(CLINCAL_SIGNS_SENTENCE + i, clinicalSignsSentence);
|
||||
i++;
|
||||
}
|
||||
if(clinicalSignsSentences.isEmpty()){
|
||||
if (clinicalSignsSentences.isEmpty()) {
|
||||
resultMap.put(CLINCAL_SIGNS_SENTENCE + 1, "");
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put(DOSE_MORTALITY_SENTENCE + i, sentence);
|
||||
i++;
|
||||
}
|
||||
if(doseMortalitySentences.isEmpty()){
|
||||
if (doseMortalitySentences.isEmpty()) {
|
||||
resultMap.put(DOSE_MORTALITY_SENTENCE + 1, "");
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put(PRELIMINARY_TEST_RESULTS_SENTENCE + i, sentence);
|
||||
i++;
|
||||
}
|
||||
if(sentences.isEmpty()){
|
||||
if (sentences.isEmpty()) {
|
||||
resultMap.put(PRELIMINARY_TEST_RESULTS_SENTENCE + 1, "");
|
||||
}
|
||||
|
||||
@ -471,16 +471,30 @@ public class RSSPoc2Service {
|
||||
private List<String> getDoseMortality(RedactionLog redactionLog) {
|
||||
|
||||
var doseMortalityEntries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dose_mortality")).collect(Collectors.toList());
|
||||
|
||||
Map<Integer, List<String>> perYValue = new HashMap<>();
|
||||
|
||||
for (var entry : doseMortalityEntries) {
|
||||
perYValue.computeIfAbsent(Math.round(entry.getPositions().get(0).getTopLeft().getY()), (x) -> new ArrayList<>()).add(entry.getValue());
|
||||
}
|
||||
var doseMortalityDoseEntries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dose_mortality_dose")).collect(Collectors.toList());
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Map.Entry<Integer, List<String>> entry : perYValue.entrySet()) {
|
||||
result.add(entry.getValue().stream().collect(Collectors.joining(", ")));
|
||||
for (var mortality : doseMortalityEntries) {
|
||||
|
||||
RedactionLogEntry doseWithSmallestDistance = null;
|
||||
for (var dose : doseMortalityDoseEntries) {
|
||||
if (Math.round(mortality.getPositions().get(0).getTopLeft().getY()) == Math.round(dose.getPositions().get(0).getTopLeft().getY())) {
|
||||
doseWithSmallestDistance = dose;
|
||||
break;
|
||||
}
|
||||
if (doseWithSmallestDistance == null) {
|
||||
doseWithSmallestDistance = dose;
|
||||
} else if(Math.abs(Math.round(mortality.getPositions().get(0).getTopLeft().getY()) - Math.round(dose.getPositions().get(0).getTopLeft().getY())) < Math.abs(Math.round(mortality.getPositions().get(0).getTopLeft().getY()) - Math.round(doseWithSmallestDistance.getPositions().get(0).getTopLeft().getY()))){
|
||||
doseWithSmallestDistance = dose;
|
||||
}
|
||||
}
|
||||
|
||||
if(doseWithSmallestDistance != null){
|
||||
result.add(doseWithSmallestDistance.getValue() + ", " + mortality.getValue());
|
||||
} else {
|
||||
result.add(", " + mortality.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -839,9 +853,9 @@ public class RSSPoc2Service {
|
||||
var guidelineNumber = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("oecd_guideline_number")).map(RedactionLogEntry::getValue).findFirst();
|
||||
var guidelineYear = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("oecd_guideline_year")).map(RedactionLogEntry::getValue).findFirst();
|
||||
|
||||
if(guidelineNumber.isPresent() && guidelineYear.isPresent()){
|
||||
if (guidelineNumber.isPresent() && guidelineYear.isPresent()) {
|
||||
var guidelinePair = Pair.of(guidelineNumber.get(), guidelineYear.get());
|
||||
if(guidelineMapping.containsKey(guidelinePair)){
|
||||
if (guidelineMapping.containsKey(guidelinePair)) {
|
||||
return guidelineMapping.get(guidelinePair);
|
||||
}
|
||||
}
|
||||
@ -879,7 +893,6 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void sortRedactionLog(RedactionLog redactionLog) {
|
||||
|
||||
redactionLog.getRedactionLogEntry().sort((entry1, entry2) -> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user