Skip to content

Commit

Permalink
[GLT-4050] switched over from requisition QCs to deliverables (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
djcooke authored Feb 27, 2024
1 parent c60c681 commit c5f0b61
Show file tree
Hide file tree
Showing 18 changed files with 358 additions and 354 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
/**
* Immutable RequisitionQcGroup
*/
@JsonDeserialize(builder = RequisitionQcGroup.Builder.class)
public class RequisitionQcGroup {
@JsonDeserialize(builder = AnalysisQcGroup.Builder.class)
public class AnalysisQcGroup {

private final BigDecimal callability;
private final BigDecimal collapsedCoverage;
private final Donor donor;
private final String groupId;
private final String libraryDesignCode;
private final BigDecimal purity;
private final String tissueOrigin;
private final String tissueType;

private RequisitionQcGroup(Builder builder) {
this.donor = requireNonNull(builder.donor);
private AnalysisQcGroup(Builder builder) {
this.tissueOrigin = requireNonNull(builder.tissueOrigin);
this.tissueType = requireNonNull(builder.tissueType);
this.libraryDesignCode = requireNonNull(builder.libraryDesignCode);
Expand All @@ -40,10 +38,6 @@ public BigDecimal getCollapsedCoverage() {
return collapsedCoverage;
}

public Donor getDonor() {
return donor;
}

public String getGroupId() {
return groupId;
}
Expand All @@ -69,15 +63,14 @@ public static class Builder {

private BigDecimal callability;
private BigDecimal collapsedCoverage;
private Donor donor;
private String groupId;
private String libraryDesignCode;
private BigDecimal purity;
private String tissueOrigin;
private String tissueType;

public RequisitionQcGroup build() {
return new RequisitionQcGroup(this);
public AnalysisQcGroup build() {
return new AnalysisQcGroup(this);
}

public Builder callability(BigDecimal callability) {
Expand All @@ -90,11 +83,6 @@ public Builder collapsedCoverage(BigDecimal collapsedCoverage) {
return this;
}

public Builder donor(Donor donor) {
this.donor = donor;
return this;
}

public Builder groupId(String groupId) {
this.groupId = groupId;
return this;
Expand Down
34 changes: 25 additions & 9 deletions cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.on.oicr.gsi.cardea.data;

import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableList;
import static java.util.Collections.unmodifiableSet;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -31,7 +32,8 @@ public class Case {
private final Requisition requisition;
private final LocalDate startDate;
private final List<Test> tests;
private final List<Deliverable> deliverables;
private final List<AnalysisQcGroup> qcGroups;
private final List<CaseDeliverable> deliverables;
private final String timepoint;
private final String tissueOrigin;
private final String tissueType;
Expand All @@ -56,15 +58,19 @@ private Case(Builder builder) {
this.timepoint = builder.timepoint;
this.receipts = unmodifiableList(builder.receipts);
this.tests = unmodifiableList(builder.tests);
this.qcGroups = builder.qcGroups == null ? emptyList() : unmodifiableList(builder.qcGroups);
this.deliverables =
builder.deliverables == null ? null : unmodifiableList(builder.deliverables);
builder.deliverables == null ? emptyList() : unmodifiableList(builder.deliverables);
this.requisition = requireNonNull(builder.requisition);
this.startDate = requireNonNull(builder.startDate);

this.latestActivityDate = Stream
.of(receipts.stream().map(Sample::getLatestActivityDate),
tests.stream().map(Test::getLatestActivityDate),
Stream.of(requisition.getLatestActivityDate()))
.flatMap(Function.identity()).filter(Objects::nonNull).max(LocalDate::compareTo)
.concat(Stream.of(receipts.stream().map(Sample::getLatestActivityDate),
tests.stream().map(Test::getLatestActivityDate))
.flatMap(Function.identity()),
deliverables == null ? Stream.empty()
: deliverables.stream().map(CaseDeliverable::getLatestActivityDate))
.filter(Objects::nonNull).max(LocalDate::compareTo)
.orElse(null);
this.receiptDaysSpent = builder.receiptDaysSpent;
this.analysisReviewDaysSpent = builder.analysisReviewDaysSpent;
Expand Down Expand Up @@ -118,7 +124,11 @@ public List<Test> getTests() {
return tests;
}

public List<Deliverable> getDeliverables() {
public List<AnalysisQcGroup> getQcGroups() {
return qcGroups;
}

public List<CaseDeliverable> getDeliverables() {
return deliverables;
}

Expand Down Expand Up @@ -174,7 +184,8 @@ public static class Builder {
private List<Sample> receipts;
private Requisition requisition;
private List<Test> tests;
private List<Deliverable> deliverables;
private List<AnalysisQcGroup> qcGroups;
private List<CaseDeliverable> deliverables;
private String timepoint;
private String tissueOrigin;
private String tissueType;
Expand Down Expand Up @@ -235,7 +246,12 @@ public Builder requisition(Requisition requisition) {
return this;
}

public Builder deliverables(List<Deliverable> deliverables) {
public Builder qcGroups(List<AnalysisQcGroup> qcGroups) {
this.qcGroups = qcGroups;
return this;
}

public Builder deliverables(List<CaseDeliverable> deliverables) {
this.deliverables = deliverables;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import static java.util.Objects.requireNonNull;

import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

@JsonDeserialize(builder = Deliverable.Builder.class)
public class Deliverable {
@JsonDeserialize(builder = CaseDeliverable.Builder.class)
public class CaseDeliverable {

private final DeliverableType deliverableType;
private final LocalDate analysisReviewQcDate;
Expand All @@ -18,12 +22,10 @@ public class Deliverable {
private final Boolean releaseApprovalQcPassed;
private final String releaseApprovalQcUser;
private final String releaseApprovalQcNote;
private final LocalDate releaseQcDate;
private final Boolean releaseQcPassed;
private final String releaseQcUser;
private final String releaseQcNote;
private final List<CaseRelease> releases;
private final LocalDate latestActivityDate;

private Deliverable(Builder builder) {
private CaseDeliverable(Builder builder) {
this.deliverableType = requireNonNull(builder.deliverableType);
this.analysisReviewQcDate = builder.analysisReviewQcDate;
this.analysisReviewQcPassed = builder.analysisReviewQcPassed;
Expand All @@ -33,10 +35,14 @@ private Deliverable(Builder builder) {
this.releaseApprovalQcPassed = builder.releaseApprovalQcPassed;
this.releaseApprovalQcUser = builder.releaseApprovalQcUser;
this.releaseApprovalQcNote = builder.releaseApprovalQcNote;
this.releaseQcDate = builder.releaseQcDate;
this.releaseQcPassed = builder.releaseQcPassed;
this.releaseQcUser = builder.releaseQcUser;
this.releaseQcNote = builder.releaseQcNote;
this.releases = builder.releases == null ? Collections.emptyList()
: Collections.unmodifiableList(builder.releases);
this.latestActivityDate = Stream
.concat(releases == null ? Stream.empty() : releases.stream().map(CaseRelease::getQcDate),
Stream.of(analysisReviewQcDate, releaseApprovalQcDate))
.filter(Objects::nonNull)
.max(LocalDate::compareTo)
.orElse(null);
}

public DeliverableType getDeliverableType() {
Expand Down Expand Up @@ -75,21 +81,14 @@ public String getReleaseApprovalQcNote() {
return releaseApprovalQcNote;
}

public LocalDate getReleaseQcDate() {
return releaseQcDate;
public List<CaseRelease> getReleases() {
return releases;
}

public Boolean getReleaseQcPassed() {
return releaseQcPassed;
public LocalDate getLatestActivityDate() {
return latestActivityDate;
}

public String getReleaseQcUser() {
return releaseQcUser;
}

public String getReleaseQcNote() {
return releaseQcNote;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {
Expand All @@ -103,10 +102,7 @@ public static class Builder {
private Boolean releaseApprovalQcPassed;
private String releaseApprovalQcUser;
private String releaseApprovalQcNote;
private LocalDate releaseQcDate;
private Boolean releaseQcPassed;
private String releaseQcUser;
private String releaseQcNote;
private List<CaseRelease> releases;

public Builder deliverableType(DeliverableType deliverableType) {
this.deliverableType = deliverableType;
Expand Down Expand Up @@ -153,28 +149,13 @@ public Builder releaseApprovalQcNote(String releaseApprovalQcNote) {
return this;
}

public Builder releaseQcDate(LocalDate releaseQcDate) {
this.releaseQcDate = releaseQcDate;
return this;
}

public Builder releaseQcPassed(Boolean releaseQcPassed) {
this.releaseQcPassed = releaseQcPassed;
return this;
}

public Builder releaseQcUser(String releaseQcUser) {
this.releaseQcUser = releaseQcUser;
return this;
}

public Builder releaseQcNote(String releaseQcNote) {
this.releaseQcNote = releaseQcNote;
public Builder releases(List<CaseRelease> releases) {
this.releases = releases;
return this;
}

public Deliverable build() {
return new Deliverable(this);
public CaseDeliverable build() {
return new CaseDeliverable(this);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package ca.on.oicr.gsi.cardea.data;

import java.time.LocalDate;
import java.util.Objects;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

@JsonDeserialize(builder = CaseRelease.Builder.class)
public class CaseRelease {

private final String deliverable;
private final LocalDate qcDate;
private final Boolean qcPassed;
private final String qcUser;
private final String qcNote;

private CaseRelease(Builder builder) {
this.deliverable = Objects.requireNonNull(builder.deliverable);
this.qcDate = builder.qcDate;
this.qcPassed = builder.qcPassed;
this.qcUser = builder.qcUser;
this.qcNote = builder.qcNote;
}

public String getDeliverable() {
return deliverable;
}

public LocalDate getQcDate() {
return qcDate;
}

public Boolean getQcPassed() {
return qcPassed;
}

public String getQcUser() {
return qcUser;
}

public String getQcNote() {
return qcNote;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {

private String deliverable;
private LocalDate qcDate;
private Boolean qcPassed;
private String qcUser;
private String qcNote;

public Builder deliverable(String deliverable) {
this.deliverable = deliverable;
return this;
}

public Builder qcDate(LocalDate qcDate) {
this.qcDate = qcDate;
return this;
}

public Builder qcPassed(Boolean qcPassed) {
this.qcPassed = qcPassed;
return this;
}

public Builder qcUser(String qcUser) {
this.qcUser = qcUser;
return this;
}

public Builder qcNote(String qcNote) {
this.qcNote = qcNote;
return this;
}

public CaseRelease build() {
return new CaseRelease(this);
}

}
}
Loading

0 comments on commit c5f0b61

Please sign in to comment.