Add full Eye Care (ophthalmology) specialty clinical suite.
Deploy Ladill Care / deploy (push) Successful in 35s

Mirror Emergency/Blood Bank depth with stages, workspace tabs, workflow/analytics services, reports/print, demo clinical seed, and feature tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-19 15:19:04 +00:00
co-authored by Cursor
parent 5d9d333170
commit 1d3db4f803
20 changed files with 1454 additions and 28 deletions
@@ -0,0 +1,107 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Eye care summary · {{ $patient->fullName() }}</title>
<style>
body { font-family: system-ui, sans-serif; color: #0f172a; margin: 2rem; }
h1 { font-size: 1.25rem; margin: 0 0 .25rem; }
h2 { font-size: .95rem; margin: 1.25rem 0 .5rem; border-bottom: 1px solid #e2e8f0; padding-bottom: .25rem; }
.meta { color: #64748b; font-size: .875rem; }
dl { display: grid; grid-template-columns: 10rem 1fr; gap: .35rem .75rem; font-size: .875rem; }
dt { color: #64748b; }
dd { margin: 0; font-weight: 500; }
@media print { .no-print { display: none; } }
</style>
</head>
<body>
<p class="no-print"><a href="{{ route('care.specialty.workspace', ['module' => 'ophthalmology', 'visit' => $visit]) }}">Back</a></p>
<h1>{{ $patient->fullName() }}</h1>
<p class="meta">
{{ $patient->patient_number }}
· Visit #{{ $visit->id }}
· Stage {{ $visit->specialty_stage ?? '—' }}
· {{ $visit->checked_in_at?->format('d M Y H:i') ?? '—' }}
</p>
<h2>Visual acuity / refraction</h2>
@if ($refraction)
<dl>
<dt>VA OD / OS</dt><dd>{{ $refraction->payload['va_od'] ?? '—' }} / {{ $refraction->payload['va_os'] ?? '—' }}</dd>
<dt>Near VA</dt><dd>{{ $refraction->payload['va_od_near'] ?? '—' }} / {{ $refraction->payload['va_os_near'] ?? '—' }}</dd>
<dt>OD Rx</dt>
<dd>
Sph {{ $refraction->payload['sphere_od'] ?? '—' }}
Cyl {{ $refraction->payload['cylinder_od'] ?? '—' }}
Axis {{ $refraction->payload['axis_od'] ?? '—' }}
</dd>
<dt>OS Rx</dt>
<dd>
Sph {{ $refraction->payload['sphere_os'] ?? '—' }}
Cyl {{ $refraction->payload['cylinder_os'] ?? '—' }}
Axis {{ $refraction->payload['axis_os'] ?? '—' }}
</dd>
<dt>Add / PD</dt><dd>{{ $refraction->payload['add'] ?? '—' }} / {{ $refraction->payload['pd'] ?? '—' }}</dd>
<dt>Notes</dt><dd>{{ $refraction->payload['notes'] ?? '—' }}</dd>
</dl>
@else
<p class="meta">No refraction recorded.</p>
@endif
<h2>Examination</h2>
@if ($exam)
<dl>
<dt>Chief complaint</dt><dd>{{ $exam->payload['chief_complaint'] ?? '—' }}</dd>
<dt>History</dt><dd>{{ $exam->payload['history'] ?? '—' }}</dd>
<dt>IOP OD / OS</dt><dd>{{ $exam->payload['iop_od'] ?? '—' }} / {{ $exam->payload['iop_os'] ?? '—' }}</dd>
<dt>Pupils</dt><dd>{{ $exam->payload['pupils'] ?? '—' }}</dd>
<dt>Anterior segment</dt><dd>{{ $exam->payload['anterior_segment'] ?? '—' }}</dd>
<dt>Fundus</dt><dd>{{ $exam->payload['fundus'] ?? '—' }}</dd>
<dt>Findings</dt><dd>{{ $exam->payload['findings'] ?? '—' }}</dd>
</dl>
@else
<p class="meta">No examination recorded.</p>
@endif
<h2>Investigations</h2>
@if ($investigation)
<dl>
<dt>Modality</dt><dd>{{ $investigation->payload['modality'] ?? '—' }}</dd>
<dt>Eye</dt><dd>{{ $investigation->payload['eye'] ?? '—' }}</dd>
<dt>Findings</dt><dd>{{ $investigation->payload['findings'] ?? '—' }}</dd>
<dt>Impression</dt><dd>{{ $investigation->payload['impression'] ?? '—' }}</dd>
</dl>
@else
<p class="meta">No investigation recorded.</p>
@endif
<h2>Diagnosis &amp; plan</h2>
@if ($plan)
<dl>
<dt>Diagnosis</dt><dd>{{ $plan->payload['diagnosis'] ?? '—' }}</dd>
<dt>Laterality</dt><dd>{{ $plan->payload['laterality'] ?? '—' }}</dd>
<dt>Plan</dt><dd>{{ $plan->payload['plan'] ?? '—' }}</dd>
<dt>Medications</dt><dd>{{ $plan->payload['medications'] ?? '—' }}</dd>
<dt>Follow-up</dt><dd>{{ $plan->payload['follow_up'] ?? '—' }}</dd>
</dl>
@else
<p class="meta">No plan recorded.</p>
@endif
<h2>Procedure / treatment</h2>
@if ($procedure)
<dl>
<dt>Procedure</dt><dd>{{ $procedure->payload['procedure'] ?? '—' }}</dd>
<dt>Eye</dt><dd>{{ $procedure->payload['eye'] ?? '—' }}</dd>
<dt>Outcome</dt><dd>{{ $procedure->payload['outcome'] ?? '—' }}</dd>
<dt>Post-op plan</dt><dd>{{ $procedure->payload['post_op_plan'] ?? '—' }}</dd>
<dt>Notes</dt><dd>{{ $procedure->payload['notes'] ?? '—' }}</dd>
</dl>
@else
<p class="meta">No procedure recorded.</p>
@endif
<script>window.print();</script>
</body>
</html>
@@ -0,0 +1,88 @@
<x-app-layout title="Eye care reports">
<div class="space-y-6">
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<h1 class="text-xl font-semibold text-slate-900">Eye care reports</h1>
<p class="mt-1 text-sm text-slate-500">Arrivals, elevated IOP, diagnoses, procedures, length of stay, and eye service revenue.</p>
</div>
<a href="{{ route('care.specialty.show', 'ophthalmology') }}" class="text-sm font-medium text-indigo-600"> Specialty home</a>
</div>
<form method="GET" class="flex flex-wrap items-end gap-3 rounded-2xl border border-slate-200 bg-white p-4">
<div>
<label class="block text-xs font-medium text-slate-600">From</label>
<input type="date" name="from" value="{{ $report['from'] ?? '' }}" class="mt-1 rounded-xl border border-slate-200 px-3 py-2 text-sm">
</div>
<div>
<label class="block text-xs font-medium text-slate-600">To</label>
<input type="date" name="to" value="{{ $report['to'] ?? '' }}" class="mt-1 rounded-xl border border-slate-200 px-3 py-2 text-sm">
</div>
<button type="submit" class="rounded-xl bg-indigo-600 px-4 py-2 text-sm font-semibold text-white">Apply</button>
</form>
<div class="grid gap-4 sm:grid-cols-4">
<div class="rounded-2xl border border-slate-200 bg-white p-4">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Arrivals today</p>
<p class="mt-2 text-2xl font-semibold tabular-nums text-slate-900">{{ number_format($report['arrivals_today']) }}</p>
</div>
<div class="rounded-2xl border border-slate-200 bg-white p-4">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Completed today</p>
<p class="mt-2 text-2xl font-semibold tabular-nums text-slate-900">{{ number_format($report['completed_today']) }}</p>
</div>
<div class="rounded-2xl border border-slate-200 bg-white p-4">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Elevated IOP open</p>
<p class="mt-2 text-2xl font-semibold tabular-nums text-rose-700">{{ number_format($report['elevated_iop_open']) }}</p>
</div>
<div class="rounded-2xl border border-slate-200 bg-white p-4">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Avg LOS (range)</p>
<p class="mt-2 text-2xl font-semibold tabular-nums text-slate-900">
{{ $report['avg_los_minutes'] !== null ? $report['avg_los_minutes'].' min' : '—' }}
</p>
</div>
</div>
<div class="grid gap-4 lg:grid-cols-2">
<section class="rounded-2xl border border-slate-200 bg-white p-5">
<h2 class="text-sm font-semibold text-slate-900">Diagnoses</h2>
<ul class="mt-3 space-y-2 text-sm">
@forelse ($report['diagnosis_breakdown'] as $row)
<li class="flex justify-between gap-3">
<span>{{ $row['diagnosis'] }}</span>
<span class="tabular-nums text-slate-600">{{ $row['total'] }}</span>
</li>
@empty
<li class="text-slate-500">No diagnosis records in range.</li>
@endforelse
</ul>
</section>
<section class="rounded-2xl border border-slate-200 bg-white p-5">
<h2 class="text-sm font-semibold text-slate-900">Procedures</h2>
<ul class="mt-3 space-y-2 text-sm">
@forelse ($report['procedure_breakdown'] as $row)
<li class="flex justify-between gap-3">
<span>{{ $row['procedure'] }}</span>
<span class="tabular-nums text-slate-600">{{ $row['total'] }}</span>
</li>
@empty
<li class="text-slate-500">No procedures in range.</li>
@endforelse
</ul>
</section>
</div>
<section class="rounded-2xl border border-slate-200 bg-white p-5">
<h2 class="text-sm font-semibold text-slate-900">Eye care service revenue</h2>
<ul class="mt-3 space-y-2 text-sm">
@forelse ($report['revenue_by_service'] as $row)
<li class="flex justify-between gap-3">
<span>{{ $row->description }} <span class="text-slate-400">×{{ $row->total }}</span></span>
<span class="tabular-nums">{{ $currency }} {{ number_format($row->amount_minor / 100, 2) }}</span>
</li>
@empty
<li class="text-slate-500">No billed eye care services in range.</li>
@endforelse
</ul>
</section>
</div>
</x-app-layout>
@@ -0,0 +1,126 @@
@php
$examPayload = $ophthalmologyExam?->payload ?? [];
$refractionPayload = $ophthalmologyRefraction?->payload ?? [];
$planPayload = $ophthalmologyPlan?->payload ?? [];
$currentStage = $workspaceVisit->specialty_stage;
$stageFlow = $ophthalmologyStageFlow ?? [];
$stageLabels = collect($stages ?? [])->pluck('label', 'code');
$canManage = $canAdvanceStage ?? $canConsult ?? false;
$vaOd = $refractionPayload['va_od'] ?? ($examPayload['va_od'] ?? null);
$vaOs = $refractionPayload['va_os'] ?? ($examPayload['va_os'] ?? null);
@endphp
<section class="rounded-2xl border border-slate-200 bg-white p-5">
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<h3 class="text-sm font-semibold text-slate-900">Eye care overview</h3>
<p class="mt-0.5 text-xs text-slate-500">Visual acuity, IOP, diagnosis, and visit stage for this episode.</p>
</div>
<div class="flex flex-wrap gap-3 text-sm">
<a href="{{ route('care.specialty.ophthalmology.print', $workspaceVisit) }}" target="_blank" class="font-medium text-indigo-600">Print summary</a>
<a href="{{ route('care.specialty.ophthalmology.reports') }}" class="font-medium text-indigo-600">Eye care reports</a>
</div>
</div>
<div class="mt-4 grid gap-3 sm:grid-cols-3">
<div class="rounded-xl border border-slate-100 bg-slate-50 px-3 py-3">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Visual acuity</p>
<p class="mt-1 text-sm font-semibold text-slate-900">
OD {{ $vaOd ?? '—' }} · OS {{ $vaOs ?? '—' }}
</p>
<p class="mt-1 text-xs text-slate-500">{{ $examPayload['chief_complaint'] ?? 'No complaint recorded' }}</p>
</div>
<div class="rounded-xl border border-slate-100 bg-slate-50 px-3 py-3">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">IOP (mmHg)</p>
<p class="mt-1 text-sm font-semibold text-slate-900">
OD {{ $examPayload['iop_od'] ?? '—' }} · OS {{ $examPayload['iop_os'] ?? '—' }}
</p>
<p class="mt-1 text-xs text-slate-500">Pupils {{ $examPayload['pupils'] ?? '—' }}</p>
</div>
<div class="rounded-xl border border-slate-100 bg-slate-50 px-3 py-3">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Diagnosis</p>
<p class="mt-1 text-sm font-semibold text-slate-900">{{ $planPayload['diagnosis'] ?? 'Not set' }}</p>
<p class="mt-1 text-xs text-slate-500">{{ $planPayload['follow_up'] ?? ($planPayload['laterality'] ?? '—') }}</p>
</div>
</div>
<div class="mt-4 rounded-xl border border-slate-100 bg-slate-50 px-3 py-3">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Visit stage</p>
<p class="mt-1 text-sm font-medium text-slate-900">
{{ $currentStage ? ($stageLabels[$currentStage] ?? ucfirst(str_replace('_', ' ', $currentStage))) : 'Not set' }}
</p>
<div class="mt-3 flex flex-wrap gap-2">
@foreach (($ophthalmologyStageCodes ?: ['check_in', 'history', 'refraction', 'exam', 'investigation', 'plan', 'treatment', 'completed']) as $stageCode)
@if ($canManage)
<form method="POST" action="{{ route('care.specialty.ophthalmology.stage', $workspaceVisit) }}">
@csrf
<input type="hidden" name="stage" value="{{ $stageCode }}">
<button type="submit"
@class([
'rounded-lg px-2.5 py-1 text-xs font-semibold',
'bg-indigo-600 text-white' => $currentStage === $stageCode,
'border border-slate-200 bg-white text-slate-700 hover:bg-slate-50' => $currentStage !== $stageCode,
])>
{{ $stageLabels[$stageCode] ?? ucfirst(str_replace('_', ' ', $stageCode)) }}
</button>
</form>
@else
<span
@class([
'rounded-lg px-2.5 py-1 text-xs font-semibold',
'bg-indigo-600 text-white' => $currentStage === $stageCode,
'border border-slate-200 bg-white text-slate-400' => $currentStage !== $stageCode,
])
@if ($currentStage !== $stageCode) aria-disabled="true" title="View-only access" @endif
>
{{ $stageLabels[$stageCode] ?? ucfirst(str_replace('_', ' ', $stageCode)) }}
</span>
@endif
@endforeach
@if ($canManage && $currentStage && isset($stageFlow[$currentStage]) && $stageFlow[$currentStage]['next'] !== $currentStage)
<form method="POST" action="{{ route('care.specialty.ophthalmology.stage', $workspaceVisit) }}">
@csrf
<input type="hidden" name="stage" value="{{ $stageFlow[$currentStage]['next'] }}">
<button type="submit" class="rounded-lg bg-emerald-600 px-2.5 py-1 text-xs font-semibold text-white hover:bg-emerald-700">
{{ $stageFlow[$currentStage]['label'] }}
</button>
</form>
@endif
</div>
</div>
<dl class="mt-4 grid gap-3 text-sm sm:grid-cols-2">
<div>
<dt class="text-slate-500">Key findings</dt>
<dd class="font-medium text-slate-900">{{ $examPayload['findings'] ?? '—' }}</dd>
</div>
<div>
<dt class="text-slate-500">Plan</dt>
<dd class="font-medium text-slate-900">{{ $planPayload['plan'] ?? '—' }}</dd>
</div>
<div>
<dt class="text-slate-500">Queue</dt>
<dd class="font-medium text-slate-900">
{{ $workspaceVisit->appointment?->queue_ticket_number ?? '—' }}
@if ($workspaceVisit->appointment?->queue_ticket_status)
<span class="text-slate-500">({{ $workspaceVisit->appointment->queue_ticket_status }})</span>
@endif
</dd>
</div>
<div>
<dt class="text-slate-500">Checked in</dt>
<dd class="font-medium text-slate-900">{{ $workspaceVisit->checked_in_at?->format('d M Y H:i') ?? '—' }}</dd>
</div>
</dl>
@if (! empty($clinicalAlerts))
<div class="mt-4 space-y-1.5 border-t border-slate-100 pt-4">
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Alerts</p>
@foreach ($clinicalAlerts as $alert)
<p class="text-sm {{ ($alert['severity'] ?? '') === 'critical' ? 'text-rose-700' : 'text-amber-800' }}">
{{ $alert['message'] ?? '' }}
</p>
@endforeach
</div>
@endif
</section>
@@ -0,0 +1,70 @@
@php
$record = $ophthalmologyProcedure;
$payload = $record?->payload ?? [];
$canManage = $canManageClinical ?? $canConsult ?? false;
@endphp
<section class="rounded-2xl border border-slate-200 bg-white p-5">
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<h3 class="text-sm font-semibold text-slate-900">Procedure / treatment</h3>
<p class="mt-0.5 text-xs text-slate-500">Record ocular procedures. Completing a procedure can close the visit.</p>
</div>
<a href="{{ route('care.specialty.ophthalmology.print', $workspaceVisit) }}" target="_blank" class="text-sm font-medium text-indigo-600">Print summary</a>
</div>
@if ($canManage)
<form method="POST" action="{{ route('care.specialty.ophthalmology.procedure', $workspaceVisit) }}" class="mt-4 space-y-4">
@csrf
<input type="hidden" name="tab" value="treat">
<div class="grid gap-3 sm:grid-cols-2">
@foreach ($clinicalFields ?? [] as $field)
@php
$name = $field['name'];
$value = old('payload.'.$name, $payload[$name] ?? '');
$type = $field['type'] ?? 'text';
@endphp
<div @class(['sm:col-span-2' => in_array($type, ['textarea'], true)])>
<label class="block text-xs font-medium text-slate-600">
{{ $field['label'] }}
@if (! empty($field['required'])) <span class="text-rose-600">*</span> @endif
</label>
@if ($type === 'textarea')
<textarea name="payload[{{ $name }}]" rows="{{ $field['rows'] ?? 3 }}" @required(! empty($field['required']))
class="mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm">{{ $value }}</textarea>
@elseif ($type === 'select')
<select name="payload[{{ $name }}]" @required(! empty($field['required']))
class="mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm">
<option value="">Select…</option>
@foreach ($field['options'] ?? [] as $option)
<option value="{{ $option }}" @selected((string) $value === (string) $option)>{{ $option }}</option>
@endforeach
</select>
@elseif ($type === 'boolean')
<label class="mt-2 inline-flex items-center gap-2 text-sm text-slate-700">
<input type="checkbox" name="payload[{{ $name }}]" value="1" @checked(old('payload.'.$name, ! empty($payload[$name])))>
Yes
</label>
@else
<input type="{{ $type === 'number' ? 'number' : 'text' }}" name="payload[{{ $name }}]" value="{{ $value }}"
@required(! empty($field['required']))
class="mt-1 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm">
@endif
</div>
@endforeach
</div>
<button type="submit" class="btn-primary">Save treatment</button>
</form>
@elseif ($record)
<dl class="mt-4 grid gap-3 text-sm sm:grid-cols-2">
@foreach ($clinicalFields ?? [] as $field)
<div>
<dt class="text-slate-500">{{ $field['label'] }}</dt>
<dd class="font-medium text-slate-900">{{ $payload[$field['name']] ?? '—' }}</dd>
</div>
@endforeach
</dl>
@else
<p class="mt-4 text-sm text-slate-500">No procedure recorded yet.</p>
@endif
</section>
@@ -52,6 +52,8 @@
@include('care.specialty.emergency.workspace-'.$activeTab)
@elseif ($moduleKey === 'blood_bank' && in_array($activeTab, ['overview', 'issue', 'transfusion'], true))
@include('care.specialty.blood-bank.workspace-'.$activeTab)
@elseif ($moduleKey === 'ophthalmology' && in_array($activeTab, ['overview', 'treat'], true))
@include('care.specialty.ophthalmology.workspace-'.$activeTab)
@elseif ($activeTab === 'billing')
<section class="rounded-2xl border border-slate-200 bg-white p-5">
<h3 class="text-sm font-semibold text-slate-900">
@@ -34,6 +34,9 @@
<a href="{{ route('care.blood-bank.admin.index') }}" class="text-slate-600 hover:text-slate-900">Admin</a>
@endif
@endif
@if ($moduleKey === 'ophthalmology')
<a href="{{ route('care.specialty.ophthalmology.reports') }}" class="text-slate-600 hover:text-slate-900">Reports</a>
@endif
<a href="{{ route('care.specialty.history', $moduleKey) }}" class="text-slate-600 hover:text-slate-900">History</a>
@if ($canManageClinical ?? $canManageSpecialty ?? true)
<a href="{{ route('care.specialty.billing', $moduleKey) }}" class="text-slate-600 hover:text-slate-900">Billing</a>