Clinical-Genomics / cg

Glue between Clinical Genomics apps
6 stars 2 forks source link

Not possible to filter for cancelled samples in StatusDB #3058

Open beatrizsavinhas opened 3 months ago

beatrizsavinhas commented 3 months ago

Description

It is currently not possible to filter for cancelled samples in StatusDB. This means that cancelled samples still show up as existing samples in the order portal and therefore the customers often place orders containing cancelled samples for which there is no data.

Related to https://github.com/Clinical-Genomics/clinical-genomics-ui/issues/431.

Furthermore, the current action of cancelling a sample in StatusDB also deleted all the associated entries in the Case Sample and Case tables. If by any reason the cancelling needs to be reversed, all information has to be re-entered in the database manually which is error prone (and has caused issues in the past). The action to cancel the sample should be reversible.

Suggested solution

Add field is_cancelled to the Sample table in StatusDB. The action to cancel the sample should be reversible (no data should be deleted from the database).

This can be closed when

It is possible to filter for cancelled samples.

Blocked by

Nothing to my knowledge.

beatrizsavinhas commented 3 months ago

According to @annagellerbring, we are expecting big orders in the following weeks for reruns of samples for which there are corresponding duplicated cancelled samples so it would be good to have this in place before then.

henrikstranneheim commented 3 months ago

@beatrizsavinhas Or is a status in the Action field? When should it be set and by whom (from GUI/TB/CLI/Automation/manually)?

beatrizsavinhas commented 3 months ago

Do you mean the Action field in the Case table? Maybe there should also be a cancelled status for case. (And cases that contain cancelled samples should not be able to start, but that would be another issue.)

But since we cancel the sequencing of samples, I think this should be a field in the Sample table.

This would be set in the GUI/manually (and possibly CLI?) as it is currently done by clicking With selected > Cancel samples (which results in appending the message "Cancelled yyyy-mm-dd by user" in the Comment field).

henrikstranneheim commented 3 months ago

Ok, thx for explaining, then this would be used to not show these samples as cancelled in the order? Or exclude them from the order when getting pre-existing samples? I guess there is no point including them in another order if they have been cancelled once.

beatrizsavinhas commented 3 months ago

Exactly, in the order portal we would want to exclude these cancelled samples from the list of existing samples so that the customers cannot place new orders with them (I've also written a related issue on this in the cg-ui repo https://github.com/Clinical-Genomics/clinical-genomics-ui/issues/431).

Vince-janv commented 3 months ago

Having talked to @beatrizsavinhas I think adding a column (is_cancelled) to the sample table makes sense. We could then filter those out from the samples we return to the front-end. I think this should be on sample level rather than case level.

seallard commented 2 months ago

What does it mean that a sample is cancelled? Is it cancelled in one order specifically? How is it cancelled?

Given that the sample can belong to multiple cases and orders, I'd advise against storing this information on the sample. Maybe an option is to remove cancelled samples from status db?

beatrizsavinhas commented 2 months ago

In general, a cancelled sample is a sample that cannot be analysed. Usually it is a sample where the prep or sequencing failed and, in most cases, we do not have any data for that sample. But we have received it, prepped it and worked on it so we still want to both bill it and keep track of the work we did - for traceability (and likely for other reasons), I don't think it is a good idea to simply remove cancelled samples from status db.

As a cancelled sample cannot be analysed, the analysis of existing cases connected to the sample should be prevented from starting and we also want to prevent customers from placing new orders with it. This is why I proposed that this information is stored on sample level.

But please do suggest alternative solutions if you think they would work better!

seallard commented 2 months ago

Alright, I see - thanks 👍

I think we should do some more technical refinement. Maybe there is a better way to model it. For instance, adding a separate SampleStatus table. Our sample model is already quite bloated.

beatrizsavinhas commented 2 months ago

We just had a sample that a customer requested to uncancel and we had to re-add all the information to the database manually, which is error prone - one more argument against deleting any data from StatusDB in this situation. Reverting the cancelling action is also something we would like to have! Will add this to the description of the issue and suggested solution as well.