Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sample name validation for microbial fastq #4019

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from cg.exc import OrderError
from cg.models.orders.constants import OrderType
from cg.models.orders.order import OrderIn
from cg.models.orders.samples import SarsCov2Sample
from cg.models.orders.samples import MicrobialFastqSample, SarsCov2Sample
from cg.services.orders.submitters.order_submitter import ValidateOrderService
from cg.store.models import Customer
from cg.store.store import Store
Expand All @@ -15,18 +15,25 @@ def __init__(self, status_db: Store):
def validate_order(self, order: OrderIn) -> None:
if order.order_type == OrderType.SARS_COV_2:
self._validate_sample_names_are_available(
samples=order.samples, customer_id=order.customer
samples=order.samples, customer_id=order.customer, is_sars_cov_2=True
)
elif order.order_type == OrderType.MICROBIAL_FASTQ:
islean marked this conversation as resolved.
Show resolved Hide resolved
self._validate_sample_names_are_available(
samples=order.samples, customer_id=order.customer, is_sars_cov_2=False
)

def _validate_sample_names_are_available(
self, samples: list[SarsCov2Sample], customer_id: str
self,
samples: list[SarsCov2Sample] | list[MicrobialFastqSample],
customer_id: str,
is_sars_cov_2: bool,
) -> None:
"""Validate names of all samples are not already in use."""
customer: Customer = self.status_db.get_customer_by_internal_id(
customer_internal_id=customer_id
)
for sample in samples:
if sample.control:
if is_sars_cov_2 and sample.control:
continue
if self.status_db.get_sample_by_customer_and_name(
customer_entry_id=[customer.id], sample_name=sample.name
Expand Down
Loading