@extends('layouts.app') @section('title', 'Maternity Inpatient | ' . ($maternityAdmission->patient->full_name ?? '')) @section('styles') @endsection @section('content') @php $ma = $maternityAdmission; $p = $ma->patient; $discharged = app(\App\Services\VisitLockService::class)->isClosed($ma); $entries = $ma->labourMonitoring; @endphp {{-- Unified visit lock banner (read-only + reactivate for admins) --}} @include('partials._visit-lock-banner', ['entity' => $ma, 'type' => 'maternity']) {{-- ═══ PATIENT BALANCE SUMMARY (compact strip) ═══ --}} @include('partials._patient-balance-summary', ['patient' => $ma->patient]) {{-- Patient header --}} @php // Round 15: LMP/EDD live on the linked AncRegistration. Surface them // on the maternity banner so the clinician sees the dating without // having to navigate away. If the admission has no ANC registration // linked (walk-in delivery, no prior enrolment), $matReg will be // null and we show a prompt to set LMP inline. $matReg = $ma->ancRegistration; $matLmp = $matReg?->lmp; $matEdd = $matReg?->edd; $matCanEditLmpEdd = auth()->user()->hasAnyRole('Clinician', 'Nurse', 'Triage Nurse', 'Hospital Admin', 'Super Admin'); @endphp
{{ strtoupper(substr($p->first_name??'',0,1).substr($p->last_name??'',0,1)) }}

{{ $p->full_name }}

{{ $p->mrn }} · GA: {{ $ma->gestational_age_weeks ?? '-' }}wks · {{ $ma->reason_for_admission }}

{{ ucfirst(str_replace('_',' ',$ma->status)) }}
{{-- LMP / EDD strip (round 15). Shows the dating from the linked AncRegistration; clinicians can click "Edit" to update or set it for walk-in admissions that have no ANC enrolment yet. Note: the GA in the banner above remains the admission-day snapshot (gestational_age_weeks recorded on the MaternityAdmission) — clinically the relevant figure for the encounter. --}}
LMP
{{ $matLmp ? $matLmp->format('d M Y') : '— Not recorded' }}
EDD
{{ $matEdd ? $matEdd->format('d M Y') : '— Not recorded' }}
@if($matCanEditLmpEdd)
@endif
@if($matCanEditLmpEdd) {{-- Inline edit form — hidden by default; toggled by the button above. The EDD field auto-fills from LMP via Naegele's rule on input (LMP + 280 days). Clinician can override it if needed. --}} @endif
{{-- TABS --}}
@foreach(['overview'=>'Overview','labour'=>'WHO Labour Care Guide','delivery'=>'Delivery','orders'=>'Orders','postnatal'=>'Postnatal','billing'=>'Billing','discharge'=>'Discharge'] as $tab => $label) @endforeach
{{-- ═══ OVERVIEW TAB ═══ --}}

Admission Details

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

Reason: {{ $ma->reason_for_admission }}

Membranes: {{ ucfirst($ma->membrane_status ?? '-') }}

Cervix: {{ $ma->cervical_dilatation ?? '-' }}

Fetal: {{ ucfirst($ma->fetal_condition ?? '-') }}

Maternal: {{ ucfirst($ma->maternal_condition ?? '-') }}

Labour onset: {{ ucfirst(str_replace('_',' ',$ma->labour_onset ?? '-')) }}

Provider: {{ $ma->attendingProvider->name ?? '-' }}

@if($ma->ancRegistration)

ANC Summary

G/P: G{{ $ma->ancRegistration?->gravida ?? '-' }}P{{ $ma->ancRegistration?->parity ?? '-' }}

EDD: {{ $ma->ancRegistration?->edd?->format('d M Y') ?? '-' }}

ANC Visits: {{ $ma->ancRegistration?->visits()?->count() ?? 0 }}

Risk: {{ ucfirst($ma->ancRegistration?->risk_status ?? 'normal') }}

View full ANC profile →
@endif
{{-- ═══ WORKING DIAGNOSIS (editable inline) ═══ Round 16 — clinicians flagged that the Case Summary print was permanently disabled because there's no consultation gate on a maternity admission, so the diagnosis field on the admission itself was never visible/editable after admit. This card lets the attending clinician set or update the working diagnosis at any time during the stay, which unlocks the Case Summary print on the Billing tab and seeds the Final Diagnosis on Discharge. --}}

Working Diagnosis

Required to print the Case Summary (Billing tab) and pre-fills the Final Diagnosis at discharge.

@if($ma->diagnosis) Recorded @else Not recorded @endif
@if($discharged) {{-- Patient already discharged: show read-only --}}
{{ $ma->diagnosis ?? '— Not recorded —' }}
@elseif(auth()->user()->hasAnyRole('Clinician','Nurse','Triage Nurse','Hospital Admin','Super Admin'))
@csrf @method('PATCH')
@if($ma->diagnosis) Last updated: {{ $ma->updated_at?->format('d M Y H:i') }} @endif
@else
{{ $ma->diagnosis ?? '— Not recorded —' }}

Only clinicians and ward staff can edit the diagnosis.

@endif
{{-- ═══ WHO LABOUR CARE GUIDE TAB ═══ --}} {{-- ═══════════════════════════════════════════════════════════════════════ DELIVERY TAB Empty state: inline form to record the delivery + first newborn. Filled state: show the delivery summary + newborn cards + "Add Another Newborn" collapsible (for twins / multiples). ═══════════════════════════════════════════════════════════════════════ --}} {{-- ═══ ORDERS TAB (Lab / Imaging / Prescriptions) ═══ --}} {{-- ═══ BILLING TAB ═══ --}} {{-- Mirrors the IPD Billing tab (resources/views/inpatient/show.blade.php #tab-billing) — same line-items table, same payments table, same record-payment form, same role gating. No auto-billed lines: per CRH policy the cashier adds everything manually from the service catalog. The empty invoice container is created in MaternityController::inpatientShow(). --}} {{-- ═══ POSTNATAL TAB ═══ --}} {{-- ═══ DISCHARGE TAB ═══ --}} @endsection @push('scripts') @include('partials._tab-state-helper', ['defaultTab' => 'overview']) @endpush