Commit 24574a92 authored by javi's avatar javi
Browse files

export changes and curations features

parent 447c7c35
Pipeline #22662 passed with stage
in 4 minutes and 42 seconds
......@@ -56,21 +56,14 @@ public class DocumentController {
return "";
}
@RequestMapping("/documents/{id}/acceptFinding/{findingId}")
public String acceptFinding(@PathVariable(value="id") Long id, @PathVariable(value="findingId") Integer findingId) {
documentService.acceptFinding(id, findingId);
return "true";
}
@RequestMapping("/documents/{id}/rejectFinding/{findingId}")
public String rejectFinding(@PathVariable(value="id") Long id, @PathVariable(value="findingId") Integer findingId) {
documentService.rejectFinding(id, findingId);
@RequestMapping("/documents/{id}/exportFinding/{findingId}/{export_finding}")
public String setExportFinding(@PathVariable(value="id") Long id, @PathVariable(value="findingId") Integer findingId, @PathVariable(value="export_finding") String export_finding) {
documentService.setExportFinding(id, findingId, export_finding);
return "true";
}
@RequestMapping("/documents/{id}/exportFinding/{findingId}/{export_finding}")
public String setExportFinding(@PathVariable(value="id") Long id, @PathVariable(value="findingId") Integer findingId, @PathVariable(value="export_finding") String export_finding) {
@RequestMapping("/documents/{id}/findingValidation/{findingId}/{status}")
public String setFindingValidation(@PathVariable(value="id") Long id, @PathVariable(value="findingId") Integer findingId, @PathVariable(value="export_finding") String export_finding) {
documentService.setExportFinding(id, findingId, export_finding);
return "true";
}
......
......@@ -28,9 +28,7 @@ public interface DocumentService {
String findFindingsEvidenceByDocumentId(Long id);
Boolean acceptFinding(Long id, Integer findingId);
Boolean rejectFinding(Long id, Integer findingId);
Boolean setExportFinding(Long id, Integer findingId, String export_finding);
Boolean setFindingValidation(Long id, Integer findingId,String status);
}
......@@ -123,30 +123,8 @@ public class DocumentServiceImpl implements DocumentService {
return "";
}
@Override
public Boolean acceptFinding(Long id, Integer findingId) {
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Finding findingSelected = null;
for (Annotation annotation : documentAnnotations.getRelevantSentences()) {
for (Finding finding : annotation.getFindings()) {
if(finding.getFindingId().equals(findingId)) {
findingSelected = finding;
break;
}
}
}
if(findingSelected!=null) {
findingSelected.setStatus("accepted");
documentAnnotationsRepository.save(documentAnnotations);
return true;
}
return false;
}
@Override
public Boolean rejectFinding(Long id, Integer findingId) {
public Boolean setFindingValidation(Long id, Integer findingId,String status) {
DocumentAnnotations documentAnnotations = this.findDocumentAnnotationsByDocumentId(id);
Finding findingSelected = null;
for (Annotation annotation : documentAnnotations.getRelevantSentences()) {
......@@ -159,7 +137,7 @@ public class DocumentServiceImpl implements DocumentService {
}
if(findingSelected!=null) {
//https://stackoverflow.com/questions/47699646/updating-replacing-a-deeply-nested-object-in-mongodb-with-spring-data-mongodb
findingSelected.setStatus("rejected");
findingSelected.setStatus(status);
documentAnnotationsRepository.save(documentAnnotations);
return true;
}
......@@ -288,127 +266,84 @@ public class DocumentServiceImpl implements DocumentService {
retStr.append("STUDYID|DOMAIN|SRSEQ|SRRISK|SPGRPCD|GRPLBL|SRGRPDOS|SRSEX|SRSTDY|SRSTPHSE|SROBSTDY|SRENDY|SRENPHSE|SROBENDY|SRDOMAIN|SRSPEC|SRTSTCD|SRFNDG|SRORES|SROBSV|SROBSQ|SRSEV|SRPCNT|SRSIGF|SRTRTEF|SRCOMNT");
retStr.append(System.getProperty("line.separator"));
for (Finding finding : documentAnnotations.getFindings()) {
//STUDYID -- > Study Identifier
retStr.append(id);
retStr.append("|");
//DOMAIN -- > Domain Abbreviation, always SR
retStr.append("SR");
retStr.append("|");
//SRSEQ -- > Sequence number
retStr.append("");
retStr.append("|");
//SRRISK --> Effect Level Associated with a Group/Sex, NOEL, LOEL, NOAEL, LOAEL, HNSTD, STD, MTD
retStr.append(finding.getRisk_level()==null?"":finding.getRisk_level().getValue());
retStr.append("|");
//SPGRPCD --> Sponsor-defined Group Code, group 1 , A
retStr.append(finding.getGroup()==null?"":finding.getGroup().getValue());
retStr.append("|");
//GRPLBL --> Sponsor-defined Group Name, "low dose", "mid dose"
retStr.append(finding.getGroup()==null?"":finding.getGroup().getValue());
retStr.append("|");
//SRGRPDOS --> Group Dose Level, "20 mg/kg"
retStr.append(finding.getGroup()==null?"":finding.getGroup().getValue());
retStr.append("|");
//SRSEX -- > Sex
retStr.append(finding.getSex()==null?"":finding.getSex().getValue());
retStr.append("|");
//SRSTDY --> Study Day of Start of Finding
retStr.append("");
retStr.append("|");
//SRSTPHSE --> Study Phase of first Observation, “PRE-DOSING”, “DOSING”, “RECOVERY”
retStr.append("");
retStr.append("|");
//SROBSTDY --> Start Phase Day of Observation
retStr.append("");
retStr.append("|");
//SRENPHSE -->Study Phase of last Observation
retStr.append("");
retStr.append("|");
//SRDOMAIN --> Domain of Finding
retStr.append(finding.getStudy_domain()==null?"":finding.getStudy_domain().getValue());
retStr.append("|");
//SRSPEC --> Specimen of Finding
retStr.append(finding.getSpecimen()==null?"":finding.getSpecimen().getValue());
retStr.append("|");
//SRTSTCD --> Test Short Name
retStr.append(finding.getStudy_testcd()==null?"":finding.getStudy_testcd().getValue());
retStr.append("|");
//SRFNDG --> Finding
retStr.append(finding.getFinding()==null?"":finding.getFinding().getValue());
retStr.append("|");
//SRORES --> Observation (original result)
retStr.append(finding.getFinding()==null?"":finding.getFinding().getValue());
retStr.append("|");
//SROBSV --> Manifestation of Finding, “I” (Increase), “D” (Decrease), “P” (Present) or “A” (Absent)
retStr.append(finding.getManifestation_finding()==null?"":finding.getManifestation_finding().getValue());
retStr.append("|");
//SROBSQ --> Observation Qualifier, “R” (Reversible), “T” (Transient) or ‘none’
retStr.append(finding.getObservation_qualification()==null?"":finding.getObservation_qualification().getValue());
retStr.append("|");
//SRSEV --> Severity of Finding
retStr.append("");
retStr.append("|");
//SRPCNT --> Scale of this Finding
retStr.append("");
retStr.append("|");
//SRSIGF --> Statistical Significance
retStr.append(finding.getStatistical_significance()==null?"":finding.getStatistical_significance().getValue());
retStr.append("|");
//SRTRTEF --> Treatment-Related
retStr.append(finding.getIs_treatment_related()==null?"":finding.getIs_treatment_related().getValue());
retStr.append("|");
//SRCOMNT --> Comment
retStr.append("\n");
for (SRDomainFinding srDomainFinding : finding.getSrDomainFindings()) {
//STUDYID -- > Study Identifier
retStr.append(id);
retStr.append("|");
//DOMAIN -- > Domain Abbreviation, always SR
retStr.append("SR");
retStr.append("|");
//SRSEQ -- > Sequence number
retStr.append("");
retStr.append("|");
//SRRISK --> Effect Level Associated with a Group/Sex, NOEL, LOEL, NOAEL, LOAEL, HNSTD, STD, MTD
retStr.append(srDomainFinding.getSRRISK()==null?"":srDomainFinding.getSRRISK());
retStr.append("|");
//SPGRPCD --> Sponsor-defined Group Code, group 1 , A
retStr.append(srDomainFinding.getSPGRPCD()==null?"":srDomainFinding.getSPGRPCD());
retStr.append("|");
//GRPLBL --> Sponsor-defined Group Name, "low dose", "mid dose"
retStr.append(srDomainFinding.getGRPLBL()==null?"":srDomainFinding.getGRPLBL());
retStr.append("|");
//SRGRPDOS --> Group Dose Level, "20 mg/kg"
retStr.append(srDomainFinding.getSRGRPDOS()==null?"":srDomainFinding.getSRGRPDOS());
retStr.append("|");
//SRSEX -- > Sex
retStr.append(srDomainFinding.getSRSEX()==null?"":srDomainFinding.getSRSEX());
retStr.append("|");
//SRSTDY --> Study Day of Start of Finding
retStr.append("");
retStr.append("|");
//SRSTPHSE --> Study Phase of first Observation, “PRE-DOSING”, “DOSING”, “RECOVERY”
retStr.append("");
retStr.append("|");
//SROBSTDY --> Start Phase Day of Observation
retStr.append("");
retStr.append("|");
//SRENPHSE -->Study Phase of last Observation
retStr.append("");
retStr.append("|");
//SRDOMAIN --> Domain of Finding
retStr.append(srDomainFinding.getSRDOMAIN()==null?"":srDomainFinding.getSRDOMAIN());
retStr.append("|");
//SRSPEC --> Specimen of Finding
retStr.append(srDomainFinding.getSRSPEC()==null?"":srDomainFinding.getSRSPEC());
retStr.append("|");
//SRTSTCD --> Test Short Name
retStr.append(srDomainFinding.getSRTSTCD()==null?"":srDomainFinding.getSRTSTCD());
retStr.append("|");
//SRFNDG --> Finding
retStr.append(srDomainFinding.getSRFNDG()==null?"":srDomainFinding.getSRFNDG());
retStr.append("|");
//SRORES --> Observation (original result)
retStr.append(srDomainFinding.getSRORES()==null?"":srDomainFinding.getSRORES());
retStr.append("|");
//SROBSV --> Manifestation of Finding, “I” (Increase), “D” (Decrease), “P” (Present) or “A” (Absent)
retStr.append(srDomainFinding.getSROBSV()==null?"":srDomainFinding.getSROBSV());
retStr.append("|");
//SROBSQ --> Observation Qualifier, “R” (Reversible), “T” (Transient) or ‘none’
retStr.append(srDomainFinding.getSROBSQ()==null?"":srDomainFinding.getSROBSQ());
retStr.append("|");
//SRSEV --> Severity of Finding
retStr.append("");
retStr.append("|");
//SRPCNT --> Scale of this Finding
retStr.append("");
retStr.append("|");
//SRSIGF --> Statistical Significance
retStr.append(srDomainFinding.getSRSIGF()==null?"":srDomainFinding.getSRSIGF());
retStr.append("|");
//SRTRTEF --> Treatment-Related
retStr.append(srDomainFinding.getSRTRTEF()==null?"":srDomainFinding.getSRTRTEF());
retStr.append("|");
//SRCOMNT --> Comment
retStr.append("\n");
}
}
return retStr.toString().getBytes(Charset.forName("UTF-8"));
}
/**
* Create a plain text file with the given string
* @param path
* @param plainText
* @throws FileNotFoundException
* @throws IOException
*/
private void createTxtFile(String path, String plainText) throws FileNotFoundException, IOException {
File fout = new File(path);
FileOutputStream fos = new FileOutputStream(fout);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos,StandardCharsets.UTF_8));
bw.write(plainText);
bw.flush();
bw.close();
}
// /**
// *
// * @param text
// * @param findingSelected
// * @return
// */
// private String generateFindingSnippet(String text, Finding findingSelected) {
// System.out.println(text);
// Integer offsetSlicing = 0;
//
// List<Annotation> all = findingSelected.generateSortedAnnotations();
// Collections.sort(all);
//
// Annotation relevant_text = findingSelected.getRelevant_text();
// String init_ = "<span class='relevant_text'>";
// String end_ = "</span>";
//
// text = text.toString().substring(0, relevant_text.getStartOffset()) + init_ + relevant_text.getText() + end_ + text.toString().substring(relevant_text.getEndOffset());
// offsetSlicing = init_.length();
// Object[] data = {text, offsetSlicing};
// for (Annotation annotation : all) {
// if(!annotationSuperposition(annotation, all)) {
// data = addColorToAnnotation(data, this.getAnnotationStyleClass(annotation), annotation);
// }
// System.out.println(data[0]);
// }
// return data[0].toString();
// }
/**
*
* @param text
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment