@extends('layouts.app') @section('title', 'Maternity Discharge Summary | ' . ($maternityAdmission->patient->full_name ?? '')) @section('styles') {{-- ── Round 16: Maternity discharge summary rewritten to match the IPD discharge summary visually (browser-rendered, _document-header letterhead, same demographic-strip + ds-section styling). The previous DomPDF template had its own pink-themed look that didn't match the rest of the document family — clinicians flagged that the maternity discharge summary lacked the letterhead and didn't feel like an official CRH document. This template extends layouts.app so the logo and flex layouts render correctly. ── --}} @endsection @section('content') @php $ma = $maternityAdmission; $patient = $ma->patient; $visit = $ma->visit; $delivery = $ma->resolvedDelivery; $newborns = $delivery?->newborns ?? collect(); // Only dispensed take-home meds appear on the summary (mirrors IPD). $dispDrugs = $visit?->prescriptions ->where('status', 'dispensed') ->where('is_take_home', true) ?? collect(); // If no take-home flag is in use yet, fall back to all dispensed meds // so old records don't print blank. Clinicians can mark items as // take-home from the Orders tab once the workflow rolls out. if (! $dispDrugs->count()) { $dispDrugs = $visit?->prescriptions->where('status', 'dispensed') ?? collect(); } $los = $ma->length_of_stay ?? '-'; $cond = $ma->condition_on_discharge ?? ''; $condLabel = [ 'improved' => 'Improved', 'stable' => 'Stable', 'deteriorated' => 'Deteriorated', 'absconded' => 'Absconded', 'deceased' => 'Deceased', ][$cond] ?? '-'; @endphp
Back

Maternity Discharge Summary | {{ $patient->full_name ?? '' }}

{{-- PRINTABLE DISCHARGE SUMMARY --}}
{{-- LETTERHEAD (shared partial — matches IPD discharge & case summary) --}} @include('partials._document-header') {{-- PATIENT DEMOGRAPHICS STRIP — row 1 --}}
Name:{{ $patient->full_name ?? '' }} Patient ID:{{ $patient->mrn ?? '' }} Age:{{ $patient->age ?? '—' }} Phone:{{ $patient->phone ?? '—' }}
{{-- PATIENT DEMOGRAPHICS STRIP — row 2: admission facts --}}
G/A on Admission:{{ $ma->gestational_age_weeks ? $ma->gestational_age_weeks.' wk' : '—' }} Admitted:{{ $ma->admission_date?->format('d M Y H:i') ?? '-' }} Discharged:{{ $ma->discharge_date?->format('d M Y H:i') ?? 'Pending' }}
{{-- PATIENT DEMOGRAPHICS STRIP — row 3: clinical facts --}}
Length of Stay:{{ $los }} {{ $los == 1 ? 'day' : 'days' }} Condition on Discharge:{{ $condLabel }} Attending Provider:{{ $ma->attendingProvider->name ?? '-' }}
{{-- SEPARATOR --}}
{{-- REPORT TITLE --}}

Maternity Discharge Summary

{{-- REPORT SECTIONS --}}

{{ $ma->reason_for_admission ?? '-' }}

{{ $ma->diagnosis ?? '-' }}

{{ $ma->discharge_diagnosis ?? '-' }}

{{-- DELIVERY DETAILS --}} @if($delivery)
@if($delivery->complications && (is_array($delivery->complications) ? count($delivery->complications) : true)) @endif @if($delivery->notes) @endif
Date / Time {{ $delivery->delivery_date?->format('d M Y') ?? '-' }} {{ $delivery->delivery_time ?? '' }} Mode of Delivery {{ ucfirst(str_replace('_',' ', $delivery->mode_of_delivery ?? '-')) }}
G/A at Delivery {{ $delivery->gestational_age_at_delivery ? $delivery->gestational_age_at_delivery.' wk' : '-' }} Duration of Labour {{ $delivery->duration_of_labour ?? '-' }}
Blood Loss {{ $delivery->blood_loss ? $delivery->blood_loss.' ml' : '-' }} Placenta {{ $delivery->placenta_complete === null ? '-' : ($delivery->placenta_complete ? 'Complete' : 'Incomplete') }}
Perineum {{ $delivery->perineum ?? '-' }} Delivered By {{ $delivery->deliveredBy->name ?? '-' }}
Mother Outcome {{ ucfirst(str_replace('_',' ', $delivery->mother_outcome ?? '-')) }} Baby Outcome {{ ucfirst(str_replace('_',' ', $delivery->baby_outcome ?? '-')) }}
Intrapartum Notes {{ is_array($delivery->complications) ? implode(', ', $delivery->complications) : $delivery->complications }}
Delivery Notes {{ $delivery->notes }}
@endif {{-- NEWBORN(S) --}} @if($newborns->count())
@foreach($newborns as $i => $nb)
Baby {{ $i + 1 }} · {{ ucfirst($nb->gender ?? 'unknown') }} · {{ $nb->birth_weight ? $nb->birth_weight.' kg' : 'weight n/r' }}
@if($nb->notes) @endif
APGAR (1/5/10) {{ $nb->apgar_1min ?? '-' }} / {{ $nb->apgar_5min ?? '-' }} / {{ $nb->apgar_10min ?? '-' }} Resuscitation {{ $nb->resuscitation ? 'Yes' : 'No' }}
Vitamin K {{ $nb->vitamin_k ? '✓ Given' : '✗ Not given' }} BCG / OPV {{ $nb->bcg ? 'BCG ✓' : 'BCG ✗' }} · {{ $nb->opv ? 'OPV ✓' : 'OPV ✗' }}
Breastfeeding {{ $nb->breastfeeding_initiated ? 'Initiated' : 'Not initiated' }} Abnormalities {{ $nb->abnormalities ?: 'None noted' }}
Notes {{ $nb->notes }}
@endforeach
@endif {{-- MATERNAL COMPLICATIONS --}} @if($ma->complications->count())
@foreach($ma->complications as $c) @endforeach
When Type Severity Management Outcome
{{ $c->occurred_at?->format('d M H:i') ?? '-' }} {{ ucwords(str_replace('_',' ', $c->complication_type)) }} {{ ucfirst($c->severity ?? '-') }} {{ $c->management ?: '-' }} {{ ucfirst($c->outcome ?: '-') }}{{ $c->referred_out ? ' (Referred)' : '' }}
@endif {{-- HOSPITAL COURSE --}}

{{ $ma->discharge_summary ?? '-' }}

{{-- INVESTIGATIONS --}} @if(($visit?->labOrders?->count() ?? 0) || ($visit?->imagingRequests?->count() ?? 0))
@if($visit->labOrders->count()) @foreach($visit->labOrders as $lo) @endforeach
Lab Test Result Status
{{ $lo->test_name }} @if($lo->result && is_array($lo->result->results)) @php $res = $lo->result->results; @endphp @if(isset($res['generic'])) {{ $res['generic']['value'] ?? '-' }} {{ $res['generic']['unit'] ?? '' }} @else @foreach($res as $param) @if(is_array($param) && isset($param['name'])) {{ $param['short_code'] ?? $param['name'] }}: {{ $param['value'] ?? '-' }} {{ $param['unit'] ?? '' }}@if(!$loop->last), @endif @endif @endforeach @endif @elseif($lo->result) {{ $lo->result->results ?? '-' }} @else — @endif {{ ucfirst($lo->status) }}
@endif @if($visit->imagingRequests->count()) @foreach($visit->imagingRequests as $ir) @endforeach
Imaging Findings Impression
{{ $ir->imaging_type }} {{ $ir->report ? \Illuminate\Support\Str::limit($ir->report->findings, 150) : '—' }} {{ $ir->report->impression ?? '-' }}
@endif
@endif {{-- MEDICATIONS ON DISCHARGE --}} @if($dispDrugs->count())
@foreach($dispDrugs as $rx) @if($rx->instructions) @endif @endforeach
Medication Dose Route Frequency Duration Qty
{{ $rx->drug_name }} {{ $rx->dosage ?? '-' }} {{ $rx->route ?? '-' }} {{ $rx->frequency ?? '-' }} {{ $rx->duration ?? '-' }} {{ $rx->quantity ?? '-' }}
Instructions: {{ $rx->instructions }}
@endif

{{ $ma->discharge_instructions ?? '-' }}

{{ $ma->follow_up_plan ?? '-' }} @if($ma->postnatal_review_date) {{ "\n" }}Postnatal review: {{ $ma->postnatal_review_date->format('d M Y') }} @endif

{{-- SIGNATURES --}}

Discharged By:

{{ $ma->attendingProvider->name ?? auth()->user()->name ?? '-' }}

{{ $ma->discharge_date?->format('d M Y H:i') ?? '' }}

Mother / Next of Kin Signature:

Acknowledged receipt of discharge summary & medications

@include('partials._document-footer')
@endsection