Skip to content

Commit

Permalink
[GLT-4070]added TAT trend report (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuall826 authored Aug 14, 2024
1 parent bb06eea commit 370ed01
Show file tree
Hide file tree
Showing 13 changed files with 713 additions and 35 deletions.
1 change: 1 addition & 0 deletions changes/add_GLT-4070
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TAT trend report generated from the Cases list in Dimsum using the same filters
2 changes: 1 addition & 1 deletion docs/user_manual/reports.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ cases you are interested in, and click the "TAT Report" button. The report will

## TAT Trend Report

(TODO)
The TAT Trend Report provides a box plot visualization of turn-around time trends for selected cases. It includes gates for clinical report and data release turn-around times, with options to group data by time range or QC gate. To generate the report, select cases from any case table, such as the main QC dashboard, and click the "TAT Trend" button. The report will open in a new window.
145 changes: 121 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
},
"license": "MIT",
"devDependencies": {
"@types/plotly.js-dist-min": "^2.3.4",
"tailwindcss": "^3.0.24",
"ts-loader": "^9.3.0",
"typescript": "^5.3.3",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.2"
},
"dependencies": {
"plotly.js-dist-min": "^2.33.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ca.on.oicr.gsi.dimsum.controller.mvc;

import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class TatTrendController {

@GetMapping("/tat-trend")
public ModelAndView tatTrend(@RequestParam Map<String, String> filters) {
ModelAndView modelAndView = new ModelAndView("tat-trend");
modelAndView.addObject("filters", filters);
return modelAndView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.io.IOException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand All @@ -13,6 +12,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import ca.on.oicr.gsi.dimsum.controller.BadRequestException;
import ca.on.oicr.gsi.dimsum.service.CaseService;
import ca.on.oicr.gsi.dimsum.util.reporting.Report;
Expand All @@ -29,23 +29,30 @@ public class DownloadRestController {
@Autowired
private CaseService caseService;

@Autowired
private ObjectMapper objectMapper; // Autowire ObjectMapper

@PostMapping("/reports/{reportName}")
public HttpEntity<byte[]> generateReport(@PathVariable String reportName,
@RequestBody JsonNode parameters, HttpServletResponse response)
throws IOException {
@RequestBody JsonNode parameters) throws IOException {

ReportFormat format = Report.getFormat(parameters);
Report report = getReport(reportName);
byte[] bytes = report.writeFile(caseService, parameters);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(format.getMediaType());
response.setHeader("Content-Disposition",
"attachment; filename="
+ String.format("%s-%s.%s", reportName, DateTimeFormatter.ISO_LOCAL_DATE.format(
ZonedDateTime.now()), format.getExtension()));
headers.set("Content-Disposition",
"attachment; filename=" + String.format("%s-%s.%s", reportName,
DateTimeFormatter.ISO_LOCAL_DATE.format(ZonedDateTime.now()), format.getExtension()));

return new HttpEntity<>(bytes, headers);
}

return new HttpEntity<byte[]>(bytes, headers);
@PostMapping("/reports/{reportName}/data")
public JsonNode getReportData(@PathVariable String reportName, @RequestBody JsonNode parameters) {
Report report = getReport(reportName);
return report.getData(caseService, parameters, objectMapper); // Return JSON directly
}

private static Report getReport(String reportName) {
Expand All @@ -62,5 +69,4 @@ private static Report getReport(String reportName) {
throw new BadRequestException("Invalid report name");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import ca.on.oicr.gsi.dimsum.controller.BadRequestException;
import ca.on.oicr.gsi.dimsum.service.CaseService;

Expand Down Expand Up @@ -82,4 +83,10 @@ private byte[] writeDelimitedFile(CaseService caseService, String delimiter,
return sb.toString().getBytes();
}

public <T> JsonNode getData(CaseService caseService, JsonNode parameters,
ObjectMapper objectMapper) {
ReportSection<T> section = (ReportSection<T>) sections.get(0);
List<T> objects = section.getData(caseService, parameters);
return section.createJson(objects, objectMapper);
}
}
Loading

0 comments on commit 370ed01

Please sign in to comment.