diff --git a/app/Services/Care/AppointmentService.php b/app/Services/Care/AppointmentService.php index bfadcf0..78b20e4 100644 --- a/app/Services/Care/AppointmentService.php +++ b/app/Services/Care/AppointmentService.php @@ -161,10 +161,16 @@ class AppointmentService return true; } + $context = $this->queueBridge->contextForAppointment($organization, $appointment); + // Regular doctor Queue is consultation-only; specialty waiters belong on specialty modules. + if ($context !== CareQueueContexts::CONSULTATION) { + return false; + } + return $this->workflowGate->canRelease( $organization, $appointment->visit, - $this->queueBridge->contextForAppointment($organization, $appointment), + $context, ); }) ->values() diff --git a/app/Services/Care/DemoTenantSeeder.php b/app/Services/Care/DemoTenantSeeder.php index a8c5126..446e404 100644 --- a/app/Services/Care/DemoTenantSeeder.php +++ b/app/Services/Care/DemoTenantSeeder.php @@ -115,7 +115,8 @@ class DemoTenantSeeder $departments = $this->seedDepartments($branches, $ownerRef, $volumes); if (in_array($plan, ['pro', 'enterprise'], true)) { $this->seedSpecialtyModules($organization, $ownerRef); - $departments = $this->departmentsByBranch($branches, $ownerRef); + // Keep $departments as core/paid only. Specialty departments must not feed + // general GP desks or appointments — those waiters live in seedSpecialtyDemoData. } $practitioners = $this->seedPractitioners($organization, $branches, $departments, $ownerRef, $volumes); $this->linkStaffDoctorsToPractitioners($organization, $ownerRef, $plan, $branches, $practitioners); @@ -1085,9 +1086,14 @@ class DemoTenantSeeder for ($i = 0; $i < $volumes['appointments']; $i++) { $patient = $patients[$i % count($patients)]; $practitioner = $practitioners[$i % count($practitioners)]; - $branch = $branches[$i % count($branches)]; - $branchDepts = $departments[$branch->id] ?? []; - $department = $branchDepts[$i % max(1, count($branchDepts))] ?? null; + $branch = collect($branches)->first( + fn (Branch $b) => (int) $b->id === (int) $practitioner->branch_id, + ) ?? $branches[$i % count($branches)]; + $branchDepts = $departments[(int) $practitioner->branch_id] ?? ($departments[$branch->id] ?? []); + // Align department to the practitioner desk so Queue tickets stay consultation-context. + $department = collect($branchDepts)->first( + fn (Department $dept) => (int) $dept->id === (int) ($practitioner->department_id ?? 0), + ) ?? ($branchDepts[$i % max(1, count($branchDepts))] ?? null); $status = $statuses[$i % count($statuses)]; $scheduledAt = now()->subDays(14)->addHours($i * 3);