diff --git a/src/Form/Nph/NphOrderType.php b/src/Form/Nph/NphOrderType.php index f79873c09..cfac8bb4f 100644 --- a/src/Form/Nph/NphOrderType.php +++ b/src/Form/Nph/NphOrderType.php @@ -155,7 +155,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'view_timezone' => $options['userTimezone'], 'model_timezone' => 'UTC', 'label' => 'Order Creation Time', - 'attr' => ['class' => 'order-ts'] + 'attr' => ['class' => 'order-ts', 'autocomplete' => 'off'], ]); return $builder->getForm(); diff --git a/src/Repository/NphOrderRepository.php b/src/Repository/NphOrderRepository.php index 9746baae4..bb37039b1 100644 --- a/src/Repository/NphOrderRepository.php +++ b/src/Repository/NphOrderRepository.php @@ -216,11 +216,14 @@ public function getDownTimeGeneratedOrdersByModuleAndVisit(string $ParticipantId { $queryBuild = $this->createQueryBuilder('no') ->where('no.participantId = :participantId') + ->join('no.nphSamples', 'ns') ->andWhere('no.module = :module') ->andWhere('no.visitType = :visitType') ->andWhere('no.DowntimeGenerated = 1') + ->andWhere('ns.modifyType != :modifyType OR ns.modifyType IS NULL') ->setParameter('participantId', $ParticipantId) ->setParameter('module', $Module) + ->setParameter('modifyType', NphSample::CANCEL) ->setParameter('visitType', $Visit); return $queryBuild->getQuery()->getResult(); } diff --git a/src/Service/Nph/NphOrderService.php b/src/Service/Nph/NphOrderService.php index 989d303c4..f1bbad97d 100644 --- a/src/Service/Nph/NphOrderService.php +++ b/src/Service/Nph/NphOrderService.php @@ -275,12 +275,12 @@ public function createOrdersAndSamples(array $formData): string return $sampleGroup; } - public function createOrder(string $timePoint, string $orderType, string $orderId = null, bool $downtimeGenerated = false, ?DateTime $downtimeGeneratedTs = new DateTime()): NphOrder + public function createOrder(string $timePoint, string $orderType, string $orderId = null, bool $downtimeGenerated = false, ?DateTime $downtimeGeneratedTs = null): NphOrder { if ($orderId === null) { $orderId = $this->generateOrderId(); } - if ($downtimeGeneratedTs === null) { + if (empty($downtimeGeneratedTs)) { $downtimeGeneratedTs = new DateTime(); } $nphOrder = new NphOrder(); @@ -849,20 +849,24 @@ public function getDowntimeOrderSummary(): array $downtimeGenerated = []; $downtimeGenerated['orderInfo'] = []; $downtimeGenerated['sampleInfo'] = []; - $orderNumber = 1; + $orderNumber = 0; + $seenSampleGroups = []; /** @var NphOrder $order */ foreach ($orders as $order) { if (array_key_exists($order->getTimepoint(), $existingSamples)) { - $downtimeGenerated['orderInfo'][$orderNumber]['orderUser'] = $order->getUser()->getEmail(); - $downtimeGenerated['orderInfo'][$orderNumber]['orderDowntimeCreatedTime'] = $order->getDowntimeGeneratedTs(); - $downtimeGenerated['orderInfo'][$orderNumber]['orderCreatedTime'] = $order->getCreatedTs(); /** @var NphSample $sample */ foreach ($order->getNphSamples() as $sample) { + if (!in_array($sample->getSampleGroup(), $seenSampleGroups, true)) { + $seenSampleGroups[] = $sample->getSampleGroup(); + $orderNumber++; + $downtimeGenerated['orderInfo'][$orderNumber]['orderUser'] = $order->getUser()->getEmail(); + $downtimeGenerated['orderInfo'][$orderNumber]['orderDowntimeCreatedTime'] = $order->getDowntimeGeneratedTs(); + $downtimeGenerated['orderInfo'][$orderNumber]['orderCreatedTime'] = $order->getCreatedTs(); + } if (in_array($sample->getSampleCode(), $existingSamples[$order->getTimepoint()], true)) { $downtimeGenerated['sampleInfo'][$order->getTimepoint()][$sample->getSampleCode()] = $orderNumber; } } - $orderNumber++; } } return $downtimeGenerated; @@ -937,7 +941,7 @@ private function getNumericId(): string return $id; } - private function createOrderWithSamples(string $timePoint, string $orderType, array $samples, string $sampleGroup, bool $downtimeGenerated = false, ?DateTime $downtimeGeneratedCreatedTs = new DateTime()): void + private function createOrderWithSamples(string $timePoint, string $orderType, array $samples, string $sampleGroup, bool $downtimeGenerated = false, ?DateTime $downtimeGeneratedCreatedTs = null): void { $nphOrder = $this->createOrder($timePoint, $orderType, null, $downtimeGenerated, $downtimeGeneratedCreatedTs); foreach ($samples as $sample) { diff --git a/templates/program/nph/order/collect.html.twig b/templates/program/nph/order/collect.html.twig index a34e5aad7..a0fb33604 100644 --- a/templates/program/nph/order/collect.html.twig +++ b/templates/program/nph/order/collect.html.twig @@ -13,7 +13,7 @@ {% if order.downtimeGenerated() %}