diff --git a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java index 13ce146..dac663d 100644 --- a/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java +++ b/cardea-data/src/main/java/ca/on/oicr/gsi/cardea/data/Case.java @@ -49,16 +49,8 @@ private Case(Builder builder) { this.timepoint = builder.timepoint; this.receipts = unmodifiableList(builder.receipts); this.tests = unmodifiableList(builder.tests); - this.requisition = builder.requisition; - if (builder.startDate != null) { - this.startDate = builder.startDate; - } else { - this.startDate = builder.receipts.stream() - .filter(sample -> sample.getRequisitionId() != null - && sample.getRequisitionId().longValue() == builder.requisition.getId()) - .map(Sample::getCreatedDate) - .min(LocalDate::compareTo).orElse(null); - } + this.requisition = requireNonNull(builder.requisition); + this.startDate = requireNonNull(builder.startDate); this.latestActivityDate = Stream .of(receipts.stream().map(Sample::getLatestActivityDate), tests.stream().map(Test::getLatestActivityDate), diff --git a/cardea-server/src/main/java/ca/on/oicr/gsi/cardea/server/CaseLoader.java b/cardea-server/src/main/java/ca/on/oicr/gsi/cardea/server/CaseLoader.java index bb795fd..6031645 100644 --- a/cardea-server/src/main/java/ca/on/oicr/gsi/cardea/server/CaseLoader.java +++ b/cardea-server/src/main/java/ca/on/oicr/gsi/cardea/server/CaseLoader.java @@ -227,6 +227,7 @@ private List loadCases(FileReader fileReader, Map project .receipts(parseIdsAndGet(json, "receipt_ids", JsonNode::asText, samplesById)) .tests(parseTests(json, "assay_tests", samplesById)) .requisition(requisitionsById.get(requisitionId)) + .startDate(parseDate(json, "start_date")) .build(); }); } diff --git a/cardea-server/src/test/resources/testdata/cases.json b/cardea-server/src/test/resources/testdata/cases.json index 214c03d..37c50a0 100644 --- a/cardea-server/src/test/resources/testdata/cases.json +++ b/cardea-server/src/test/resources/testdata/cases.json @@ -59,6 +59,7 @@ } ], "requisition_id": 512, - "stopped": false + "stopped": false, + "start_date": "2021-07-19" } ] diff --git a/changes/change_startDate.md b/changes/change_startDate.md new file mode 100644 index 0000000..763aac2 --- /dev/null +++ b/changes/change_startDate.md @@ -0,0 +1 @@ +Case start date provided by QC-Gate-ETL (based on latest sample receipt) will be used