Deploy Ladill Care / deploy (push) Successful in 53s
Remove the standalone Service Queues nav so call-next/now-serving lives on clinical queue, appointments, pharmacy, lab, and specialty surfaces; Pro orgs can activate dentistry and related modules with branch departments and queue stubs. Co-authored-by: Cursor <cursoragent@cursor.com>
81 lines
2.8 KiB
PHP
81 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Care;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
|
use App\Models\Appointment;
|
|
use App\Models\Department;
|
|
use App\Services\Care\OrganizationResolver;
|
|
use App\Services\Care\ServiceQueuePresenter;
|
|
use App\Services\Care\SpecialtyModuleService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class SpecialtyModuleController extends Controller
|
|
{
|
|
use ScopesToAccount;
|
|
|
|
public function show(
|
|
Request $request,
|
|
string $module,
|
|
SpecialtyModuleService $modules,
|
|
ServiceQueuePresenter $presenter,
|
|
): View {
|
|
$definition = $modules->definition($module);
|
|
abort_unless($definition, 404);
|
|
|
|
$organization = $this->organization($request);
|
|
abort_unless($modules->isEnabled($organization, $module), 404);
|
|
|
|
$roles = $definition['roles'] ?? [];
|
|
$member = $this->member($request);
|
|
if (is_array($roles) && $roles !== [] && $member && ! in_array($member->role, $roles, true)) {
|
|
abort(403);
|
|
}
|
|
|
|
$owner = $this->ownerRef($request);
|
|
$branchScope = app(OrganizationResolver::class)->branchScope($member);
|
|
|
|
$departments = Department::owned($owner)
|
|
->where('type', $definition['department_type'] ?? 'general')
|
|
->where('is_active', true)
|
|
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope))
|
|
->with('branch')
|
|
->orderBy('name')
|
|
->get();
|
|
|
|
$departmentIds = $departments->pluck('id')->all();
|
|
|
|
$waiting = Appointment::owned($owner)
|
|
->where('organization_id', $organization->id)
|
|
->whereIn('status', [Appointment::STATUS_WAITING, Appointment::STATUS_CHECKED_IN])
|
|
->when($departmentIds !== [], fn ($q) => $q->whereIn('department_id', $departmentIds))
|
|
->when($departmentIds === [], fn ($q) => $q->whereRaw('1 = 0'))
|
|
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope))
|
|
->with(['patient', 'practitioner', 'department'])
|
|
->orderBy('queue_position')
|
|
->orderBy('checked_in_at')
|
|
->limit(25)
|
|
->get();
|
|
|
|
$serviceQueuePanel = $presenter->panel(
|
|
$request,
|
|
$organization,
|
|
$member,
|
|
$module,
|
|
$request->input('counter_uuid'),
|
|
);
|
|
|
|
return view('care.specialty.show', [
|
|
'organization' => $organization,
|
|
'moduleKey' => $module,
|
|
'definition' => $definition,
|
|
'departments' => $departments,
|
|
'waiting' => $waiting,
|
|
'queueStubs' => $modules->queueStubsFor($organization, $module),
|
|
'serviceQueuePanel' => $serviceQueuePanel,
|
|
]);
|
|
}
|
|
}
|