Clinical-Genomics / cg

Glue between Clinical Genomics apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sequencing date for externally sequenced sample

seallard opened this issue · comments

We should ensure that the last_sequenced_at date is set for externally sequenced samples, that way we can drop the ordered_at column from the sample model and remove some of this logic on the case model

    @property
    def latest_sequenced(self) -> datetime | None:
        sequenced_dates = []
        for link in self.links:
            if link.sample.application_version.application.is_external:
                sequenced_dates.append(link.sample.ordered_at)
            elif link.sample.last_sequenced_at:
                sequenced_dates.append(link.sample.last_sequenced_at)
        return max(sequenced_dates, default=None)