From fdb97646c8f17d0e9eb89295d77f4dc62c842435 Mon Sep 17 00:00:00 2001 From: deiflaender Date: Mon, 7 Nov 2022 13:09:43 +0100 Subject: [PATCH] RSS-171: Changed report to new SCM excel file requirements --- .../v1/server/service/RSSPoc2Service.java | 163 +++++++++++------- 1 file changed, 99 insertions(+), 64 deletions(-) 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 8962f9b..c555c64 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 @@ -65,6 +65,14 @@ public class RSSPoc2Service { guidelineMapping.put("Nº 442B: Skin Sensitization (27/06/2018)", Set.of("ÖECD 442B (2018)", "ÖECD No. 442B (2018)")); guidelineMapping.put("Nº 471: Bacterial Reverse Mutation Test (21/07/1997)", Set.of("OECD 471 (1997)", "OECD No. 471 (1997)")); guidelineMapping.put("Nº 471: Bacterial Reverse Mutation Test (26/06/2020)", Set.of("OECD 471 (2020)", "OECD No. 471 (2020)")); + + guidelineMapping.put("Nº 406: Skin Sensitisation (1992)", Set.of("OECD 406 (1992)", "OECD No. 406 (1992)")); + guidelineMapping.put("Nº 428: Split-Thickness Skin test (2004)", Set.of("OECD 428 (2004)", "OECD No. 428 (2004)")); + guidelineMapping.put("Nº 438: Eye Irritation (26/06/2018)", Set.of("OECD 438 (2018)", "OECD No. 438 (2018)")); + guidelineMapping.put("Nº 439: Skin Irritation (2019)", Set.of("OECD 439 (2019)", "OECD No. 439 (2019)")); + guidelineMapping.put("Nº 474: Micronucleus Bone Marrow Cells Rat (2016)", Set.of("OECD 474 (2016)", "OECD No. 474 (2016)")); + guidelineMapping.put("Nº 487: Micronucleus Human Lymphocytes (2016)", Set.of("OECD 487 (2016)", "OECD No. 487 (2016)")); + } @@ -87,100 +95,112 @@ public class RSSPoc2Service { redactionLog.getRedactionLogEntry().removeIf(r -> !r.isRedacted() || r.getChanges().get(r.getChanges().size() - 1).getType().equals(ChangeType.REMOVED)); - resultMap.put("TEST_GUIDELINE(S):_1", getTestGuideline1(redactionLog)); - + resultMap.put(oecd + "-Study_Title", getTitle(redactionLog)); + resultMap.put(oecd + "-Report_Number:", getReportNumber(redactionLog)); + resultMap.put(oecd + "-PERFORMING_LABORATORY:", getPerformingLaboratory(redactionLog)); + resultMap.put(oecd + "-Experimental_Starting_Date:", getExperimentalStartDate(redactionLog)); + resultMap.put(oecd + "-Experimental_Completion_Date:", getExperimentalEndDate(redactionLog)); + resultMap.put(oecd + "-GLP_Study", getGlpStudy(redactionLog)); + resultMap.put(oecd + "-Certificate_of_Analysis,_Batch_Identification", getBatchNumber(redactionLog)); + resultMap.put(oecd + "-TEST_GUIDELINE(S):_1", getTestGuideline1(redactionLog)); var testGuideline2 = getTestGuideline2(redactionLog); - resultMap.put("TEST_GUIDELINE(S):_2", testGuideline2 == null ? "" : testGuideline2); + resultMap.put(oecd + "-TEST_GUIDELINE(S):_2", testGuideline2 == null ? "" : testGuideline2); - resultMap.put("Report_Number:", getReportNumber(redactionLog)); - resultMap.put("Experimental_Starting_Date:", getExperimentalStartDate(redactionLog)); - resultMap.put("Experimental_Completion_Date:", getExperimentalEndDate(redactionLog)); - resultMap.put("Species", getSpecies(redactionLog)); - resultMap.put("Strain", getStrain(redactionLog)); + if (oecdIn(oecd, Set.of("402", "403", "404", "405", "425", "429", "436", "471"))) { - var macroscopicFindingSentences = getAsSentences(redactionLog, "macroscopic_findings"); - int i = 1; - for (String macroscopicFindingSentence : macroscopicFindingSentences) { - resultMap.put("Macroscopic_Findings_" + i, macroscopicFindingSentence); - i++; - } + resultMap.put(oecd + "-Study_Conclusion", getStudyConclusion(redactionLog)); - resultMap.put("Study_Title", getTitle(redactionLog)); - resultMap.put("GLP_Study", getGlpStudy(redactionLog)); - resultMap.put("Certificate_of_Analysis,_Batch_Identification", getBatchNumber(redactionLog)); - - var clinicalSignsSentences = getAsSentences(redactionLog, "clinical_signs"); - i = 1; - for (String clinicalSignsSentence : clinicalSignsSentences) { - resultMap.put("Clincal_Signs_" + i, clinicalSignsSentence); - i++; - } - - if (oecd != null && oecd.equals("425")) { - resultMap.put("Dosages", getDosages(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; + int i = 1; for (String guidelineDeviationSentence : guidelineDeviationSentences) { - resultMap.put("Deviation_from_the_Guideline_(Study_Plan)_" + i, guidelineDeviationSentence); + resultMap.put(oecd + "-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 (oecdIn(oecd, Set.of("402", "403", "404", "405", "425", "429", "436"))) { + + resultMap.put(oecd + "-Species", getSpecies(redactionLog)); + resultMap.put(oecd + "-Strain", getStrain(redactionLog)); } - if (oecd != null && oecd.equals("402")) { + if (oecdIn(oecd, Set.of("402", "403", "425", "436"))) { + resultMap.put(oecd + "-Conclusion_-_LD50_(mg/L)", getLd50Value(redactionLog)); + resultMap.put(oecd + "-Conclusion_-_Minimum_Confidence", getConfidenceMinimal(redactionLog)); + resultMap.put(oecd + "-Conclusion_-_Maximum_Confidence", getConfidenceMaximal(redactionLog)); + } + + if (oecdIn(oecd, Set.of("438", "439"))) { + resultMap.put(oecd + "-Results_and_Conclusions", getResultsAndConclusion(redactionLog)); + } + + if (oecdIn(oecd, Set.of("402"))) { var weightBehaviorChangesSentences = getAsSentences(redactionLog, "weight_behavior_changes"); - i = 1; + int i = 1; for (String sentence : weightBehaviorChangesSentences) { - resultMap.put("Body_weight_changes_" + i, sentence); + resultMap.put(oecd + "-Weight_Behavior_Change_" + i, sentence); i++; } } - if (oecd != null && oecd.equals("403")) { - resultMap.put("MMAD", getMmad(redactionLog)); - resultMap.put("GSD", getGsd(redactionLog)); + if (oecdIn(oecd, Set.of("403"))) { + resultMap.put(oecd + "-MMAD", getMmad(redactionLog)); + resultMap.put(oecd + "-GSD", getGsd(redactionLog)); var effectiveConcentrations = getEffectiveConcentrations(redactionLog); Iterator effectiveConcentrationsIterator = effectiveConcentrations.iterator(); - i = 1; + int i = 1; while (effectiveConcentrationsIterator.hasNext()) { String effectiveConcentration = effectiveConcentrationsIterator.next(); - resultMap.put("Effective_Concerntration_(mg/L_of_air)_" + i, effectiveConcentration); + resultMap.put(oecd + "-Effective_Concentration_(mg/L_of_air)_" + i, effectiveConcentration); i++; } } - if (oecd != null && (oecd.equals("438") || oecd.equals("439"))) { - resultMap.put("Results_and_Conclusions", getResultsAndConclusion(redactionLog)); + if (oecdIn(oecd, Set.of("404"))) { + resultMap.put(oecd + "-Dose_(ml/animal)", getDoseMlPerAnimal(redactionLog)); + resultMap.put(oecd + "-Was_there_dilution_of_the_test_substance?", getDilution(redactionLog)); + resultMap.put(oecd + "-Detailing_of_reported_changes", getAsOneBlock(redactionLog, "detailing")); } - if (oecd != null && oecd.equals("404")) { - resultMap.put("Dose_(ml/animal)", getDoseMlPerAnimal(redactionLog)); - resultMap.put("Was_there_dilution_of_the_test_substance?", getDilution(redactionLog)); + if (oecdIn(oecd, Set.of("405"))) { + var sentences = getAsSentences(redactionLog, "detailing"); + int i = 1; + for (String sentence : sentences) { + resultMap.put(oecd + "-Detailing_of_reported_changes_" + i, sentence); + i++; + } + } + + if (oecdIn(oecd, Set.of("425"))) { + + var clinicalSignsSentences = getAsSentences(redactionLog, "clinical_signs"); + int i = 1; + for (String clinicalSignsSentence : clinicalSignsSentences) { + resultMap.put(oecd + "-Clincal_Signs_" + i, clinicalSignsSentence); + i++; + } + + var mortalitySentences = getAsSentences(redactionLog, "mortality"); + i = 1; + for (String mortalitySentence : mortalitySentences) { + resultMap.put(oecd + "-Mortality_" + i, mortalitySentence); + i++; + } + + resultMap.put(oecd + "-Dosages", getDosages(redactionLog)); + } + + if (oecdIn(oecd, Set.of("429"))) { + var sentences = getAsSentences(redactionLog, "preliminary_test_results"); + int i = 1; + for (String sentence : sentences) { + resultMap.put(oecd + "-Preliminary_test_results" + i, sentence); + i++; + } + + resultMap.put(oecd + "-Test_results", getAsOneBlock(redactionLog, "test_results")); } rssFileResponses.add(new RSSFileResponse(file.getFilename(), resultMap)); @@ -192,6 +212,21 @@ public class RSSPoc2Service { } + private String getAsOneBlock(RedactionLog redactionLog, String type) { + + return redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).map(RedactionLogEntry::getValue).collect(Collectors.joining(" ")); + } + + + private boolean oecdIn(String oecd, Set oecdsToApply) { + + if (oecd != null && oecdsToApply.contains(oecd)) { + return true; + } + return false; + } + + private String getOecdNumber(FileModel file) { var fileAttributesConfig = fileAttributesClient.getFileAttributeConfigs(file.getDossierTemplateId());