@extends('layouts.app') @section('title', 'ANC Visits') @section('content') @include('partials._encounter-styles') @php // Used by the Discharge button on the ANC Clients table (rendered below). // Backend gate on route('maternity.anc.outcome') is Super Admin + Hospital Admin. $isAdmin = auth()->user() && auth()->user()->hasAnyRole('Super Admin', 'Hospital Admin'); @endphp {{-- Scoped table-header restyle (May 14 2026): the shared enc-table thead is purple-tinted (CR brand) which here clashes with the grey-headed clients table further down on the same page. These overrides make the ANC visits table thead match the standard grey table style used elsewhere in the system. Scope is the .anc-page wrapper, so no other page that uses enc-table is affected. --}}
{{-- Breadcrumb row removed May 14 2026: Antenatal Care is now a top-level sidebar entry, so a back-link to "Outpatient Visits" is incorrect (ANC isn't a child of OPD any more). The page title and sidebar active-state already tell the user where they are. Issue #5 May 12 2026: View Completed Visits moved to the table's filter row (top-right) so it sits with the other table-level controls. --}} {{-- Primary action row — three buttons above the table. Issue #4 May 12 2026: Register / Start / View Clients. The standalone "ANC Clients" tab was removed; "View ANC Clients" button replaces it, linking to the same ?tab=clients view. --}}
Register ANC Client View ANC Clients @if($activeTab !== 'clients'){{ $mothers->total() }}@endif @if($activeTab === 'clients') Back to ANC Visits @endif
@if($activeTab === 'visits') {{-- Search/filter row above the table. Issue #5 May 12 2026: View Completed Visits anchored at the right side of this row so it sits with the table's other controls. --}}
@if(request()->hasAny(['search','status','date'])) Clear @endif {{ $visits->total() }} visit(s) View Completed Visits
{{-- ═══ VISITS TABLE ═══ --}}
{{-- Section header row removed Issue #15 — the tab strip already labels this content; a redundant "1 ANC Visits" row was noise. --}}
{{-- Column set unified across the four visits-list pages on 25 May 2026. ANC Visits gets no Actions column — the spec restricts that to the Completed pages. If reception needs the "Enroll" shortcut back for patients who aren't in ANC yet, surface it as an inline link inside the Department cell instead of reintroducing a column. --}} @forelse($visits as $v) @php $ancReg = \App\Models\AncRegistration::where('patient_id', $v->patient_id)->where('status', 'active')->first(); // Whole-row click lands on the ANC encounter when the // patient is enrolled, otherwise on the visit show // page (where they can be routed to enrollment). $rowHref = $ancReg ? route('maternity.anc.show', $ancReg) : route('visits.show', $v); @endphp @empty @endforelse
Date Patient Age / Sex Phone Department Bill Total Payer Clinician
{{ $v->check_in_at?->format('Y-m-d') ?? '—' }}

{{ $v->patient->full_name ?? '' }}

{{ $v->patient->age ?? '' }} / {{ ucfirst(substr($v->patient->gender ?? '', 0, 1)) }} {{ $v->patient->phone ?? '' }} {{ $v->department->name ?? '-' }} @if($v->invoice) KES {{ number_format($v->invoice?->total_amount ?? 0) }} @if(($v->invoice?->balance ?? 0) > 0)
Bal: {{ number_format($v->invoice?->balance) }}@endif @else - @endif
{{ $v->payer_label }} {{ $v->clinician->name ?? '-' }}

No ANC visits {{ request('date') ? 'on ' . request('date') : 'today' }}.

Create an ANC visit →
@if($visits->hasPages())
{{ $visits->links() }}
@endif
@elseif($activeTab === 'clients') {{-- ═══ ANC CLIENTS PANE (Issue #10) ═══ Folded in from /maternity/edd-monitor. Standalone EDD monitor route stays alive for back-compat (bookmarks); new entry point is this tab. --}} {{-- Client filter pills --}}
@foreach(['all'=>'All Active','today'=>'EDD Today','week'=>'This Week','overdue'=>'Overdue','delivered'=>'Delivered'] as $key => $label) {{ $label }} @endforeach
@forelse($mothers as $r) @empty @endforelse
Patient MRN Phone GA EDD Days Risk Visits Actions
{{ $r->patient->full_name ?? '' }} {{ $r->patient->mrn ?? '' }} {{ $r->patient->phone ?? '' }} {{ $r->gestational_age ?? '-' }}wks {{ $r->edd?->format('d M Y') ?? '-' }} {{ $r->edd ? ($r->edd->isPast() ? (int) abs($r->edd->diffInDays(now())).' overdue' : (int) $r->edd->diffInDays(now()).' days') : '-' }} {{ ucfirst($r->risk_status ?? 'normal') }} {{ $r->visits_count ?? 0 }} View @if($isAdmin && $r->edd && $r->edd->lte(today())) @endif
No ANC clients in scope.
@if($mothers->hasPages())
{{ $mothers->links() }}
@endif
@elseif($activeTab === 'completed') {{-- Issue #2 (May 12 2026): the inline Completed Visits tab was replaced by a "Completed Visits" top-action button that navigates to the standalone /maternity/anc-visits/completed route. This branch is kept as a safety net for any stale ?tab=completed links — it just redirects via the button text. --}}

Completed ANC visits have moved to a dedicated page.

Open Completed Visits →
@endif
{{-- /.enc-page --}} {{-- ═══ NEW ANC VISIT MODAL ═══ Issue #6 May 13 2026: Visual redesign. All form field names/IDs are preserved (patient_id, payer_type, department_id, insurance_company_id, authorization_code, plus the #anc-patient-* JS hooks) so the controller and scoped patient-search script downstream don't need any changes. --}} {{-- ─── ANC Discharge Modal ────────────────────────────────────────── Super Admin + Hospital Admin only. Posts to maternity.anc.outcome. Recording an outcome flips status away from 'active' so the client drops off this list automatically. --}} @endsection