@extends('layouts.app') @section('title', 'Inpatient Case Summary | ' . ($admission->patient->full_name ?? '')) @section('styles') @endsection @section('content') @php $patient = $admission->patient; $visit = $admission->visit; $consultation = $visit?->consultation; $triage = $visit?->triage; $labOrders = $visit?->labOrders ?? collect(); $imagingReqs = $visit?->imagingRequests ?? collect(); $prescriptions = $visit?->prescriptions ?? collect(); $invoice = $visit?->invoice; $isDischarged = $admission->status === 'discharged'; // ── Diagnosis: "whichever has been added" ────────────────────── // Structured ICD-10 (if a consultation exists on the linked encounter), // plus the admission's own free-text fields. Preference for the // headline: discharge (final) → admission (provisional) → ICD-10. $structuredDx = $consultation ? trim($consultation->formatted_diagnosis) : ''; $admitDx = trim($admission->diagnosis_on_admission ?? ''); $dischargeDx = trim($admission->discharge_diagnosis ?? ''); if ($dischargeDx !== '') { $primaryDx = $dischargeDx; $primaryDxLabel = 'Discharge (Final) Diagnosis'; } elseif ($admitDx !== '') { $primaryDx = $admitDx; $primaryDxLabel = 'Admission Diagnosis'; } elseif ($structuredDx !== '') { $primaryDx = $structuredDx; $primaryDxLabel = 'Diagnosis (ICD-10)'; } else { $primaryDx = ''; $primaryDxLabel = 'Diagnosis'; } // Vitals (latest triage on the linked encounter), only populated fields. $vitals = []; if ($triage) { if ($triage->blood_pressure_systolic && $triage->blood_pressure_diastolic) { $vitals[] = ['BP', $triage->blood_pressure_systolic . '/' . $triage->blood_pressure_diastolic . ' mmHg']; } if ($triage->pulse) $vitals[] = ['Pulse', $triage->pulse . ' bpm']; if ($triage->temperature) $vitals[] = ['Temp', $triage->temperature . '°C']; if ($triage->respiratory_rate) $vitals[] = ['RR', $triage->respiratory_rate . '/min']; if ($triage->oxygen_saturation) $vitals[] = ['SpO₂', $triage->oxygen_saturation . '%']; if ($triage->weight) $vitals[] = ['Wt', $triage->weight . ' kg']; } $admissionCode = 'IPD-' . str_pad((string) $admission->id, 6, '0', STR_PAD_LEFT); $payerLabel = match($invoice?->payment_mode) { 'insurance' => $invoice?->insuranceCompany?->name ?? 'Insurance', 'corporate' => 'Corporate', 'cash' => 'Cash', 'mpesa' => 'M-Pesa', 'bank_transfer' => 'Bank Transfer', 'waiver' => 'Waiver', default => ucfirst($invoice?->payment_mode ?? '—'), }; @endphp
| Name: | {{ $patient->full_name ?? '' }} | MRN: | {{ $patient->mrn ?? '' }} | Sex: | {{ ucfirst($patient->gender ?? '—') }} | Age: | {{ $patient->age ?? '—' }} |
| Admission: | {{ $admissionCode }} | Ward: | {{ $admission->ward->name ?? '—' }} | Bed: | {{ $admission->bed->bed_number ?? '—' }} | LOS: | {{ $admission->length_of_stay }} day(s) |
| Admitted: | {{ $admission->admission_date?->format('d M Y H:i') ?? '—' }} | Discharged: | {{ $admission->discharge_date?->format('d M Y H:i') ?? 'Still admitted' }} | Clinician: | {{ $admission->clinician->name ?? '—' }} | ||
Reason for Admission
{{ $admission->reason }}
{{ $primaryDxLabel }}
{{ $primaryDx ?: '—' }}
{{-- If both free-text diagnoses exist, show the admission one as context under the final --}} @if($dischargeDx !== '' && $admitDx !== '')Investigations & Results
| Type | Test / Study | Result / Findings |
|---|---|---|
| Lab | {{ $lab->test_name }} | {{ $lab->result ? 'Results Attached' : 'Pending' }} |
| Imaging |
{{ $img->imaging_type }}
@if($img->body_part) {{ $img->body_part }} @endif
|
{{ $img->report ? 'Report Attached' : 'Pending' }} |
Treatment / Medications
| Medication | Dose | Route | Frequency | Duration |
|---|---|---|---|---|
| {{ $rx->drug_name }} | {{ $rx->dosage ?? '—' }} | {{ $rx->route ?? '—' }} | {{ $rx->frequency ?? '—' }} | {{ $rx->duration ?? '—' }} |
Daily Ward Round Notes
Discharge Details
@php $parts = []; if ($admission->condition_on_discharge) $parts[] = 'Condition on discharge: ' . $admission->condition_on_discharge; if ($admission->discharge_summary) $parts[] = $admission->discharge_summary; if ($admission->discharge_instructions) $parts[] = 'Instructions: ' . $admission->discharge_instructions; if ($admission->follow_up_plan) $parts[] = 'Follow-up: ' . $admission->follow_up_plan; echo e(implode("\n", $parts)); @endphp