Route pharmacy, lab, and billing tickets through a shared FIFO pool.
Deploy Ladill Care / deploy (push) Successful in 57s
Deploy Ladill Care / deploy (push) Successful in 57s
Stop pre-assigning prescriptions to a default counter so Call next follows arrival order and each pharmacist only serves one active patient at a time. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -64,6 +64,32 @@ class PrescriptionController extends Controller
|
||||
$queue = $queue->filter(fn (Prescription $rx) => (int) ($rx->visit?->branch_id) === $branchScope)->values();
|
||||
}
|
||||
|
||||
$queueIntegration = $branchId
|
||||
? $this->queueBridge->listMeta($organization, CareQueueContexts::PHARMACY, $branchId)
|
||||
: ['enabled' => false];
|
||||
|
||||
$memberPoint = $branchId
|
||||
? app(\App\Services\Care\CareQueueProvisioner::class)
|
||||
->pointForMember($organization, CareQueueContexts::PHARMACY, $branchId, $member)
|
||||
: null;
|
||||
$memberCounterUuid = $memberPoint['counter_uuid'] ?? null;
|
||||
|
||||
if (! empty($queueIntegration['enabled'])) {
|
||||
$queue = $queue->sortBy(function (Prescription $rx) use ($memberCounterUuid) {
|
||||
$status = (string) ($rx->queue_ticket_status ?? '');
|
||||
$mine = $memberCounterUuid
|
||||
&& (string) ($rx->queue_service_point_uuid ?? '') === (string) $memberCounterUuid;
|
||||
$rank = match (true) {
|
||||
$mine && $status === 'serving' => 0,
|
||||
$mine && $status === 'called' => 1,
|
||||
$status === 'waiting' || $status === '' => 2,
|
||||
default => 3,
|
||||
};
|
||||
|
||||
return sprintf('%d-%s', $rank, $rx->created_at?->format('Y-m-d H:i:s') ?? '');
|
||||
})->values();
|
||||
}
|
||||
|
||||
$drugs = \App\Models\Drug::owned($this->ownerRef($request))
|
||||
->where('organization_id', $organization->id)
|
||||
->where('is_active', true)
|
||||
@@ -80,9 +106,8 @@ class PrescriptionController extends Controller
|
||||
'drugs' => $drugs,
|
||||
'canDispense' => $canDispense,
|
||||
'branchId' => $branchId,
|
||||
'queueIntegration' => $branchId
|
||||
? $this->queueBridge->listMeta($organization, CareQueueContexts::PHARMACY, $branchId)
|
||||
: ['enabled' => false],
|
||||
'queueIntegration' => $queueIntegration,
|
||||
'memberCounterUuid' => $memberCounterUuid,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -99,7 +124,9 @@ class PrescriptionController extends Controller
|
||||
$result = $this->queueBridge->callNext($organization, CareQueueContexts::PHARMACY, $branchId, $member);
|
||||
$ticket = $result['ticket'] ?? null;
|
||||
if (! $ticket) {
|
||||
return back()->with('info', 'No prescriptions waiting at your pharmacy service point.');
|
||||
// Distinguish empty queue vs mid-dispense block via a follow-up check is hard over HTTP;
|
||||
// prefer a clear action message for pharmacists.
|
||||
return back()->with('info', 'No waiting patients — or finish the patient you are already serving before calling next.');
|
||||
}
|
||||
|
||||
return back()->with('success', 'Called '.$ticket['ticket_number'].'.');
|
||||
|
||||
Reference in New Issue
Block a user