Add hero sections to Patients, Appointments, Queue, and admin index pages.
Deploy Ladill Care / deploy (push) Successful in 37s

Introduce shared x-care.page-hero with summary stats so key list views
match the Ladill app hero pattern used across Frontdesk and Link.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-05 22:57:54 +00:00
co-authored by Cursor
parent 527244948c
commit 0b6cad75a6
15 changed files with 512 additions and 304 deletions
@@ -38,11 +38,26 @@ class AppointmentController extends Controller
$practitioners = $this->activePractitioners($request, $organization->id);
$owner = $this->ownerRef($request);
$appointmentQuery = Appointment::owned($owner)
->where('organization_id', $organization->id)
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope));
$heroStats = [
'today' => (clone $appointmentQuery)->whereDate('scheduled_at', today())->count(),
'scheduled' => (clone $appointmentQuery)->where('status', Appointment::STATUS_SCHEDULED)->count(),
'waiting' => (clone $appointmentQuery)->whereIn('status', [
Appointment::STATUS_CHECKED_IN,
Appointment::STATUS_WAITING,
])->count(),
];
return view('care.appointments.index', [
'organization' => $organization,
'appointments' => $appointments,
'practitioners' => $practitioners,
'statuses' => config('care.appointment_statuses'),
'heroStats' => $heroStats,
]);
}
@@ -26,7 +26,13 @@ class BranchController extends Controller
->orderBy('name')
->get();
return view('care.admin.branches.index', compact('branches', 'organization'));
$heroStats = [
'total' => $branches->count(),
'active' => $branches->where('is_active', true)->count(),
'departments' => $branches->sum('departments_count'),
];
return view('care.admin.branches.index', compact('branches', 'organization', 'heroStats'));
}
public function create(Request $request): View
@@ -27,10 +27,17 @@ class DepartmentController extends Controller
->orderBy('name')
->get();
$heroStats = [
'total' => $departments->count(),
'active' => $departments->where('is_active', true)->count(),
'branches' => $departments->pluck('branch_id')->unique()->count(),
];
return view('care.admin.departments.index', [
'departments' => $departments,
'organization' => $organization,
'types' => config('care.department_types'),
'heroStats' => $heroStats,
]);
}
@@ -35,6 +35,16 @@ class DrugController extends Controller
$lowStock = $this->pharmacy->lowStock($this->ownerRef($request), $organization->id);
$expired = $this->pharmacy->expiredBatches($this->ownerRef($request), $organization->id);
$drugQuery = Drug::owned($this->ownerRef($request))
->where('organization_id', $organization->id)
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope));
$heroStats = [
'total' => (clone $drugQuery)->count(),
'low_stock' => $lowStock->count(),
'expired' => $expired->count(),
];
return view('care.pharmacy.drugs.index', [
'organization' => $organization,
'drugs' => $drugs,
@@ -42,6 +52,7 @@ class DrugController extends Controller
'expired' => $expired,
'canManage' => app(\App\Services\Care\CarePermissions::class)
->can($this->member($request), 'pharmacy.manage'),
'heroStats' => $heroStats,
]);
}
@@ -27,10 +27,19 @@ class MemberController extends Controller
->orderBy('created_at')
->get();
$clinicalRoles = ['doctor', 'nurse', 'lab_technician', 'pharmacist'];
$heroStats = [
'total' => $members->count(),
'clinical' => $members->whereIn('role', $clinicalRoles)->count(),
'branches' => $members->whereNotNull('branch_id')->pluck('branch_id')->unique()->count(),
];
return view('care.admin.members.index', [
'members' => $members,
'organization' => $organization,
'roles' => config('care.roles'),
'heroStats' => $heroStats,
]);
}
@@ -33,7 +33,18 @@ class PatientController extends Controller
$branchScope,
);
return view('care.patients.index', compact('patients', 'organization'));
$owner = $this->ownerRef($request);
$patientQuery = Patient::owned($owner)
->where('organization_id', $organization->id)
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope));
$heroStats = [
'total' => (clone $patientQuery)->count(),
'new_this_month' => (clone $patientQuery)->where('created_at', '>=', now()->startOfMonth())->count(),
'with_visits' => (clone $patientQuery)->whereHas('appointments')->count(),
];
return view('care.patients.index', compact('patients', 'organization', 'heroStats'));
}
public function create(Request $request): View
@@ -57,6 +57,16 @@ class QueueController extends Controller
$canConsult = app(\App\Services\Care\CarePermissions::class)
->can($this->member($request), 'consultations.manage');
$heroStats = [
'waiting' => $queue->count(),
'in_consultation' => $inConsultation->count(),
'today' => Appointment::owned($this->ownerRef($request))
->where('organization_id', $organization->id)
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
->whereDate('scheduled_at', today())
->count(),
];
return view('care.queue.index', [
'organization' => $organization,
'branches' => $branches,
@@ -71,6 +81,7 @@ class QueueController extends Controller
'inConsultation' => $inConsultation,
'canManageQueue' => $canManageQueue,
'canConsult' => $canConsult,
'heroStats' => $heroStats,
]);
}
@@ -1,22 +1,43 @@
<x-app-layout title="Branches">
<div class="flex items-center justify-between">
<h1 class="text-xl font-semibold text-slate-900">Branches</h1>
@if (app(\App\Services\Care\CarePermissions::class)->can(auth()->user() ? app(\App\Services\Care\OrganizationResolver::class)->memberFor(auth()->user(), $organization) : null, 'admin.branches.manage'))
<a href="{{ route('care.branches.create') }}" class="btn-primary">Add branch</a>
@endif
</div>
@php
$canManageBranches = app(\App\Services\Care\CarePermissions::class)->can(
auth()->user() ? app(\App\Services\Care\OrganizationResolver::class)->memberFor(auth()->user(), $organization) : null,
'admin.branches.manage'
);
@endphp
<div class="mt-4 space-y-3">
@forelse ($branches as $branch)
<div class="flex items-center justify-between rounded-2xl border border-slate-200 bg-white p-4">
<div>
<p class="font-medium text-slate-900">{{ $branch->name }}</p>
<p class="text-sm text-slate-500">{{ $branch->address ?? 'No address' }} · {{ $branch->departments_count }} department(s)</p>
</div>
<a href="{{ route('care.branches.edit', $branch) }}" class="text-sm text-slate-600 hover:text-slate-800">Edit</a>
<x-app-layout title="Branches">
<div class="space-y-6">
<x-care.page-hero
badge="Locations · Sites · Coverage"
title="Branches"
description="Organize clinic locations and sites so patients, departments, and staff stay scoped to the right branch."
:stats="[
['value' => number_format($heroStats['total']), 'label' => 'Branches'],
['value' => number_format($heroStats['active']), 'label' => 'Active'],
['value' => number_format($heroStats['departments']), 'label' => 'Departments'],
]">
@if ($canManageBranches)
<x-slot name="actions">
<a href="{{ route('care.branches.create') }}" class="btn-primary">Add branch</a>
</x-slot>
@endif
</x-care.page-hero>
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<div class="border-b border-slate-100 px-6 py-4">
<h2 class="text-sm font-semibold text-slate-900">All branches</h2>
</div>
@empty
<p class="text-sm text-slate-500">No branches yet.</p>
@endforelse
@forelse ($branches as $branch)
<div class="flex items-center justify-between border-b border-slate-50 px-6 py-4 last:border-b-0">
<div>
<p class="font-medium text-slate-900">{{ $branch->name }}</p>
<p class="text-sm text-slate-500">{{ $branch->address ?? 'No address' }} · {{ $branch->departments_count }} department(s)</p>
</div>
<a href="{{ route('care.branches.edit', $branch) }}" class="text-sm text-slate-600 hover:text-slate-800">Edit</a>
</div>
@empty
<p class="px-6 py-8 text-center text-sm text-slate-500">No branches yet.</p>
@endforelse
</div>
</div>
</x-app-layout>
@@ -1,28 +1,39 @@
<x-app-layout title="Departments">
<div class="flex items-center justify-between">
<h1 class="text-xl font-semibold text-slate-900">Departments</h1>
<a href="{{ route('care.departments.create') }}" class="btn-primary">Add department</a>
</div>
<div class="space-y-6">
<x-care.page-hero
badge="Outpatient · Lab · Pharmacy · More"
title="Departments"
description="Define clinical and support departments within each branch to organize care delivery and staffing."
:stats="[
['value' => number_format($heroStats['total']), 'label' => 'Departments'],
['value' => number_format($heroStats['active']), 'label' => 'Active'],
['value' => number_format($heroStats['branches']), 'label' => 'Branches'],
]">
<x-slot name="actions">
<a href="{{ route('care.departments.create') }}" class="btn-primary">Add department</a>
</x-slot>
</x-care.page-hero>
<div class="mt-4 overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
<tr><th class="px-4 py-3">Name</th><th class="px-4 py-3">Type</th><th class="px-4 py-3">Branch</th><th class="px-4 py-3"></th></tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse ($departments as $department)
<tr>
<td class="px-4 py-3 font-medium">{{ $department->name }}</td>
<td class="px-4 py-3">{{ $types[$department->type] ?? $department->type }}</td>
<td class="px-4 py-3">{{ $department->branch?->name }}</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('care.departments.edit', $department) }}" class="text-sky-600">Edit</a>
</td>
</tr>
@empty
<tr><td colspan="4" class="px-4 py-6 text-center text-slate-500">No departments yet.</td></tr>
@endforelse
</tbody>
</table>
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
<tr><th class="px-4 py-3">Name</th><th class="px-4 py-3">Type</th><th class="px-4 py-3">Branch</th><th class="px-4 py-3"></th></tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse ($departments as $department)
<tr>
<td class="px-4 py-3 font-medium">{{ $department->name }}</td>
<td class="px-4 py-3">{{ $types[$department->type] ?? $department->type }}</td>
<td class="px-4 py-3">{{ $department->branch?->name }}</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('care.departments.edit', $department) }}" class="text-sky-600">Edit</a>
</td>
</tr>
@empty
<tr><td colspan="4" class="px-4 py-6 text-center text-slate-500">No departments yet.</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
</x-app-layout>
@@ -1,36 +1,47 @@
<x-app-layout title="Team members">
<div class="flex items-center justify-between">
<h1 class="text-xl font-semibold text-slate-900">Team members</h1>
<a href="{{ route('care.members.create') }}" class="btn-primary">Add member</a>
</div>
<div class="space-y-6">
<x-care.page-hero
badge="Roles · Access · Branch assignment"
title="Team"
description="Manage who can access Care, their roles, and which branch each member belongs to."
:stats="[
['value' => number_format($heroStats['total']), 'label' => 'Members'],
['value' => number_format($heroStats['clinical']), 'label' => 'Clinical staff'],
['value' => number_format($heroStats['branches']), 'label' => 'Branches staffed'],
]">
<x-slot name="actions">
<a href="{{ route('care.members.create') }}" class="btn-primary">Add member</a>
</x-slot>
</x-care.page-hero>
<div class="mt-4 overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
<tr><th class="px-4 py-3">Member</th><th class="px-4 py-3">Role</th><th class="px-4 py-3">Branch</th><th class="px-4 py-3"></th></tr>
</thead>
<tbody class="divide-y divide-slate-50">
@foreach ($members as $member)
@php
$display = str_contains($member->user_ref, '@')
? $member->user_ref
: (\App\Models\User::where('public_id', $member->user_ref)->value('email') ?? $member->user_ref);
@endphp
<tr>
<td class="px-4 py-3 text-sm">{{ $display }}</td>
<td class="px-4 py-3">{{ $roles[$member->role] ?? $member->role }}</td>
<td class="px-4 py-3">{{ $member->branch?->name ?? 'All branches' }}</td>
<td class="px-4 py-3 text-right">
@if ($member->user_ref !== auth()->user()->public_id)
<form method="POST" action="{{ route('care.members.destroy', $member) }}" class="inline" onsubmit="return confirm('Remove this member?')">
@csrf @method('DELETE')
<button type="submit" class="text-red-600">Remove</button>
</form>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
<tr><th class="px-4 py-3">Member</th><th class="px-4 py-3">Role</th><th class="px-4 py-3">Branch</th><th class="px-4 py-3"></th></tr>
</thead>
<tbody class="divide-y divide-slate-50">
@foreach ($members as $member)
@php
$display = str_contains($member->user_ref, '@')
? $member->user_ref
: (\App\Models\User::where('public_id', $member->user_ref)->value('email') ?? $member->user_ref);
@endphp
<tr>
<td class="px-4 py-3 text-sm">{{ $display }}</td>
<td class="px-4 py-3">{{ $roles[$member->role] ?? $member->role }}</td>
<td class="px-4 py-3">{{ $member->branch?->name ?? 'All branches' }}</td>
<td class="px-4 py-3 text-right">
@if ($member->user_ref !== auth()->user()->public_id)
<form method="POST" action="{{ route('care.members.destroy', $member) }}" class="inline" onsubmit="return confirm('Remove this member?')">
@csrf @method('DELETE')
<button type="submit" class="text-red-600">Remove</button>
</form>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</x-app-layout>
@@ -1,76 +1,89 @@
@php
$canManageAppointments = app(\App\Services\Care\CarePermissions::class)->can(
auth()->user() ? app(\App\Services\Care\OrganizationResolver::class)->memberFor(auth()->user(), $organization) : null,
'appointments.manage'
);
@endphp
<x-app-layout title="Appointments">
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div>
<h1 class="text-xl font-semibold text-slate-900">Appointments</h1>
<p class="mt-1 text-sm text-slate-500">Schedule and manage patient appointments</p>
<div class="space-y-6">
<x-care.page-hero
badge="Schedule · Walk-ins · Check-in"
title="Appointments"
description="Schedule visits, register walk-ins, and track patient flow from booking through consultation."
:stats="[
['value' => number_format($heroStats['today']), 'label' => 'Today'],
['value' => number_format($heroStats['scheduled']), 'label' => 'Scheduled'],
['value' => number_format($heroStats['waiting']), 'label' => 'Waiting'],
]">
@if ($canManageAppointments)
<x-slot name="actions">
<a href="{{ route('care.appointments.walk-in.create') }}" class="btn-secondary">Walk-in</a>
<a href="{{ route('care.appointments.create') }}" class="btn-primary">Book appointment</a>
</x-slot>
@endif
</x-care.page-hero>
<form method="GET" class="flex flex-wrap gap-3 rounded-2xl border border-slate-200 bg-white p-4">
<input type="date" name="date" value="{{ request('date') }}" class="rounded-lg border-slate-300 text-sm">
<select name="status" class="rounded-lg border-slate-300 text-sm">
<option value="">All statuses</option>
@foreach ($statuses as $value => $label)
<option value="{{ $value }}" @selected(request('status') === $value)>{{ $label }}</option>
@endforeach
</select>
<select name="practitioner_id" class="rounded-lg border-slate-300 text-sm">
<option value="">All practitioners</option>
@foreach ($practitioners as $practitioner)
<option value="{{ $practitioner->id }}" @selected((string) request('practitioner_id') === (string) $practitioner->id)>{{ $practitioner->name }}</option>
@endforeach
</select>
<button type="submit" class="btn-primary">Filter</button>
@if (request()->hasAny(['date', 'status', 'practitioner_id']))
<a href="{{ route('care.appointments.index') }}" class="rounded-lg border border-slate-200 px-4 py-2 text-sm text-slate-600">Clear</a>
@endif
</form>
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
<tr>
<th class="px-4 py-3">Patient</th>
<th class="px-4 py-3">Scheduled</th>
<th class="px-4 py-3">Practitioner</th>
<th class="px-4 py-3">Type</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse ($appointments as $appointment)
<tr>
<td class="px-4 py-3">
<p class="font-medium text-slate-900">{{ $appointment->patient->fullName() }}</p>
<p class="text-xs text-slate-500">{{ $appointment->patient->patient_number }}</p>
</td>
<td class="px-4 py-3">{{ $appointment->scheduled_at?->format('d M Y H:i') ?? '—' }}</td>
<td class="px-4 py-3">{{ $appointment->practitioner?->name ?? '—' }}</td>
<td class="px-4 py-3 capitalize">{{ str_replace('_', ' ', $appointment->type) }}</td>
<td class="px-4 py-3">
<span class="rounded-full bg-slate-100 px-2 py-0.5 text-xs font-medium text-slate-700">
{{ $statuses[$appointment->status] ?? $appointment->status }}
</span>
</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('care.appointments.show', $appointment) }}" class="text-sky-600 hover:text-sky-700">View</a>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-4 py-8 text-center text-slate-500">No appointments found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if (app(\App\Services\Care\CarePermissions::class)->can(auth()->user() ? app(\App\Services\Care\OrganizationResolver::class)->memberFor(auth()->user(), $organization) : null, 'appointments.manage'))
<div class="flex gap-2">
<a href="{{ route('care.appointments.walk-in.create') }}" class="rounded-lg border border-slate-200 bg-white px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Walk-in</a>
<a href="{{ route('care.appointments.create') }}" class="btn-primary">Book appointment</a>
</div>
@endif
<div>{{ $appointments->links() }}</div>
</div>
<form method="GET" class="mt-4 flex flex-wrap gap-3 rounded-2xl border border-slate-200 bg-white p-4">
<input type="date" name="date" value="{{ request('date') }}" class="rounded-lg border-slate-300 text-sm">
<select name="status" class="rounded-lg border-slate-300 text-sm">
<option value="">All statuses</option>
@foreach ($statuses as $value => $label)
<option value="{{ $value }}" @selected(request('status') === $value)>{{ $label }}</option>
@endforeach
</select>
<select name="practitioner_id" class="rounded-lg border-slate-300 text-sm">
<option value="">All practitioners</option>
@foreach ($practitioners as $practitioner)
<option value="{{ $practitioner->id }}" @selected((string) request('practitioner_id') === (string) $practitioner->id)>{{ $practitioner->name }}</option>
@endforeach
</select>
<button type="submit" class="btn-primary">Filter</button>
@if (request()->hasAny(['date', 'status', 'practitioner_id']))
<a href="{{ route('care.appointments.index') }}" class="rounded-lg border border-slate-200 px-4 py-2 text-sm text-slate-600">Clear</a>
@endif
</form>
<div class="mt-4 overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
<tr>
<th class="px-4 py-3">Patient</th>
<th class="px-4 py-3">Scheduled</th>
<th class="px-4 py-3">Practitioner</th>
<th class="px-4 py-3">Type</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse ($appointments as $appointment)
<tr>
<td class="px-4 py-3">
<p class="font-medium text-slate-900">{{ $appointment->patient->fullName() }}</p>
<p class="text-xs text-slate-500">{{ $appointment->patient->patient_number }}</p>
</td>
<td class="px-4 py-3">{{ $appointment->scheduled_at?->format('d M Y H:i') ?? '—' }}</td>
<td class="px-4 py-3">{{ $appointment->practitioner?->name ?? '—' }}</td>
<td class="px-4 py-3 capitalize">{{ str_replace('_', ' ', $appointment->type) }}</td>
<td class="px-4 py-3">
<span class="rounded-full bg-slate-100 px-2 py-0.5 text-xs font-medium text-slate-700">
{{ $statuses[$appointment->status] ?? $appointment->status }}
</span>
</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('care.appointments.show', $appointment) }}" class="text-sky-600 hover:text-sky-700">View</a>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-4 py-8 text-center text-slate-500">No appointments found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-4">{{ $appointments->links() }}</div>
</x-app-layout>
+73 -58
View File
@@ -1,62 +1,77 @@
@php
$canManagePatients = app(\App\Services\Care\CarePermissions::class)->can(
auth()->user() ? app(\App\Services\Care\OrganizationResolver::class)->memberFor(auth()->user(), $organization) : null,
'patients.manage'
);
@endphp
<x-app-layout title="Patients">
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div>
<h1 class="text-xl font-semibold text-slate-900">Patients</h1>
<p class="mt-1 text-sm text-slate-500">Search and manage patient records</p>
<div class="space-y-6">
<x-care.page-hero
badge="Records · Search · Registration"
title="Patients"
description="Search and manage patient records, demographics, and visit history across your branches."
:stats="[
['value' => number_format($heroStats['total']), 'label' => 'Patients'],
['value' => number_format($heroStats['new_this_month']), 'label' => 'New this month'],
['value' => number_format($heroStats['with_visits']), 'label' => 'With visits'],
]">
@if ($canManagePatients)
<x-slot name="actions">
<a href="{{ route('care.patients.create') }}" class="btn-primary">Register patient</a>
</x-slot>
@endif
</x-care.page-hero>
<form method="GET" class="flex flex-wrap gap-3 rounded-2xl border border-slate-200 bg-white p-4">
<input type="search" name="q" value="{{ request('q') }}" placeholder="Name, phone, patient ID, national ID…"
class="min-w-[200px] flex-1 rounded-lg border-slate-300 text-sm">
<input type="date" name="date_of_birth" value="{{ request('date_of_birth') }}"
class="rounded-lg border-slate-300 text-sm" title="Date of birth">
<button type="submit" class="btn-primary">Search</button>
@if (request()->hasAny(['q', 'date_of_birth', 'phone', 'national_id', 'patient_number']))
<a href="{{ route('care.patients.index') }}" class="rounded-lg border border-slate-200 px-4 py-2 text-sm text-slate-600">Clear</a>
@endif
</form>
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
<tr>
<th class="px-4 py-3">Patient</th>
<th class="px-4 py-3">Patient ID</th>
<th class="px-4 py-3">Phone</th>
<th class="px-4 py-3">DOB</th>
<th class="px-4 py-3">Branch</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse ($patients as $patient)
<tr>
<td class="px-4 py-3">
<p class="font-medium text-slate-900">{{ $patient->fullName() }}</p>
@if ($patient->national_id)
<p class="text-xs text-slate-500">NID: {{ $patient->national_id }}</p>
@endif
</td>
<td class="px-4 py-3 font-mono text-xs">{{ $patient->patient_number }}</td>
<td class="px-4 py-3">{{ $patient->phone ?? '—' }}</td>
<td class="px-4 py-3">{{ $patient->date_of_birth?->format('Y-m-d') ?? '—' }}</td>
<td class="px-4 py-3">{{ $patient->branch?->name ?? '—' }}</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('care.patients.show', $patient) }}" class="text-sky-600 hover:text-sky-700">View</a>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-4 py-8 text-center text-slate-500">No patients found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@if (app(\App\Services\Care\CarePermissions::class)->can(auth()->user() ? app(\App\Services\Care\OrganizationResolver::class)->memberFor(auth()->user(), $organization) : null, 'patients.manage'))
<a href="{{ route('care.patients.create') }}" class="btn-primary">Register patient</a>
@endif
<div>{{ $patients->links() }}</div>
</div>
<form method="GET" class="mt-4 flex flex-wrap gap-3 rounded-2xl border border-slate-200 bg-white p-4">
<input type="search" name="q" value="{{ request('q') }}" placeholder="Name, phone, patient ID, national ID…"
class="min-w-[200px] flex-1 rounded-lg border-slate-300 text-sm">
<input type="date" name="date_of_birth" value="{{ request('date_of_birth') }}"
class="rounded-lg border-slate-300 text-sm" title="Date of birth">
<button type="submit" class="btn-primary">Search</button>
@if (request()->hasAny(['q', 'date_of_birth', 'phone', 'national_id', 'patient_number']))
<a href="{{ route('care.patients.index') }}" class="rounded-lg border border-slate-200 px-4 py-2 text-sm text-slate-600">Clear</a>
@endif
</form>
<div class="mt-4 overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500">
<tr>
<th class="px-4 py-3">Patient</th>
<th class="px-4 py-3">Patient ID</th>
<th class="px-4 py-3">Phone</th>
<th class="px-4 py-3">DOB</th>
<th class="px-4 py-3">Branch</th>
<th class="px-4 py-3"></th>
</tr>
</thead>
<tbody class="divide-y divide-slate-50">
@forelse ($patients as $patient)
<tr>
<td class="px-4 py-3">
<p class="font-medium text-slate-900">{{ $patient->fullName() }}</p>
@if ($patient->national_id)
<p class="text-xs text-slate-500">NID: {{ $patient->national_id }}</p>
@endif
</td>
<td class="px-4 py-3 font-mono text-xs">{{ $patient->patient_number }}</td>
<td class="px-4 py-3">{{ $patient->phone ?? '—' }}</td>
<td class="px-4 py-3">{{ $patient->date_of_birth?->format('Y-m-d') ?? '—' }}</td>
<td class="px-4 py-3">{{ $patient->branch?->name ?? '—' }}</td>
<td class="px-4 py-3 text-right">
<a href="{{ route('care.patients.show', $patient) }}" class="text-sky-600 hover:text-sky-700">View</a>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-4 py-8 text-center text-slate-500">No patients found.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-4">{{ $patients->links() }}</div>
</x-app-layout>
@@ -1,32 +1,52 @@
@php $money = fn ($minor) => config('care.billing.currency').' '.number_format($minor / 100, 2); @endphp
<x-app-layout title="Drug inventory">
<div class="flex items-center justify-between">
<h1 class="text-xl font-semibold text-slate-900">Drug inventory</h1>
@if ($canManage)<a href="{{ route('care.pharmacy.drugs.create') }}" class="btn-primary">Add drug</a>@endif
<div class="space-y-6">
<x-care.page-hero
badge="Pharmacy · Stock · Reorder alerts"
title="Inventory"
description="Track drug stock levels, unit pricing, and batches — with alerts when items run low or expire."
:stats="[
['value' => number_format($heroStats['total']), 'label' => 'Drugs'],
['value' => number_format($heroStats['low_stock']), 'label' => 'Low stock'],
['value' => number_format($heroStats['expired']), 'label' => 'Expired batches'],
]">
@if ($canManage)
<x-slot name="actions">
<a href="{{ route('care.pharmacy.drugs.create') }}" class="btn-primary">Add drug</a>
</x-slot>
@endif
</x-care.page-hero>
@if ($lowStock->isNotEmpty())
<div class="rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900">{{ $lowStock->count() }} drug(s) below reorder level.</div>
@endif
@if ($expired->isNotEmpty())
<div class="rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-900">{{ $expired->count() }} expired batch(es) with stock on hand.</div>
@endif
<form method="GET" class="rounded-2xl border border-slate-200 bg-white p-4">
<input type="search" name="q" value="{{ request('q') }}" placeholder="Search drugs…" class="w-full rounded-lg border-slate-300 text-sm sm:max-w-md">
</form>
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500"><tr><th class="px-4 py-3">Drug</th><th class="px-4 py-3">Stock</th><th class="px-4 py-3">Unit price</th><th></th></tr></thead>
<tbody class="divide-y divide-slate-50">
@forelse ($drugs as $drug)
<tr>
<td class="px-4 py-3"><p class="font-medium">{{ $drug->name }}</p>@if($drug->generic_name)<p class="text-xs text-slate-500">{{ $drug->generic_name }}</p>@endif</td>
<td class="px-4 py-3 {{ $drug->stockOnHand() <= $drug->reorder_level ? 'text-amber-700 font-medium' : '' }}">{{ $drug->stockOnHand() }} {{ $drug->unit }}</td>
<td class="px-4 py-3">{{ $money($drug->unit_price_minor) }}</td>
<td class="px-4 py-3 text-right"><a href="{{ route('care.pharmacy.drugs.show', $drug) }}" class="text-sky-600">View</a></td>
</tr>
@empty
<tr><td colspan="4" class="px-4 py-8 text-center text-slate-500">No drugs in inventory.</td></tr>
@endforelse
</tbody>
</table>
</div>
<div>{{ $drugs->links() }}</div>
</div>
@if ($lowStock->isNotEmpty())
<div class="mt-4 rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900">{{ $lowStock->count() }} drug(s) below reorder level.</div>
@endif
@if ($expired->isNotEmpty())
<div class="mt-4 rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-900">{{ $expired->count() }} expired batch(es) with stock on hand.</div>
@endif
<form method="GET" class="mt-4"><input type="search" name="q" value="{{ request('q') }}" placeholder="Search drugs…" class="rounded-lg border-slate-300 text-sm"></form>
<div class="mt-4 overflow-hidden rounded-2xl border border-slate-200 bg-white">
<table class="min-w-full text-sm">
<thead class="bg-slate-50 text-left text-xs uppercase text-slate-500"><tr><th class="px-4 py-3">Drug</th><th class="px-4 py-3">Stock</th><th class="px-4 py-3">Unit price</th><th></th></tr></thead>
<tbody class="divide-y divide-slate-50">
@forelse ($drugs as $drug)
<tr>
<td class="px-4 py-3"><p class="font-medium">{{ $drug->name }}</p>@if($drug->generic_name)<p class="text-xs text-slate-500">{{ $drug->generic_name }}</p>@endif</td>
<td class="px-4 py-3 {{ $drug->stockOnHand() <= $drug->reorder_level ? 'text-amber-700 font-medium' : '' }}">{{ $drug->stockOnHand() }} {{ $drug->unit }}</td>
<td class="px-4 py-3">{{ $money($drug->unit_price_minor) }}</td>
<td class="px-4 py-3 text-right"><a href="{{ route('care.pharmacy.drugs.show', $drug) }}" class="text-sky-600">View</a></td>
</tr>
@empty
<tr><td colspan="4" class="px-4 py-8 text-center text-slate-500">No drugs in inventory.</td></tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-4">{{ $drugs->links() }}</div>
</x-app-layout>
+78 -70
View File
@@ -1,74 +1,82 @@
<x-app-layout title="Queue">
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div>
<h1 class="text-xl font-semibold text-slate-900">Patient queue</h1>
<p class="mt-1 text-sm text-slate-500">Waiting patients and active consultations</p>
<div class="space-y-6">
<x-care.page-hero
badge="Waiting room · Consultations · Walk-ins"
title="Patient queue"
description="See who is waiting, start consultations, and keep patient flow moving across your branch."
:stats="[
['value' => number_format($heroStats['waiting']), 'label' => 'Waiting'],
['value' => number_format($heroStats['in_consultation']), 'label' => 'In consultation'],
['value' => number_format($heroStats['today']), 'label' => 'Today'],
]">
@if ($canManageQueue)
<x-slot name="actions">
<a href="{{ route('care.appointments.walk-in.create') }}" class="btn-primary">Walk-in</a>
</x-slot>
@endif
</x-care.page-hero>
<form method="GET" class="flex flex-wrap gap-3 rounded-2xl border border-slate-200 bg-white p-4">
<select name="branch_id" class="rounded-lg border-slate-300 text-sm" onchange="this.form.submit()">
@foreach ($branches as $branch)
<option value="{{ $branch->id }}" @selected($branchId == $branch->id)>{{ $branch->name }}</option>
@endforeach
</select>
<select name="practitioner_id" class="rounded-lg border-slate-300 text-sm">
<option value="">All practitioners</option>
@foreach ($practitioners as $practitioner)
<option value="{{ $practitioner->id }}" @selected($practitionerId == $practitioner->id)>{{ $practitioner->name }}</option>
@endforeach
</select>
<button type="submit" class="btn-primary">Filter</button>
</form>
<div class="grid gap-6 lg:grid-cols-2">
<section class="rounded-2xl border border-slate-200 bg-white p-6">
<h2 class="text-sm font-semibold uppercase tracking-wide text-slate-500">Waiting ({{ $queue->count() }})</h2>
<div class="mt-4 space-y-3">
@forelse ($queue as $appointment)
<div class="flex items-center justify-between rounded-xl border border-slate-100 bg-slate-50 p-4">
<div>
<p class="font-medium text-slate-900">
@if ($appointment->queue_position)
<span class="mr-2 inline-flex h-6 w-6 items-center justify-center rounded-full bg-sky-100 text-xs font-bold text-sky-700">{{ $appointment->queue_position }}</span>
@endif
{{ $appointment->patient->fullName() }}
</p>
<p class="text-xs text-slate-500">{{ $appointment->patient->patient_number }} · {{ $appointment->reason ?? '—' }}</p>
</div>
@if ($canConsult)
<form method="POST" action="{{ route('care.queue.start', $appointment) }}">
@csrf
<button type="submit" class="rounded-lg bg-sky-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-sky-700">Start</button>
</form>
@endif
</div>
@empty
<p class="text-sm text-slate-500">No patients waiting.</p>
@endforelse
</div>
</section>
<section class="rounded-2xl border border-slate-200 bg-white p-6">
<h2 class="text-sm font-semibold uppercase tracking-wide text-slate-500">In consultation ({{ $inConsultation->count() }})</h2>
<div class="mt-4 space-y-3">
@forelse ($inConsultation as $appointment)
<div class="flex items-center justify-between rounded-xl border border-emerald-100 bg-emerald-50 p-4">
<div>
<p class="font-medium text-slate-900">{{ $appointment->patient->fullName() }}</p>
<p class="text-xs text-slate-500">{{ $appointment->practitioner?->name ?? 'Unassigned' }}</p>
</div>
@if ($appointment->consultation)
<a href="{{ route('care.consultations.show', $appointment->consultation) }}" class="text-sm text-sky-600 hover:text-sky-700">Open</a>
@endif
</div>
@empty
<p class="text-sm text-slate-500">No active consultations.</p>
@endforelse
</div>
</section>
</div>
@if ($canManageQueue)
<a href="{{ route('care.appointments.walk-in.create') }}" class="btn-primary">Walk-in</a>
@endif
</div>
<form method="GET" class="mt-4 flex flex-wrap gap-3 rounded-2xl border border-slate-200 bg-white p-4">
<select name="branch_id" class="rounded-lg border-slate-300 text-sm" onchange="this.form.submit()">
@foreach ($branches as $branch)
<option value="{{ $branch->id }}" @selected($branchId == $branch->id)>{{ $branch->name }}</option>
@endforeach
</select>
<select name="practitioner_id" class="rounded-lg border-slate-300 text-sm">
<option value="">All practitioners</option>
@foreach ($practitioners as $practitioner)
<option value="{{ $practitioner->id }}" @selected($practitionerId == $practitioner->id)>{{ $practitioner->name }}</option>
@endforeach
</select>
<button type="submit" class="btn-primary">Filter</button>
</form>
<div class="mt-6 grid gap-6 lg:grid-cols-2">
<section class="rounded-2xl border border-slate-200 bg-white p-6">
<h2 class="text-sm font-semibold uppercase tracking-wide text-slate-500">Waiting ({{ $queue->count() }})</h2>
<div class="mt-4 space-y-3">
@forelse ($queue as $appointment)
<div class="flex items-center justify-between rounded-xl border border-slate-100 bg-slate-50 p-4">
<div>
<p class="font-medium text-slate-900">
@if ($appointment->queue_position)
<span class="mr-2 inline-flex h-6 w-6 items-center justify-center rounded-full bg-sky-100 text-xs font-bold text-sky-700">{{ $appointment->queue_position }}</span>
@endif
{{ $appointment->patient->fullName() }}
</p>
<p class="text-xs text-slate-500">{{ $appointment->patient->patient_number }} · {{ $appointment->reason ?? '—' }}</p>
</div>
@if ($canConsult)
<form method="POST" action="{{ route('care.queue.start', $appointment) }}">
@csrf
<button type="submit" class="rounded-lg bg-sky-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-sky-700">Start</button>
</form>
@endif
</div>
@empty
<p class="text-sm text-slate-500">No patients waiting.</p>
@endforelse
</div>
</section>
<section class="rounded-2xl border border-slate-200 bg-white p-6">
<h2 class="text-sm font-semibold uppercase tracking-wide text-slate-500">In consultation ({{ $inConsultation->count() }})</h2>
<div class="mt-4 space-y-3">
@forelse ($inConsultation as $appointment)
<div class="flex items-center justify-between rounded-xl border border-emerald-100 bg-emerald-50 p-4">
<div>
<p class="font-medium text-slate-900">{{ $appointment->patient->fullName() }}</p>
<p class="text-xs text-slate-500">{{ $appointment->practitioner?->name ?? 'Unassigned' }}</p>
</div>
@if ($appointment->consultation)
<a href="{{ route('care.consultations.show', $appointment->consultation) }}" class="text-sm text-sky-600 hover:text-sky-700">Open</a>
@endif
</div>
@empty
<p class="text-sm text-slate-500">No active consultations.</p>
@endforelse
</div>
</section>
</div>
</x-app-layout>
@@ -0,0 +1,39 @@
@props([
'badge',
'title',
'description' => null,
'stats' => [],
])
<div {{ $attributes->merge(['class' => 'relative overflow-hidden rounded-2xl border border-slate-200 bg-white']) }}>
<div class="absolute inset-0 bg-gradient-to-br from-indigo-50/80 via-white to-violet-50/60"></div>
<div class="relative px-6 py-8 sm:px-10">
<div class="flex flex-col gap-6 lg:flex-row lg:items-center lg:justify-between">
<div class="max-w-xl">
<div class="inline-flex items-center gap-1.5 rounded-full bg-indigo-100 px-3 py-1 text-xs font-semibold text-indigo-700">
{{ $badge }}
</div>
<h1 class="mt-3 text-2xl font-bold tracking-tight text-slate-900 sm:text-3xl">{{ $title }}</h1>
@if ($description)
<p class="mt-2 text-sm leading-6 text-slate-600">{{ $description }}</p>
@endif
@isset($actions)
<div class="mt-6 flex flex-wrap items-center gap-2">
{{ $actions }}
</div>
@endisset
</div>
@if (count($stats) > 0)
<div class="scrollbar-hide flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 sm:grid sm:grid-cols-3 sm:overflow-visible sm:pb-0 lg:gap-4" style="-ms-overflow-style:none;scrollbar-width:none;">
@foreach ($stats as $stat)
<div class="mobile-stats-card shrink-0 snap-start rounded-xl border border-slate-200 bg-white/90 px-4 py-3 text-center backdrop-blur-sm">
<p class="whitespace-nowrap text-xl font-bold text-slate-900 sm:text-2xl">{{ $stat['value'] }}</p>
<p class="mt-0.5 whitespace-nowrap text-[11px] font-medium text-slate-500">{{ $stat['label'] }}</p>
</div>
@endforeach
</div>
@endif
</div>
</div>
</div>