<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Women's Health 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' => 'womens_health', '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>ANC history</h2>
    @if ($history)
        <dl>
            <dt>G / P</dt><dd>{{ $history->payload['gravida'] ?? '—' }} / {{ $history->payload['para'] ?? '—' }}</dd>
            <dt>GA / EDD</dt><dd>{{ $history->payload['gestational_age_weeks'] ?? '—' }} weeks · {{ $history->payload['edd'] ?? '—' }}</dd>
            <dt>LMP</dt><dd>{{ $history->payload['lmp'] ?? '—' }}</dd>
            <dt>Obstetric history</dt><dd>{{ $history->payload['obstetric_history'] ?? '—' }}</dd>
            <dt>Medications</dt><dd>{{ $history->payload['medications'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No ANC history recorded.</p>
    @endif

    <h2>Obstetric exam</h2>
    @if ($exam)
        <dl>
            <dt>BP / pulse</dt><dd>{{ $exam->payload['bp'] ?? '—' }} · {{ $exam->payload['pulse'] ?? '—' }}</dd>
            <dt>Fundal height</dt><dd>{{ $exam->payload['fundal_height'] ?? '—' }} cm</dd>
            <dt>Presentation</dt><dd>{{ $exam->payload['presentation'] ?? '—' }}</dd>
            <dt>Urine</dt><dd>{{ $exam->payload['urine'] ?? '—' }}</dd>
            <dt>Danger signs</dt><dd>{{ $exam->payload['danger_signs'] ?? '—' }}</dd>
            <dt>Findings</dt><dd>{{ $exam->payload['findings'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No obstetric exam recorded.</p>
    @endif

    <h2>Fetal notes</h2>
    @if ($fetal)
        <dl>
            <dt>FHR</dt><dd>{{ $fetal->payload['fetal_heart_rate'] ?? '—' }} bpm</dd>
            <dt>Movements</dt><dd>{{ $fetal->payload['fetal_movements'] ?? '—' }}</dd>
            <dt>Presentation</dt><dd>{{ $fetal->payload['presentation'] ?? '—' }}</dd>
            <dt>Notes</dt><dd>{{ $fetal->payload['notes'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No fetal notes recorded.</p>
    @endif

    <h2>Investigations</h2>
    @if ($investigation)
        <dl>
            <dt>Investigation</dt><dd>{{ $investigation->payload['modality'] ?? '—' }}</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>Care plan</h2>
    @if ($plan)
        <dl>
            <dt>Risk</dt><dd>{{ $plan->payload['risk_category'] ?? '—' }}</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 care plan recorded.</p>
    @endif

    <h2>Delivery / postnatal</h2>
    @if ($postnatal)
        <dl>
            <dt>Episode</dt><dd>{{ $postnatal->payload['episode_type'] ?? '—' }}</dd>
            <dt>Delivery mode</dt><dd>{{ $postnatal->payload['delivery_mode'] ?? '—' }}</dd>
            <dt>Outcome</dt><dd>{{ $postnatal->payload['outcome'] ?? '—' }}</dd>
            <dt>Maternal</dt><dd>{{ $postnatal->payload['maternal_condition'] ?? '—' }}</dd>
            <dt>Baby</dt><dd>{{ $postnatal->payload['baby_condition'] ?? '—' }}</dd>
            <dt>Plan</dt><dd>{{ $postnatal->payload['plan'] ?? '—' }}</dd>
        </dl>
    @else
        <p class="meta">No postnatal note recorded.</p>
    @endif

    <script>window.print();</script>
</body>
</html>
