Make admin Patients, Appointments, Inventory, Billing, and Reports data-driven.
Deploy Ladill Care / deploy (push) Successful in 44s
Deploy Ladill Care / deploy (push) Successful in 44s
Facility admins see analytics overviews instead of operational directories; floor roles keep list UIs, with optional ?view=list for admins who need records. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\Department;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Patient;
|
||||
use App\Models\Practitioner;
|
||||
use App\Services\Care\AdminOverviewService;
|
||||
use App\Services\Care\AppointmentService;
|
||||
use App\Services\Care\CareFeatures;
|
||||
use App\Services\Care\CarePermissions;
|
||||
@@ -27,6 +28,7 @@ class AppointmentController extends Controller
|
||||
|
||||
public function __construct(
|
||||
protected AppointmentService $appointments,
|
||||
protected AdminOverviewService $adminOverview,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): View
|
||||
@@ -37,6 +39,20 @@ class AppointmentController extends Controller
|
||||
$resolver = app(OrganizationResolver::class);
|
||||
$branchScope = $resolver->branchScope($member);
|
||||
$practitionerScope = $resolver->practitionerScope($organization, $member);
|
||||
$permissions = app(CarePermissions::class);
|
||||
|
||||
if ($permissions->isAdmin($member) && $request->query('view') !== 'list') {
|
||||
return view('care.admin.analytics', [
|
||||
'title' => 'Appointments',
|
||||
'badge' => 'Analytics · Throughput',
|
||||
'description' => 'Scheduling, waiting, and completion rates across the facility.',
|
||||
'adminOverview' => $this->adminOverview->appointments(
|
||||
$organization,
|
||||
$this->ownerRef($request),
|
||||
$branchScope,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
$filters = $request->only(['status', 'practitioner_id', 'date', 'patient_id']);
|
||||
if ($practitionerScope !== null) {
|
||||
|
||||
@@ -7,8 +7,10 @@ use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
||||
use App\Models\Bill;
|
||||
use App\Models\Consultation;
|
||||
use App\Models\Visit;
|
||||
use App\Services\Care\AdminOverviewService;
|
||||
use App\Services\Care\BillService;
|
||||
use App\Services\Care\BranchContext;
|
||||
use App\Services\Care\CarePermissions;
|
||||
use App\Services\Care\CareQueueBridge;
|
||||
use App\Services\Care\CareQueueContexts;
|
||||
use App\Services\Care\ConsultationReturnContext;
|
||||
@@ -28,6 +30,7 @@ class BillController extends Controller
|
||||
protected MerchantGatewayService $gateway,
|
||||
protected CareQueueBridge $queueBridge,
|
||||
protected BranchContext $branchContext,
|
||||
protected AdminOverviewService $adminOverview,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): View
|
||||
@@ -35,9 +38,23 @@ class BillController extends Controller
|
||||
$this->authorizeAbility($request, 'bills.view');
|
||||
$organization = $this->organization($request);
|
||||
$member = $this->member($request);
|
||||
$permissions = app(CarePermissions::class);
|
||||
$branches = $this->branchContext->branches($request, $organization, $member);
|
||||
$branchId = $this->branchContext->resolve($request, $organization, $member);
|
||||
|
||||
if ($permissions->isAdmin($member) && $request->query('view') !== 'list') {
|
||||
return view('care.admin.analytics', [
|
||||
'title' => 'Billing',
|
||||
'badge' => 'Analytics · Revenue',
|
||||
'description' => 'Collections, outstanding balances, and invoice throughput — not a cashier queue.',
|
||||
'adminOverview' => $this->adminOverview->billing(
|
||||
$organization,
|
||||
$this->ownerRef($request),
|
||||
$branchId > 0 ? $branchId : null,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
$bills = $this->bills->list(
|
||||
$this->ownerRef($request),
|
||||
$organization->id,
|
||||
@@ -52,11 +69,11 @@ class BillController extends Controller
|
||||
'branches' => $branches,
|
||||
'branchId' => $branchId,
|
||||
'canSwitchBranch' => $this->branchContext->canSwitch($member),
|
||||
'queueIntegration' => $branchId
|
||||
'queueIntegration' => $branchId && $permissions->handlesFloorCare($member)
|
||||
? $this->queueBridge->listMeta($organization, CareQueueContexts::BILLING, $branchId)
|
||||
: ['enabled' => false],
|
||||
'canManageQueue' => app(\App\Services\Care\CarePermissions::class)
|
||||
->can($member, 'service_queues.console'),
|
||||
'canManageQueue' => $permissions->can($member, 'service_queues.console')
|
||||
&& $permissions->handlesFloorCare($member),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace App\Http\Controllers\Care;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
||||
use App\Models\Drug;
|
||||
use App\Services\Care\AdminOverviewService;
|
||||
use App\Services\Care\CarePermissions;
|
||||
use App\Services\Care\OrganizationResolver;
|
||||
use App\Services\Care\PharmacyService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -17,13 +19,29 @@ class DrugController extends Controller
|
||||
|
||||
public function __construct(
|
||||
protected PharmacyService $pharmacy,
|
||||
protected AdminOverviewService $adminOverview,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$this->authorizeAbility($request, 'pharmacy.view');
|
||||
$organization = $this->organization($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($this->member($request));
|
||||
$member = $this->member($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($member);
|
||||
$permissions = app(CarePermissions::class);
|
||||
|
||||
if ($permissions->isAdmin($member) && $request->query('view') !== 'list') {
|
||||
return view('care.admin.analytics', [
|
||||
'title' => 'Inventory',
|
||||
'badge' => 'Analytics · Stock health',
|
||||
'description' => 'Stock value, reorder risk, and expiry exposure across the pharmacy catalog.',
|
||||
'adminOverview' => $this->adminOverview->inventory(
|
||||
$organization,
|
||||
$this->ownerRef($request),
|
||||
$branchScope,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
$drugs = $this->pharmacy->listDrugs(
|
||||
$this->ownerRef($request),
|
||||
@@ -50,8 +68,7 @@ class DrugController extends Controller
|
||||
'drugs' => $drugs,
|
||||
'lowStock' => $lowStock,
|
||||
'expired' => $expired,
|
||||
'canManage' => app(\App\Services\Care\CarePermissions::class)
|
||||
->can($this->member($request), 'pharmacy.manage'),
|
||||
'canManage' => $permissions->can($member, 'pharmacy.manage'),
|
||||
'heroStats' => $heroStats,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
||||
use App\Models\Branch;
|
||||
use App\Models\Patient;
|
||||
use App\Services\Care\AdminOverviewService;
|
||||
use App\Services\Care\CareFeatures;
|
||||
use App\Services\Care\CarePermissions;
|
||||
use App\Services\Care\OrganizationResolver;
|
||||
@@ -21,6 +22,7 @@ class PatientController extends Controller
|
||||
|
||||
public function __construct(
|
||||
protected PatientService $patients,
|
||||
protected AdminOverviewService $adminOverview,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): View
|
||||
@@ -31,6 +33,20 @@ class PatientController extends Controller
|
||||
$resolver = app(OrganizationResolver::class);
|
||||
$branchScope = $resolver->branchScope($member);
|
||||
$practitionerScope = $resolver->practitionerScope($organization, $member);
|
||||
$permissions = app(CarePermissions::class);
|
||||
|
||||
if ($permissions->isAdmin($member) && $request->query('view') !== 'list') {
|
||||
return view('care.admin.analytics', [
|
||||
'title' => 'Patients',
|
||||
'badge' => 'Analytics · Population',
|
||||
'description' => 'Registration and visit trends across your facility — not a bedside patient list.',
|
||||
'adminOverview' => $this->adminOverview->patients(
|
||||
$organization,
|
||||
$this->ownerRef($request),
|
||||
$branchScope,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
$patients = $this->patients->search(
|
||||
$this->ownerRef($request),
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Care;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
|
||||
use App\Models\Branch;
|
||||
use App\Services\Care\AdminOverviewService;
|
||||
use App\Services\Care\CareFeatures;
|
||||
use App\Services\Care\OrganizationResolver;
|
||||
use App\Services\Care\PlanService;
|
||||
@@ -20,12 +21,15 @@ class ReportController extends Controller
|
||||
|
||||
public function __construct(
|
||||
protected ReportService $reports,
|
||||
protected AdminOverviewService $adminOverview,
|
||||
) {}
|
||||
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$this->authorizeAbility($request, 'reports.finance.view');
|
||||
$organization = $this->organization($request);
|
||||
$member = $this->member($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($member);
|
||||
|
||||
$branches = Branch::owned($this->ownerRef($request))
|
||||
->where('organization_id', $organization->id)
|
||||
@@ -33,10 +37,17 @@ class ReportController extends Controller
|
||||
->orderBy('name')
|
||||
->get();
|
||||
|
||||
return view('care.reports.index', [
|
||||
'organization' => $organization,
|
||||
return view('care.admin.analytics', [
|
||||
'title' => 'Reports',
|
||||
'badge' => 'Analytics · Facility performance',
|
||||
'description' => 'Live operational and financial snapshot. Open a detailed report for date ranges and CSV export.',
|
||||
'adminOverview' => $this->adminOverview->reportsHub(
|
||||
$organization,
|
||||
$this->ownerRef($request),
|
||||
$branchScope,
|
||||
),
|
||||
'catalog' => config('care.report_types'),
|
||||
'branches' => $branches,
|
||||
'reports' => config('care.report_types'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user