Add clinical device registry, browser wedge scan, and local agent API.
Deploy Ladill Care / deploy (push) Successful in 1m39s

Branch-scoped Care devices with hashed agent tokens, patient barcode lookup/labels, and provenance-aware vitals from a minimal device agent (Pro for agent hardware; wedge free).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 14:28:46 +00:00
co-authored by Cursor
parent 1da90203e8
commit e0a7a64d38
37 changed files with 1970 additions and 10 deletions
+34
View File
@@ -72,6 +72,40 @@ class PatientService
return $query->paginate((int) ($filters['per_page'] ?? 20))->withQueryString();
}
/**
* Exact patient_number match first, then fall back to broad search (first hit).
*/
public function findByScanCode(string $ownerRef, int $organizationId, string $code, ?int $branchId = null): ?Patient
{
$code = trim($code);
if ($code === '') {
return null;
}
$base = $this->queryForOrganization($ownerRef, $organizationId)
->when($branchId !== null, fn ($q) => $q->where('branch_id', $branchId));
$exact = (clone $base)->where('patient_number', $code)->first();
if ($exact) {
return $exact;
}
// Case-insensitive exact patient number.
$ci = (clone $base)->whereRaw('lower(patient_number) = ?', [strtolower($code)])->first();
if ($ci) {
return $ci;
}
return (clone $base)
->where(function (Builder $inner) use ($code) {
$inner->where('patient_number', 'like', "%{$code}%")
->orWhere('national_id', $code)
->orWhere('phone', 'like', "%{$code}%");
})
->orderByDesc('created_at')
->first();
}
/**
* @param array<string, mixed> $data
*/