Skip to content

Commit

Permalink
[GLT-4307] Added donor assay report
Browse files Browse the repository at this point in the history
  • Loading branch information
wuall826 committed Dec 5, 2024
1 parent a01bbb9 commit 068862e
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes/add_GLT-4307
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Donor Assay Report Download from the Cases table
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ca.on.oicr.gsi.dimsum.util.reporting.ReportFormat;
import ca.on.oicr.gsi.dimsum.util.reporting.reports.CaseTatReport;
import ca.on.oicr.gsi.dimsum.util.reporting.reports.DareInputSheet;
import ca.on.oicr.gsi.dimsum.util.reporting.reports.DonorAssayReport;
import ca.on.oicr.gsi.dimsum.util.reporting.reports.FullDepthSummary;
import ca.on.oicr.gsi.dimsum.util.reporting.reports.TglTrackingReport;

Expand Down Expand Up @@ -65,6 +66,8 @@ private static Report getReport(String reportName) {
return DareInputSheet.INSTANCE;
case "case-tat-report":
return CaseTatReport.INSTANCE;
case "donor-assay-report":
return DonorAssayReport.INSTANCE;
default:
throw new BadRequestException("Invalid report name");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package ca.on.oicr.gsi.dimsum.util.reporting.reports;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.JsonNode;
import ca.on.oicr.gsi.cardea.data.Case;
import ca.on.oicr.gsi.cardea.data.Project;
import ca.on.oicr.gsi.dimsum.controller.BadRequestException;
import ca.on.oicr.gsi.dimsum.service.CaseService;
import ca.on.oicr.gsi.dimsum.service.filtering.CompletedGate;
import ca.on.oicr.gsi.dimsum.util.reporting.Column;
import ca.on.oicr.gsi.dimsum.util.reporting.Report;
import ca.on.oicr.gsi.dimsum.util.reporting.ReportSection;
import ca.on.oicr.gsi.dimsum.util.reporting.ReportSection.TableReportSection;
import ca.on.oicr.gsi.dimsum.util.reporting.reports.shared.CaseSampleRowData;

public class DonorAssayReport extends Report {

private static final ReportSection<CaseSampleRowData> mainSection =
new TableReportSection<CaseSampleRowData>("Donor Assay Report", Arrays.asList(
Column.forString("Project", x -> x.getSample().getProject()),
Column.forString("Pipeline", x -> getProjectPipelines(x.getCase())),
Column.forString("Donor", x -> x.getCase().getDonor().getName()),
Column.forString("External Name", x -> x.getCase().getDonor().getExternalName()),
Column.forString("Assay", x -> x.getCase().getAssayName()),
Column.forString("Start Date", x -> getStartDate(x.getCase()).toString()),
Column.forString("Latest Activity", x -> getLatestActivityDate(x.getCase()).toString()),
Column.forString("Status", x -> getCaseStatus(x.getCase())),
Column.forString("Stop/Pause Reason", x -> getStopPauseReason(x.getCase())))) {
@Override
public List<CaseSampleRowData> getData(CaseService caseService, JsonNode parameters) {
Set<String> caseIds = getParameterStringSet(parameters, "caseIds");
if (caseIds == null) {
throw new BadRequestException("caseIds parameter missing");
}
return CaseSampleRowData.listByCaseIds(caseService, caseIds);
}
};

public static final DonorAssayReport INSTANCE = new DonorAssayReport();

private DonorAssayReport() {
super("Donor Assay Report", mainSection);
}

private static String getProjectPipelines(Case kase) {
return kase.getProjects().stream()
.map(Project::getPipeline)
.filter(Objects::nonNull)
.collect(Collectors.joining(", "));
}

private static LocalDate getStartDate(Case kase) {
return kase.getStartDate();
}

private static LocalDate getLatestActivityDate(Case kase) {
return kase.getLatestActivityDate();
}

private static String getCaseStatus(Case kase) {
if (CompletedGate.RELEASE.qualifyCase(kase)) {
return "Completed";
} else if (kase.isStopped()) {
return "Failed";
} else if (kase.getRequisition().isPaused()) {
return "Paused";
} else {
return "In Progress";
}
}

private static String getStopPauseReason(Case kase) {
if (kase.isStopped()) {
return kase.getRequisition().getStopReason() != null
? kase.getRequisition().getStopReason()
: "Reason Unspecified";
} else if (kase.getRequisition().isPaused()) {
return kase.getRequisition().getPauseReason() != null
? kase.getRequisition().getPauseReason()
: "Reason Unspecified";
}
return "";
}
}
3 changes: 3 additions & 0 deletions ts/data/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1898,11 +1898,13 @@ function hasDeliverable(kase: Case, deliverable: string) {

const REPORT_FULL_DEPTH_SUMMARY = "full-depth-summary";
const REPORT_DARE_INPUT_SHEET = "dare-input-sheet";
const DONOR_ASSAY_REPORT = "donor-assay-report";

function showDownloadDialog(items: Case[]) {
const reportOptions = new Map<string, string>([
["Full-Depth Summary", REPORT_FULL_DEPTH_SUMMARY],
["DARE Input Sheet", REPORT_DARE_INPUT_SHEET],
["Donor Assay Report", DONOR_ASSAY_REPORT],
]);

const reportSelect = new DropdownField(
Expand All @@ -1915,6 +1917,7 @@ function showDownloadDialog(items: Case[]) {
switch (result.report) {
case REPORT_FULL_DEPTH_SUMMARY:
case REPORT_DARE_INPUT_SHEET:
case DONOR_ASSAY_REPORT:
showDownloadOptionsDialog(result.report, items);
break;
default:
Expand Down

0 comments on commit 068862e

Please sign in to comment.