RSS-171: Fixed report findings and added finished components
This commit is contained in:
parent
72f9767c2f
commit
b2645a4b44
@ -4,7 +4,6 @@ import java.text.BreakIterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -20,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.rss.RSSFileResponse;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.rss.RSSResponse;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.RedactionLogClient;
|
||||
import com.iqser.red.service.redaction.v1.model.ChangeType;
|
||||
@ -36,6 +36,7 @@ public class RSSPoc2Service {
|
||||
private final FileStatusClient statusClient;
|
||||
|
||||
private final Map<String, Set<String>> guidelineMapping = new HashMap<>();
|
||||
private final FileAttributesConfigClient fileAttributesClient;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
@ -78,6 +79,9 @@ public class RSSPoc2Service {
|
||||
|
||||
List<RSSFileResponse> rssFileResponses = new ArrayList<>();
|
||||
for (FileModel file : files) {
|
||||
|
||||
String oecd = getOecdNumber(file);
|
||||
|
||||
Map<String, String> resultMap = new TreeMap<>();
|
||||
var redactionLog = redactionLogClient.getRedactionLog(dossierId, file.getId(), new ArrayList<>(), true, false);
|
||||
|
||||
@ -86,9 +90,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put("TEST_GUIDELINE(S):_1", getTestGuideline1(redactionLog));
|
||||
|
||||
var testGuideline2 = getTestGuideline2(redactionLog);
|
||||
if (testGuideline2 != null) {
|
||||
resultMap.put("TEST_GUIDELINE(S):_2", testGuideline2);
|
||||
}
|
||||
resultMap.put("TEST_GUIDELINE(S):_2", testGuideline2 == null ? "" : testGuideline2);
|
||||
|
||||
resultMap.put("Report_Number:", getReportNumber(redactionLog));
|
||||
resultMap.put("Experimental_Starting_Date:", getExperimentalStartDate(redactionLog));
|
||||
@ -96,7 +98,7 @@ public class RSSPoc2Service {
|
||||
resultMap.put("Species", getSpecies(redactionLog));
|
||||
resultMap.put("Strain", getStrain(redactionLog));
|
||||
|
||||
var macroscopicFindingSentences = getMacroscopicFindings(redactionLog);
|
||||
var macroscopicFindingSentences = getAsSentences(redactionLog, "macroscopic_findings");
|
||||
int i = 1;
|
||||
for (String macroscopicFindingSentence : macroscopicFindingSentences) {
|
||||
resultMap.put("Macroscopic_Findings_" + i, macroscopicFindingSentence);
|
||||
@ -107,22 +109,80 @@ public class RSSPoc2Service {
|
||||
resultMap.put("GLP_Study", getGlpStudy(redactionLog));
|
||||
resultMap.put("Certificate_of_Analysis,_Batch_Identification", getBatchNumber(redactionLog));
|
||||
|
||||
var clinicalSignsSentences = getClinicalSigns(redactionLog);
|
||||
var clinicalSignsSentences = getAsSentences(redactionLog, "clinical_signs");
|
||||
i = 1;
|
||||
for (String clinicalSignsSentence : clinicalSignsSentences) {
|
||||
resultMap.put("Clincal_Signs_" + i, clinicalSignsSentence);
|
||||
i++;
|
||||
}
|
||||
|
||||
resultMap.put("Dosages", getDosages(redactionLog));
|
||||
if (oecd != null && oecd.equals("425")) {
|
||||
resultMap.put("Dosages", getDosages(redactionLog));
|
||||
}
|
||||
|
||||
var mortalitySentences = getMortality(redactionLog);
|
||||
var mortalitySentences = getAsSentences(redactionLog, "mortality");
|
||||
i = 1;
|
||||
for (String mortalitySentence : mortalitySentences) {
|
||||
resultMap.put("Mortality_" + i, mortalitySentence);
|
||||
i++;
|
||||
}
|
||||
|
||||
resultMap.put("PERFORMING_LABORATORY:", getPerformingLaboratory(redactionLog));
|
||||
|
||||
if (oecd != null && (oecd.equals("402") || oecd.equals("403") || oecd.equals("425"))) {
|
||||
resultMap.put("Conclusion_-_LD50_(mg/L)", getLd50Value(redactionLog));
|
||||
resultMap.put("Conclusion_-_Minimum_Confidence", getConfidenceMinimal(redactionLog));
|
||||
resultMap.put("Conclusion_-_Maximum_Confidence", getConfidenceMaximal(redactionLog));
|
||||
}
|
||||
|
||||
if (oecd != null && (oecd.equals("402") || oecd.equals("403") || oecd.equals("404") || oecd.equals("405") || oecd.equals("425") || oecd.equals("429") || oecd.equals(
|
||||
"471"))) {
|
||||
var guidelineDeviationSentences = getAsSentences(redactionLog, "guideline_deviation");
|
||||
i = 1;
|
||||
for (String guidelineDeviationSentence : guidelineDeviationSentences) {
|
||||
resultMap.put("Deviation_from_the_Guideline_(Study_Plan)_" + i, guidelineDeviationSentence);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (oecd != null && (oecd.equals("402") || oecd.equals("403") || oecd.equals("404") || oecd.equals("405") || oecd.equals("425") || oecd.equals("429") || oecd.equals(
|
||||
"471"))) {
|
||||
resultMap.put("Study_Conclusion", getStudyConclusion(redactionLog));
|
||||
}
|
||||
|
||||
if (oecd != null && oecd.equals("402")) {
|
||||
var weightBehaviorChangesSentences = getAsSentences(redactionLog, "weight_behavior_changes");
|
||||
i = 1;
|
||||
for (String sentence : weightBehaviorChangesSentences) {
|
||||
resultMap.put("Body_weight_changes_" + i, sentence);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (oecd != null && oecd.equals("403")) {
|
||||
resultMap.put("MMAD", getMmad(redactionLog));
|
||||
resultMap.put("GSD", getGsd(redactionLog));
|
||||
|
||||
var effectiveConcentrations = getEffectiveConcentrations(redactionLog);
|
||||
Iterator<String> effectiveConcentrationsIterator = effectiveConcentrations.iterator();
|
||||
i = 1;
|
||||
while (effectiveConcentrationsIterator.hasNext()) {
|
||||
String effectiveConcentration = effectiveConcentrationsIterator.next();
|
||||
resultMap.put("Effective_Concerntration_(mg/L_of_air)_" + i, effectiveConcentration);
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (oecd != null && (oecd.equals("438") || oecd.equals("439"))) {
|
||||
resultMap.put("Results_and_Conclusions", getResultsAndConclusion(redactionLog));
|
||||
}
|
||||
|
||||
if (oecd != null && oecd.equals("404")) {
|
||||
resultMap.put("Dose_(ml/animal)", getDoseMlPerAnimal(redactionLog));
|
||||
resultMap.put("Was_there_dilution_of_the_test_substance?", getDilution(redactionLog));
|
||||
}
|
||||
|
||||
rssFileResponses.add(new RSSFileResponse(file.getFilename(), resultMap));
|
||||
}
|
||||
|
||||
@ -132,6 +192,200 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private String getOecdNumber(FileModel file) {
|
||||
|
||||
var fileAttributesConfig = fileAttributesClient.getFileAttributeConfigs(file.getDossierTemplateId());
|
||||
var oecdFileAttributeConf = fileAttributesConfig.stream().filter(f -> f.getLabel().equals("OECD Number")).map(f -> f.getId()).findFirst();
|
||||
if (oecdFileAttributeConf.isPresent()) {
|
||||
return file.getFileAttributes().get(oecdFileAttributeConf.get());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private String getDilution(RedactionLog redactionLog) {
|
||||
|
||||
var dilution = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dilution")).map(RedactionLogEntry::getValue).findFirst();
|
||||
|
||||
if (dilution.isPresent()) {
|
||||
return "Yes";
|
||||
}
|
||||
return "No";
|
||||
}
|
||||
|
||||
|
||||
private String getDoseMlPerAnimal(RedactionLog redactionLog) {
|
||||
|
||||
var doseMlPerAnimal = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dose_(ml_per_animal)")).map(RedactionLogEntry::getValue).findFirst();
|
||||
|
||||
return doseMlPerAnimal.orElse("");
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
Iterator<String> itty = uniqueGsd.iterator();
|
||||
while (itty.hasNext()) {
|
||||
stringBuilder.append(itty.next());
|
||||
if (itty.hasNext()) {
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString().trim();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String getMmad(RedactionLog redactionLog) {
|
||||
|
||||
var uniqueMmad = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("mmad")).map(RedactionLogEntry::getValue).collect(Collectors.toSet());
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
Iterator<String> itty = uniqueMmad.iterator();
|
||||
while (itty.hasNext()) {
|
||||
stringBuilder.append(itty.next());
|
||||
if (itty.hasNext()) {
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString().trim();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private String getStudyConclusion(RedactionLog redactionLog) {
|
||||
|
||||
var studyConclusion = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("study_conclusion")).map(RedactionLogEntry::getValue).findFirst();
|
||||
|
||||
return studyConclusion.orElse("");
|
||||
}
|
||||
|
||||
|
||||
private List<String> getAsSentences(RedactionLog redactionLog, String type) {
|
||||
|
||||
List<String> sentences = new ArrayList<>();
|
||||
var typeStrings = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).map(RedactionLogEntry::getValue).collect(Collectors.toList());
|
||||
|
||||
if (typeStrings.isEmpty()) {
|
||||
return sentences;
|
||||
}
|
||||
|
||||
for (String typeString : typeStrings) {
|
||||
|
||||
BreakIterator iterator = BreakIterator.getSentenceInstance(Locale.US);
|
||||
iterator.setText(typeString);
|
||||
int start = iterator.first();
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
||||
sentences.add(typeString.substring(start, end).replaceAll("\\n", "").trim());
|
||||
}
|
||||
}
|
||||
|
||||
return sentences;
|
||||
}
|
||||
|
||||
|
||||
private String getConfidenceMinimal(RedactionLog redactionLog) {
|
||||
|
||||
var uniqueConfidenceMinimal = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals("confidence_minimal"))
|
||||
.map(RedactionLogEntry::getValue)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
Iterator<String> itty = uniqueConfidenceMinimal.iterator();
|
||||
while (itty.hasNext()) {
|
||||
stringBuilder.append(itty.next());
|
||||
if (itty.hasNext()) {
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
private String getConfidenceMaximal(RedactionLog redactionLog) {
|
||||
|
||||
var uniqueConfidenceMaximal = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals("confidence_maximal"))
|
||||
.map(RedactionLogEntry::getValue)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
Iterator<String> itty = uniqueConfidenceMaximal.iterator();
|
||||
while (itty.hasNext()) {
|
||||
stringBuilder.append(itty.next());
|
||||
if (itty.hasNext()) {
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
private String getLd50Value(RedactionLog redactionLog) {
|
||||
|
||||
var uniqueLd50 = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("ld50_value")).map(RedactionLogEntry::getValue).collect(Collectors.toSet());
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
Iterator<String> itty = uniqueLd50.iterator();
|
||||
while (itty.hasNext()) {
|
||||
stringBuilder.append(itty.next());
|
||||
if (itty.hasNext()) {
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
private String getPerformingLaboratory(RedactionLog redactionLog) {
|
||||
|
||||
var laboratoryName = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("laboratory_name")).map(RedactionLogEntry::getValue).findFirst();
|
||||
var laboratoryCountry = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("laboratory_country")).map(RedactionLogEntry::getValue).findFirst();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (laboratoryName.isPresent()) {
|
||||
sb.append(laboratoryName.get());
|
||||
}
|
||||
if (laboratoryCountry.isPresent()) {
|
||||
sb.append(", ").append(laboratoryCountry.get());
|
||||
}
|
||||
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
|
||||
private String getDosages(RedactionLog redactionLog) {
|
||||
|
||||
var dosages = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("dosages")).map(RedactionLogEntry::getValue).findFirst();
|
||||
@ -140,58 +394,6 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private List<String> getMortality(RedactionLog redactionLog) {
|
||||
|
||||
List<String> mortality = new ArrayList<>();
|
||||
var mortalityString = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals("mortality"))
|
||||
.map(RedactionLogEntry::getValue)
|
||||
.findFirst();
|
||||
|
||||
if (!mortalityString.isPresent()) {
|
||||
return mortality;
|
||||
}
|
||||
|
||||
String source = mortalityString.get();
|
||||
BreakIterator iterator = BreakIterator.getSentenceInstance(Locale.US);
|
||||
iterator.setText(source);
|
||||
int start = iterator.first();
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
||||
mortality.add(source.substring(start, end));
|
||||
}
|
||||
|
||||
return mortality;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<String> getClinicalSigns(RedactionLog redactionLog) {
|
||||
|
||||
List<String> clinicalSigns = new ArrayList<>();
|
||||
var clinicalSignsString = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals("clinical_signs"))
|
||||
.map(RedactionLogEntry::getValue)
|
||||
.findFirst();
|
||||
|
||||
if (!clinicalSignsString.isPresent()) {
|
||||
return clinicalSigns;
|
||||
}
|
||||
|
||||
String source = clinicalSignsString.get();
|
||||
BreakIterator iterator = BreakIterator.getSentenceInstance(Locale.US);
|
||||
iterator.setText(source);
|
||||
int start = iterator.first();
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
||||
clinicalSigns.add(source.substring(start, end));
|
||||
}
|
||||
|
||||
return clinicalSigns;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String getBatchNumber(RedactionLog redactionLog) {
|
||||
|
||||
var batchNumber = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("batch_number")).map(RedactionLogEntry::getValue).findFirst();
|
||||
@ -220,31 +422,6 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private List<String> getMacroscopicFindings(RedactionLog redactionLog) {
|
||||
|
||||
List<String> macroscopicFindings = new ArrayList<>();
|
||||
var macroscopicFindingString = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getType().equals("macroscopic_findings"))
|
||||
.map(RedactionLogEntry::getValue)
|
||||
.findFirst();
|
||||
|
||||
if (!macroscopicFindingString.isPresent()) {
|
||||
return macroscopicFindings;
|
||||
}
|
||||
|
||||
String source = macroscopicFindingString.get();
|
||||
BreakIterator iterator = BreakIterator.getSentenceInstance(Locale.US);
|
||||
iterator.setText(source);
|
||||
int start = iterator.first();
|
||||
for (int end = iterator.next(); end != BreakIterator.DONE; start = end, end = iterator.next()) {
|
||||
macroscopicFindings.add(source.substring(start, end));
|
||||
}
|
||||
|
||||
return macroscopicFindings;
|
||||
}
|
||||
|
||||
|
||||
private String getStrain(RedactionLog redactionLog) {
|
||||
|
||||
var strain = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("strain")).map(RedactionLogEntry::getValue).findFirst();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user