diff --git a/cg/services/orders/storing/implementations/fastq_order_service.py b/cg/services/orders/storing/implementations/fastq_order_service.py index 16f674b6c6..2092e73787 100644 --- a/cg/services/orders/storing/implementations/fastq_order_service.py +++ b/cg/services/orders/storing/implementations/fastq_order_service.py @@ -5,6 +5,7 @@ from cg.constants.constants import CustomerId from cg.constants.sequencing import SeqLibraryPrepCategory from cg.models.orders.sample_base import SexEnum, StatusEnum +from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP from cg.services.orders.lims_service.service import OrderLimsService from cg.services.orders.storing.constants import MAF_ORDER_ID from cg.services.orders.storing.service import StoreOrderService @@ -82,8 +83,8 @@ def _create_db_case(self, order: FastqOrder, db_order: Order) -> Case: """Return a Case database object.""" priority: str = order.samples[0].priority case: Case = self.status_db.add_case( - data_analysis=Workflow.RAW_DATA, - data_delivery=DataDelivery.FASTQ, + data_analysis=ORDER_TYPE_WORKFLOW_MAP[order.order_type], + data_delivery=DataDelivery(order.delivery_type), name=str(db_order.ticket_id), priority=priority, ticket=str(db_order.ticket_id), diff --git a/cg/services/orders/storing/implementations/microbial_fastq_order_service.py b/cg/services/orders/storing/implementations/microbial_fastq_order_service.py index 3b5b306ac8..4682259895 100644 --- a/cg/services/orders/storing/implementations/microbial_fastq_order_service.py +++ b/cg/services/orders/storing/implementations/microbial_fastq_order_service.py @@ -2,6 +2,7 @@ from cg.constants import DataDelivery, SexOptions, Workflow from cg.models.orders.sample_base import StatusEnum +from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP from cg.services.orders.lims_service.service import OrderLimsService from cg.services.orders.storing.service import StoreOrderService from cg.services.orders.validation.workflows.microbial_fastq.models.order import MicrobialFastqOrder @@ -46,7 +47,7 @@ def store_order_data_in_status_db(self, order: MicrobialFastqOrder) -> list[Samp with self.status_db.session.no_autoflush: for sample in order.samples: case: Case = self._create_db_case_for_sample( - sample=sample, customer=db_order.customer, ticket_id=str(db_order.ticket_id) + sample=sample, customer=db_order.customer, order=order ) db_sample: Sample = self._create_db_sample( sample=sample, @@ -73,16 +74,16 @@ def _create_db_order(self, order: MicrobialFastqOrder) -> Order: return self.status_db.add_order(customer=customer, ticket_id=ticket_id) def _create_db_case_for_sample( - self, sample: MicrobialFastqSample, customer: Customer, ticket_id: str + self, sample: MicrobialFastqSample, customer: Customer, order: MicrobialFastqOrder ) -> Case: """Return a Case database object for a MicrobialFastqSample.""" case_name: str = f"{sample.name}-case" case: Case = self.status_db.add_case( - data_analysis=Workflow.RAW_DATA, - data_delivery=DataDelivery.FASTQ, + data_analysis=ORDER_TYPE_WORKFLOW_MAP[order.order_type], + data_delivery=DataDelivery(order.delivery_type), name=case_name, priority=sample.priority, - ticket=ticket_id, + ticket=str(order._generated_ticket_id), ) case.customer = customer return case diff --git a/cg/services/orders/storing/implementations/pacbio_order_service.py b/cg/services/orders/storing/implementations/pacbio_order_service.py index 1776a07b95..a8640625d8 100644 --- a/cg/services/orders/storing/implementations/pacbio_order_service.py +++ b/cg/services/orders/storing/implementations/pacbio_order_service.py @@ -3,6 +3,7 @@ from cg.constants import DataDelivery, Workflow from cg.models.orders.sample_base import StatusEnum +from cg.services.orders.constants import ORDER_TYPE_WORKFLOW_MAP from cg.services.orders.lims_service.service import OrderLimsService from cg.services.orders.storing.service import StoreOrderService from cg.services.orders.validation.workflows.pacbio_long_read.models.order import PacbioOrder @@ -77,16 +78,16 @@ def _create_db_order(self, order: PacbioOrder) -> Order: return self.status_db.add_order(customer=customer, ticket_id=ticket_id) def _create_db_case_for_sample( - self, sample: PacbioSample, customer: Customer, ticket_id: str + self, sample: PacbioSample, customer: Customer, order: PacbioOrder ) -> Case: """Return a Case database object for a PacbioSample.""" case_name: str = f"{sample.name}-case" case: Case = self.status_db.add_case( - data_analysis=Workflow.RAW_DATA, - data_delivery=DataDelivery.BAM, + data_analysis=ORDER_TYPE_WORKFLOW_MAP[order.order_type], + data_delivery=DataDelivery(order.delivery_type), name=case_name, priority=sample.priority, - ticket=ticket_id, + ticket=str(order._generated_ticket_id), ) case.customer = customer return case