@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. --}}
@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. --}}
{{-- ═══ 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. --}}
Date
Patient
Age / Sex
Phone
Department
Bill Total
Payer
Clinician
@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
@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.
{{-- /.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. --}}
{{-- Decorative header with maternity-pink gradient + heart icon --}}
New ANC Visit
Start an antenatal encounter for an enrolled mother
{{-- ─── 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. --}}