Hide finance and admin KPIs from roles that lack them.
Deploy Ladill Care / deploy (push) Successful in 33s

Doctors no longer see revenue, open bills, or org admin cards on the Care dashboard.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-14 22:32:41 +00:00
co-authored by Cursor
parent c425aa12ac
commit 50f515cf6a
4 changed files with 213 additions and 111 deletions
+24 -16
View File
@@ -19,8 +19,12 @@ class ReportService
/**
* @return array<string, mixed>
*/
public function dashboardStats(string $ownerRef, int $organizationId, ?int $branchId = null): array
{
public function dashboardStats(
string $ownerRef,
int $organizationId,
?int $branchId = null,
bool $includeBilling = true,
): array {
$today = now()->startOfDay();
$patientsToday = Patient::owned($ownerRef)
@@ -35,21 +39,25 @@ class ReportService
->whereDate('scheduled_at', $today)
->count();
$openBills = Bill::owned($ownerRef)
->where('organization_id', $organizationId)
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
->whereIn('status', [Bill::STATUS_OPEN, Bill::STATUS_PARTIAL])
->count();
$openBills = 0;
$revenueToday = 0;
if ($includeBilling) {
$openBills = Bill::owned($ownerRef)
->where('organization_id', $organizationId)
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
->whereIn('status', [Bill::STATUS_OPEN, Bill::STATUS_PARTIAL])
->count();
$revenueToday = Payment::owned($ownerRef)
->whereHas('bill', function (Builder $q) use ($organizationId, $branchId) {
$q->where('organization_id', $organizationId);
if ($branchId) {
$q->where('branch_id', $branchId);
}
})
->whereDate('paid_at', $today)
->sum('amount_minor');
$revenueToday = Payment::owned($ownerRef)
->whereHas('bill', function (Builder $q) use ($organizationId, $branchId) {
$q->where('organization_id', $organizationId);
if ($branchId) {
$q->where('branch_id', $branchId);
}
})
->whereDate('paid_at', $today)
->sum('amount_minor');
}
$pendingLab = InvestigationRequest::owned($ownerRef)
->where('organization_id', $organizationId)