Skip to content

Commit

Permalink
Merge pull request #1658 from all-of-us/master
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamzcode authored Dec 4, 2023
2 parents 9c03633 + e3d2789 commit d37d31d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Form/Nph/NphOrderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/Repository/NphOrderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
20 changes: 12 additions & 8 deletions src/Service/Nph/NphOrderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion templates/program/nph/order/collect.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>
{% if order.downtimeGenerated() %}
<div class="alert bg-success well-sm margin-top-15 text-success">
<span>This sample was generated as part of a downtime order initiated by: {{ order.downtimeGeneratedUser.getEmail }} on {{ order.downtimeGeneratedTs|date('n/j/Y') }}. [Order generation time: {{ order.createdTs|date('n/j/Y g:ia')}}] </span>
<span>This sample was generated as part of a downtime order initiated by: {{ order.downtimeGeneratedUser.getEmail }} on {{ order.downtimeGeneratedTs|date('n/j/Y', app.user.timezone) }}. [Order generation time: {{ order.createdTs|date('n/j/Y g:ia', app.user.timezone)}}] </span>
</div>
{% endif %}
<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion templates/program/nph/order/generate-orders.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{% for orderNumber, order in downtimeOrders['orderInfo'] %}
<div class="col-sm-3" style="margin-bottom: 25px">
<label>Order Generation Time<sup>{{ orderNumber }}</sup></label>
<input type="text" disabled class="order-ts form-control" style="" value="{{ order['orderCreatedTime']|date('n/j/Y g:ia') }}">
<input type="text" disabled class="order-ts form-control" style="" value="{{ order['orderCreatedTime']|date('n/j/Y g:ia', app.user.timezone) }}">
<sub class="text-success"><i class="fa fa-history"></i> Downtime order initiated by:
{{order['orderUser']}}</sub>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/program/nph/order/sample-finalize.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
<div class="panel-body">
{% if order.downtimeGenerated() %}
<div class="alert bg-success well-sm margin-top-15 text-success">
<span>This sample was generated as part of a downtime order initiated by: {{ order.downtimeGeneratedUser.getEmail }} on {{ order.downtimeGeneratedTs|date('n/j/Y') }}. [Order generation time: {{ order.createdTs|date('n/j/Y g:ia')}}] </span>
<span>This sample was generated as part of a downtime order initiated by: {{ order.downtimeGeneratedUser.getEmail }} on {{ order.downtimeGeneratedTs|date('n/j/Y', app.user.timezone) }}. [Order generation time: {{ order.createdTs|date('n/j/Y g:ia', app.user.timezone)}}] </span>
</div>
{% endif %}
{% if isFormDisabled %}
Expand Down
2 changes: 1 addition & 1 deletion templates/program/nph/order/samples.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
{% endmacro %}

{% macro displayDowntimeGeneratedOrderNumber(downtimeGeneratedOrders, timePoint, sample) %}
{% if downtimeGeneratedOrders['sampleInfo']|length > 0 and downtimeGeneratedOrders['sampleInfo'][timePoint][sample.vars.value] %}
{% if downtimeGeneratedOrders['sampleInfo']|length > 0 and timePoint in downtimeGeneratedOrders['sampleInfo']|keys and downtimeGeneratedOrders['sampleInfo'][timePoint][sample.vars.value] %}
<sup>{{ downtimeGeneratedOrders['sampleInfo'][timePoint][sample.vars.value] }}</sup>
{% endif %}
{% endmacro %}
Expand Down
14 changes: 10 additions & 4 deletions web/assets/js/views/NphOrderCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,14 @@ $(document).ready(function () {
}
}

showHideDowntimeCreatedTs();
$("#nph_order_createdTs").pmiDateTimePicker({
maxDate: new Date()
});
function initializeDowntimeCreatedTsDatePicker() {
showHideDowntimeCreatedTs();
let dateSelector = $("#nph_order_createdTs");
let currentValue = dateSelector.val();
$("#nph_order_createdTs").pmiDateTimePicker({
maxDate: new Date()
});
dateSelector.val(currentValue);
}
initializeDowntimeCreatedTsDatePicker();
});

0 comments on commit d37d31d

Please sign in to comment.