@extends('layouts.app') @section('title', 'ANC Profile | ' . ($registration->patient->full_name ?? '')) @section('content') @include('partials._encounter-styles') @php $r = $registration; $p = $r->patient; $pkg = $coverage['package'] ?? null; $isPkg = ($coverage['mode'] ?? 'per_visit') === 'package'; $packagePrice = (float) ($pkg['price'] ?? ($r->package_amount ?? 0)); $paid = (float) ($coverage['paid'] ?? 0); $balance = (float) ($coverage['balance'] ?? max(0, $packagePrice - $paid)); $paidPct = $packagePrice > 0 ? min(100, round(($paid / $packagePrice) * 100)) : 0; $visitsCount = $r->visits->count(); $lastVisit = $r->visits->first(); // ordered DESC by visit_date $finalizedCount = $r->visits->whereNotNull('risk_level')->count(); @endphp
{{-- ═══ Title bar with action buttons ═══ --}}

ANC Profile

{{ $p->full_name ?? '—' }} · MRN {{ $p->mrn ?? '—' }} @if($p->phone) · {{ $p->phone }} @endif

Edit Profile @if($r->status === 'active') Start ANC Visit @endif
@if(session('success'))
{{ session('success') }}
@endif {{-- ═══ 1. Obstetric Overview ═══ --}}

1 Obstetric Overview

ANC Number
{{ $r->anc_number ?? '—' }}
LMP
{{ $r->lmp?->format('d M Y') ?? '—' }}
EDD
{{ $r->edd?->format('d M Y') ?? '—' }}
GA
{{ $r->gestational_age ?? '—' }} wks
Gravida / Parity
G{{ $r->gravida ?? '?' }}P{{ $r->parity ?? '?' }}
Blood Group
{{ $r->blood_group ?? '—' }}{{ $r->rhesus ? ' ' . $r->rhesus : '' }}
HIV Status
{{ $r->hiv_status ? ucfirst($r->hiv_status) : '—' }}
Risk Status
@php $risk = $r->risk_status ?? 'normal'; @endphp {{ ucfirst(str_replace('_', ' ', $risk)) }}
Next Visit
{{ $r->next_visit_date?->format('d M Y') ?? '—' }}
Attending Clinician
{{ $r->attendingClinician->name ?? '—' }}
Registration Date
{{ $r->registration_date?->format('d M Y') ?? '—' }}
Status
{{ ucfirst($r->status ?? 'unknown') }}
@if(is_array($r->risk_factors) && count($r->risk_factors))
Risk Factors
@foreach($r->risk_factors as $factor) {{ $factor }} @endforeach
@endif
{{-- ═══ 2. Package Coverage ═══ --}}

2 Package Coverage

@if($isPkg && $pkg)
{{ $pkg['label'] ?? $pkg['name'] ?? 'Package' }} @if(! empty($coverage['fully_paid'])) Fully paid ✓ @else Balance owed @endif
@endif
@if(! $isPkg || ! $pkg)

No ANC package is attached to this registration. Charges are billed per visit. Attach a package →

@else {{-- Financial summary: Price / Paid / Balance. The "Minimum to Start" tile that lived here previously is gone — the round 10 single-invoice model uses a dynamic per-visit 50%-of-current-balance gate enforced at Close Visit, not a static minimum at registration. --}}
Package Price
KES {{ number_format($packagePrice) }}
Paid
KES {{ number_format($paid) }}
{{ $paidPct }}% of package
Outstanding Balance
KES {{ number_format($balance) }}
{{-- Payment progress bar --}}
KES 0 KES {{ number_format($packagePrice) }}
{{-- Consumption against the new tracked items: consultations, the single Full ANC Profile, and ultrasounds. TT and "ANC Profile coverage flag" are removed — coverage now means "did the patient actually consume their entitled count". --}}
Consumption
@php $consultsUsed = (int) ($coverage['consultations_used'] ?? 0); $consultsQuota = (int) ($coverage['consultations_quota'] ?? 0); $profileUsed = (int) ($coverage['full_profile_used'] ?? 0); $profileQuota = (int) ($coverage['full_profile_quota'] ?? 0); $ultrasoundUsed = (int) ($coverage['ultrasounds_used'] ?? 0); $ultrasoundQuota= (int) ($coverage['ultrasounds_quota'] ?? 0); $consultsFull = $consultsQuota > 0 && $consultsUsed >= $consultsQuota; $profileFull = $profileQuota > 0 && $profileUsed >= $profileQuota; $ultrasoundFull = $ultrasoundQuota > 0 && $ultrasoundUsed >= $ultrasoundQuota; @endphp
Consultations
{{ $consultsUsed }} of {{ $consultsQuota }} used
{{ $consultsFull ? 'Quota met' : ($consultsQuota - $consultsUsed) . ' remaining' }}
Full ANC Profile
@if($profileQuota > 0) {{ $profileUsed }} of {{ $profileQuota }} used @else Not included @endif
@if($profileFull) Used @elseif($profileQuota > 0) Available @else N/A @endif
Ultrasounds
@if($ultrasoundQuota > 0) {{ $ultrasoundUsed }} of {{ $ultrasoundQuota }} used @else Not included @endif
@if($ultrasoundFull) Quota met @elseif($ultrasoundQuota > 0) {{ $ultrasoundQuota - $ultrasoundUsed }} remaining @else N/A @endif
{{-- Payment history block removed — round 10 single-invoice model spreads payments across visit invoices, so they're best viewed via the patient's overall billing history (which already aggregates them from the OUTSTANDING BALANCE widget at the top of the page). --}} @endif
{{-- ═══ 3. Delivery Plan ═══ --}}

3 Delivery Plan

Preferred Delivery Place
{{ $r->preferred_delivery_place ?? '—' }}
Birth Plan
{{ $r->birth_plan ?? '—' }}
Transport Plan
{{ $r->transport_plan ?? '—' }}
Blood Donor Plan
{{ $r->blood_donor_plan ?? '—' }}
Emergency Contact
{{ $r->emergency_contact_name ?? '—' }}{{ $r->emergency_contact_phone ? ' · ' . $r->emergency_contact_phone : '' }}
Delivery Plan Notes
{{ $r->delivery_plan ?? '—' }}
{{-- ═══ 4. ANC Visits Summary ═══ --}}

4 ANC Visits Summary

{{ $visitsCount }} visits · {{ $finalizedCount }} finalized
@if($visitsCount === 0)

No ANC visits recorded yet. Click Start ANC Visit above to begin.

@else @foreach($r->visits as $v) @endforeach
Visit # Date GA BP Weight FHR Seen By Risk
#{{ $v->visit_number ?? '?' }} {{ $v->visit_date?->format('d M Y') ?? '—' }} {{ $v->gestational_age_weeks ?? '—' }}w {{ $v->bp_systolic ? $v->bp_systolic.'/'.($v->bp_diastolic ?? '?') : ($v->blood_pressure ?? '—') }} {{ $v->weight ? $v->weight.' kg' : '—' }} {{ $v->fetal_heart_rate ?? '—' }} {{ $v->seenBy->name ?? '—' }} @if($v->risk_level) {{ ucfirst(str_replace('_',' ', $v->risk_level)) }} @else In progress @endif
@endif
@endsection