@include('patient_mangement.patient._record_styles')
{{-- Hospital header on the printout only (shared print header). --}}
@include('layouts.print_header', ['printTitle' => ['all' => 'Admission record', 'medical' => 'Admission medical record', 'billing' => 'Admission billing'][$view_mode ?? 'all']])
{{-- ===== Header ===== --}}
{{ $p?->name }}
ID: {{ $p?->patient_id }}
@if ($p?->gender) · {{ ucfirst($p->gender) }} @endif
@if ($p?->dob) · {{ \Carbon\Carbon::parse($p->dob)->age }} years @endif
@if ($p?->phone) · {{ $p->phone }} @endif
@if ($admission->admission_no) · Admission #{{ $admission->admission_no }} @endif
{{ $admission->status }}
Admitted
{{ $fmtDate($admission->date_in ?? $admission->date) }}
Discharged
{{ $fmtDate($admission->date_out) ?? 'Still admitted' }}
Room / Bed
{{ $admission->Room?->name ?? '-' }}{{ $admission->bed ? ' · Bed ' . $admission->bed : '' }}
Doctor
{{ $admission->Dr?->name ?? '-' }}
@if ($admission->guardian_name)
Guardian
{{ $admission->guardian_name }}{{ $admission->relationship ? ' (' . $admission->relationship . ')' : '' }}{{ $admission->guardian_number ? ' · ' . $admission->guardian_number : '' }}
@endif
@if ($sections->isEmpty())
{{ ($view_mode ?? 'all') === 'billing' ? 'No charges recorded for this admission yet.' : 'Nothing has been recorded for this admission yet.' }}
@else
@endif
@php
// label => value pairs as a two-pairs-per-row bordered sheet; empty values left out
$kvt = function (array $pairs) {
$pairs = array_filter($pairs, fn ($v) => $v !== null && trim((string) $v) !== '');
if (!$pairs) {
return '
Nothing recorded.
';
}
$cells = [];
foreach ($pairs as $l => $v) {
$cells[] = '
' . e($l) . ' ' . e($v) . ' ';
}
return '
' . collect($cells)->chunk(2)->map(fn ($c) => '' . $c->implode('') . ($c->count() < 2 ? ' ' : '') . ' ')->implode('') . '
';
};
$staffName = fn ($id) => $id ? ($staffNames[$id] ?? $id) : null;
$yn = fn ($v, $text = null) => $v === null || $v === '' ? null : ($v . ($text ? ' — ' . $text : ''));
$head = fn($key) => '
' . e($sections[$key][0]) . '
' . $sections[$key][2] . ' ' . ($sections[$key][2] == 1 ? 'entry' : 'entries') . '
';
@endphp
{{-- ===== Billing summary ===== --}}
@if ($sections->has('billing'))
{!! $head('billing') !!}
Print bill
{{-- the other format, when wanted (default = Users → Receipt print) --}}
@if (!empty($payScope) && $billing['payable'] > 0)
{{ $payScope === 'pharmacy' ? 'Pay medication' : 'Pay all' }} · $ {{ number_format($billing['payable'], 2) }}
@endif
Billing Charge Paid Discount Balance Status
@foreach ($billing['rows'] as $b)
{{ $b['label'] }}@if ($b['note']){{ $b['note'] }}
@endif
$ {{ number_format($b['charge'], 2) }}
$ {{ number_format($b['paid'], 2) }}
$ {{ number_format($b['discount'], 2) }}
$ {{ number_format($b['balance'], 2) }}
{{ $b['balance'] <= 0.009 ? 'Paid' : ($b['paid'] > 0 ? 'Partially paid' : 'Unpaid') }}
@endforeach
TOTAL
$ {{ number_format($billing['total']['charge'], 2) }}
$ {{ number_format($billing['total']['paid'], 2) }}
$ {{ number_format($billing['total']['discount'], 2) }}
$ {{ number_format($billing['total']['balance'], 2) }}
@endif
{{-- ===== Billing statement (billing view): one table per bill type ===== --}}
@if ($sections->has('statement'))
{!! $head('statement') !!}
@include('bills.statements._by_type', [
'money' => fn($v) => '$ ' . number_format((float) $v, 2),
'fmt' => $fmtDate,
])
@endif
{{-- ===== Room history & transfers ===== --}}
@if ($sections->has('rooms'))
{!! $head('rooms') !!}
Type Room Bed From To Days @if ($showBill)Cost / day @endif
@foreach ($roomHistory as $r)
{{ ucfirst($r->type ?? 'admission') }}
{{ $r->room_name }}
{{ $r->bed }}
{{ $fmtDate($r->date_in) }}
{{ $fmtDate($r->date_out) ?? '—' }}
{{ $r->days }}
@if ($showBill)$ {{ number_format((float) $r->cost ?: (float) $r->room_rate, 2) }} @endif
@endforeach
@endif
{{-- ===== Consultation / history (Consultation tab) ===== --}}
@if ($sections->has('consult'))
{!! $head('consult') !!}
@foreach ($consultations as $c)
{{ \Carbon\Carbon::parse($c->created_at)->format('d M, Y h:i A') }} · {{ $c->doctor?->name }}
@foreach ([
'Chief complaint' => $c->chief_complaint,
'History' => $c->history,
'Physical examination' => $c->physical_examination,
'Diagnosis' => $c->diagnosisNames(),
'Treatment / plan' => $c->treatment_plan,
] as $label => $value)
@if (filled($value))
{{ $label }} {{ $value }}
@endif
@endforeach
@endforeach
@endif
{{-- ===== Discharge summary ===== --}}
@if ($sections->has('discharge'))
{!! $head('discharge') !!}
@foreach ([
'Discharge date' => $fmtDate($discharge->discharge_date),
'Days' => $discharge->days,
'Condition' => $discharge->con?->name ?? $discharge->patient_condition,
'Admission diagnosis' => $discharge->diagnosis_admission,
'Discharge diagnosis' => $discharge->discharge_diagnosis,
'Complication' => $discharge->complication_text ?: $discharge->complication,
'Discharge medication' => $discharge->discharge_medication,
] as $label => $value)
@if (filled($value))
{{ $label }} {{ $value }}
@endif
@endforeach
@endif
{{-- ===== Vital signs ===== --}}
@if ($sections->has('vitals'))
{!! $head('vitals') !!}
@foreach ($vitalsigns as $date => $entries)
{{ $fmtDate($date) }}
Time BP Pulse Temp Resp SpO₂ Weight Glucose FHR Observation By
@foreach ($entries as $vs)
{{ $fmtTime($vs->time) }} {{ $vs->blood_pressure }} {{ $vs->pulse }}
{{ $vs->temperature }} {{ $vs->respiratory }} {{ $vs->oxygen }}
{{ $vs->weight }} {{ $vs->glucose }} {{ $vs->fhr }}
{{ $vs->observation }} {{ $vs?->nurse?->name }}
@endforeach
@endforeach
@endif
{{-- ===== Doctor orders ===== --}}
@if ($sections->has('orders'))
{!! $head('orders') !!}
@foreach ($doctorOrders as $date => $entries)
{{ $fmtDate($date) }}
Time Order Drug Dose Route Instruction Status Ordered by
@foreach ($entries as $order)
{{ $fmtTime($order->time) }}
{{ ucwords(str_replace('_', ' ', $order->order_type)) }}
{{ $order->drug }} {{ $order->dose }} {{ $order?->form?->name }}
{{ $order->instruction }}@if ($order->order_type === 'give_medication' && $order->frequency_hours){{ $order->scheduleLabel() }}
@endif
{{ $order->status }}@if ($order->completed_by)by {{ $order->completer?->name }} · {{ \Carbon\Carbon::parse($order->completed_at)->format('d M, h:i A') }}
{{ $order->completion_note }}
@endif
{{ $order?->doctor?->name }}
@if ($order->doses->isNotEmpty())
{{-- the order's doses as their own table: due, given at, status, by whom, note --}}
# Due Given at Status By Note
@foreach ($order->doses as $i => $dz)
{{ $i + 1 }}
{{ \Carbon\Carbon::parse($dz->due_at)->format('d M, h:i A') }}
{{ $dz->given_at && $dz->status !== 'Due' ? \Carbon\Carbon::parse($dz->given_at)->format('d M, h:i A') : '' }}
{{ ['Due' => 'Not given', 'Stopped' => 'Order stopped'][$dz->status] ?? $dz->status }}
{{ $dz->status !== 'Due' ? $dz->nurse?->name : '' }}
{{ $dz->note }}
@endforeach
@endif
@endforeach
@endforeach
@endif
{{-- ===== Medication given (MAR) ===== --}}
@if ($sections->has('mar'))
{!! $head('mar') !!}
@foreach ($medications as $date => $entries)
{{ $fmtDate($date) }}
Time Drug Qty Dose Route Note Given by Status
@foreach ($entries as $med)
{{ $fmtTime($med->time) }}
{{-- picked drug → its product; old entries kept the product id in "drug"; written ones show as typed --}}
{{ $med->drugName() }}@if (!$med->product_id && !ctype_digit((string) $med->drug)) (written) @endif
{{ $med->quantity !== null ? $num($med->quantity) : '' }}
{{ $med->dose }} {{ $med?->form?->name }} {{ $med->note }}
{{ $med?->nurse?->name }}
{{ $med->status === 'Stopped' ? 'Stopped' : 'Given' }}
@if ($med->stoped_by)by {{ $med?->st?->name }}
@endif
@endforeach
@endforeach
@endif
{{-- ===== Prescriptions & pharmacy bill ===== --}}
@if ($sections->has('pres'))
{!! $head('pres') !!}
@php $presGrand = 0; @endphp
@foreach ($prescriptions as $pres)
@php
$pos = $pres->pharPos;
$lines = $pos
? $pos->pos_products->map(fn($l) => ['drug' => $l->prd?->name, 'qty' => $l->quantity, 'unit' => $l->measurement?->name, 'price' => $l->price])
: $pres->detail->map(fn($d) => ['drug' => $d->prd?->name, 'qty' => $d->quantity, 'unit' => $d->measurement?->name, 'price' => $d->prd?->selling_price ?? 0]);
$total = $lines->sum(fn($l) => $l['qty'] * $l['price']);
$presGrand += $total;
$st = $pos?->status ?? 'Not invoiced';
@endphp
{{ $pres->name }} · {{ $pres->typeLabel() }} · {{ $fmtDate($pres->date) }}
@if ($showBill){{ $pos ? 'Invoice · ' . $st : $st }} @endif
@if ($showBill)$ {{ number_format($total, 2) }} @endif
Drug Qty @if ($showBill)Price Amount @endif
@foreach ($lines as $l)
{{ $l['drug'] }} {{ $num($l['qty']) }} {{ $l['unit'] }}
@if ($showBill)$ {{ number_format($l['price'], 2) }} $ {{ number_format($l['qty'] * $l['price'], 2) }} @endif
@endforeach
@endforeach
@if ($showBill && $prescriptions->count() > 1)
Total medication $ {{ number_format($presGrand, 2) }}
@endif
@endif
{{-- ===== Laboratory & results ===== --}}
@if ($sections->has('labs'))
{!! $head('labs') !!}
@foreach ($labRequests as $date => $entries)
@foreach ($entries as $lab)
{{ $fmtDate($date) }} · {{ $lab->name }}
{{ $lab->status === 'Processed' ? 'Result ready' : ($lab->status ?: 'Pending') }}
@if ($showBill){{ $lab->payment_status }}
$ {{ number_format($lab->amount, 2) }} @endif
@if (!$showMed)
{{-- billing only: what was ordered, not the results --}}
Tests: {{ collect(explode(',', (string) $lab->routines))->filter()->implode(', ') ?: '—' }}
@elseif (isset($labResults[$lab->id]))
Investigation Result Normal range Unit
{{-- Grouped under titles like the lab result print (URINE ANALYSIS → Physical examination, CBC, RFT…). --}}
@foreach ($labResults[$lab->id]->groupBy('title') as $title => $group)
{{ $title }}
@foreach ($group->groupBy(fn($r) => $r->subtitle ?? '') as $subtitle => $subRows)
@if ($subtitle !== '')
{{ $subtitle }}
@endif
@foreach ($subRows as $res)
{{ $res->test }}
{!! strip_tags($res->result, '
{!! strip_tags((string) $res->normal_range, ' ') !!}
{{ $res->unit }}
@endforeach
@endforeach
@endforeach
@else
Tests: {{ collect(explode(',', (string) $lab->routines))->filter()->implode(', ') ?: '—' }} · no results entered yet
@endif
@endforeach
@endforeach
@endif
{{-- ===== Imaging ===== --}}
@if ($sections->has('images'))
{!! $head('images') !!}
Date Imaging Notes Report @if ($showBill)Payment @endif
@foreach ($images as $img)
{{ $fmtDate($img->date) }} {{ $img->type_name }} {{ $img->notes }}
{{ $img->status === 'Processed' ? 'Report ready' : ($img->status ?: 'Pending') }}
@if ($showBill){{ $img->payment_status }} @endif
@endforeach
@endif
{{-- ===== Services ===== --}}
@if ($sections->has('services'))
{!! $head('services') !!}
Date Services Notes @if ($showBill)Amount Payment @endif
@foreach ($services as $s)
{{ $fmtDate($s->date) }} {{ $s->service_names }} {{ $s->notes }}
@if ($showBill)
$ {{ number_format($s->rate, 2) }}
{{ $s->payment_status }}
@endif
@endforeach
@if ($showBill)
Total $ {{ number_format($services->sum('rate'), 2) }}
@endif
@endif
{{-- ===== Progress notes ===== --}}
@if ($sections->has('progress'))
{!! $head('progress') !!}
@foreach ($progressNotes as $date => $entries)
{{ $fmtDate($date) }}
@foreach ($entries as $note)
@php
$vitalsLine = collect(['BP' => $note->blood_pressure, 'Temp' => $note->temperature, 'Pulse' => $note->pulse, 'Resp' => $note->respiratory_rate, 'SpO₂' => $note->oxygen_saturation])
->filter()->map(fn($v, $k) => "$k: $v")->implode(' · ');
@endphp
{{ $fmtTime($note->time) }} · {{ $note?->user?->name }}
@foreach (['Subjective' => $note->subjective_note, 'Objective' => $note->objective_note, 'Assessment' => $note->assessment, 'Plan' => $note->treatment_plan, 'Vitals' => $vitalsLine, 'Medications given' => $note->medications_given, 'Procedures' => $note->procedures_done, 'Note' => $note->note, 'Follow-up' => $fmtDate($note->follow_up_date)] as $label => $value)
@if (filled($value))
{{ $label }}: {{ $value }}
@endif
@endforeach
@endforeach
@endforeach
@endif
{{-- ===== Insulin chart ===== --}}
@if ($sections->has('insulin'))
{!! $head('insulin') !!}
@foreach ($insulinChart as $date => $entries)
{{ $fmtDate($date) }}
Time Result Unit Observation By
@foreach ($entries as $ins)
{{ $fmtTime($ins->time) }} {{ $ins->result }} {{ $ins->unit }} {{ $ins->observation }} {{ $ins?->nurse?->name }}
@endforeach
@endforeach
@endif
{{-- ===== Fluid balance ===== --}}
@if ($sections->has('fluid'))
{!! $head('fluid') !!}
{{-- the IV fluid sheet (like Fluid chart → Print); older fluid-balance rows keep their in / out --}}
@php($fluidRows = $fluidChart->flatten())
Date & Time Fluid Type Volume Additives Rate(drops/min) Entered By Time Started Nurse Signature
@foreach ($fluidRows as $fl)
{{ \Carbon\Carbon::parse($fl->date)->format('d/m/Y') }} {{ $fl->time ? \Carbon\Carbon::parse($fl->time)->format('H:i') : '' }}
{{ $fl->fluid_type }}@if (!$fl->fluid_type && ($fl->oral || $fl->iv || $fl->urine))In: {{ $num((float) $fl->oral + (float) $fl->iv + (float) $fl->tube_feeding + (float) $fl->other_input) }} · Out: {{ $num((float) $fl->urine + (float) $fl->vomit + (float) $fl->diarrhea + (float) $fl->other_output) }} @endif
{{ $fl->volume }} {{ $fl->additives }} {{ $fl->rate }}
{{ $fl?->nurse?->name }}
{{ $fl->time_started ? \Carbon\Carbon::parse($fl->time_started)->format('d/m H:i') : '' }}
{{ $fl->time_started ? $fl?->starter?->name : '' }}
@if ($fl->observation)
Note: {{ $fl->observation }}
@endif
@endforeach
@endif
{{-- ===== Products used ===== --}}
@if ($sections->has('products'))
{!! $head('products') !!}
@foreach ($productsUsed as $date => $entries)
{{ $fmtDate($date) }}
Product Quantity Note By
@foreach ($entries as $prod)
{{ $prod?->product?->name }} {{ $num($prod->quantity) }} {{ $prod->note }} {{ $prod?->user?->name }}
@endforeach
@endforeach
@endif
{{-- ===== Operations ===== --}}
@if ($sections->has('operations'))
{!! $head('operations') !!}
Date Operation Doctor @if ($showBill)Amount Payment @endif @if ($showMed)Notes @endif
@foreach ($operations as $op)
{{ $fmtDate($op->date) }}
{{ $op->op?->name ?? 'Operation' }}@if ($op->op?->Cat){{ $op->op->Cat->name }} @endif
{{ $op->doctor?->name }}
@if ($showBill)${{ number_format($op->rate, 2) }} {{ $op->payment_status ?: 'Pending' }} @endif
@if ($showMed){{ $op->notes }} @endif
@endforeach
{{-- each operation's profile: pre / intra / post-operation and observations --}}
@if ($showMed)
@foreach ($operations as $op)
@php($od = $opDetails[$op->id] ?? null)
{{ $op->op?->name ?? 'Operation' }} — {{ $fmtDate($op->date) }}{{ $op->doctor?->name ? ' · Dr ' . $op->doctor->name : '' }}
Pre-operation
{!! $kvt($od && $od['pre'] ? [
'Date / time' => trim($fmtDate($od['pre']->date) . ' ' . $fmtTime($od['pre']->time)),
'Anesthesia' => $od['pre']->anesthesia_type, 'Informed consent' => $od['pre']->informed_consent,
'Fasting' => $od['pre']->fasting, 'Shaving' => $od['pre']->shaving, 'Catheterisation' => $od['pre']->catheterisation,
'IV line fixed' => $od['pre']->iv_line_fixed, 'IV line running' => $od['pre']->iv_line_running,
'HB' => $od['pre']->hb, 'Blood group' => $od['pre']->blood_group, 'Blood units' => $od['pre']->blood_units,
'Fasting blood sugar' => $od['pre']->fasting_blood_sugar, 'Random blood sugar' => $od['pre']->random_blood_sugar,
'Allergy' => $yn($od['pre']->allergy, $od['pre']->allergt_text), 'Chronic illness' => $yn($od['pre']->chronic_illness, $od['pre']->chronic_illness_text),
'Anesthetic risk' => $yn($od['pre']->anesthetic_risk, $od['pre']->anesthetic_risk_text),
'BP' => $od['pre']->blood_pressure, 'Pulse' => $od['pre']->pulse, 'Temperature' => $od['pre']->temperature,
'Respiratory' => $od['pre']->respiratory, 'Weight' => $od['pre']->weight, 'Others' => $od['pre']->others,
] : []) !!}
Intra-operation
{!! $kvt($od && $od['intra'] ? [
'Date / time' => trim($fmtDate($od['intra']->date) . ' ' . $fmtTime($od['intra']->time)),
'Operating doctor' => $staffName($od['intra']->operating_doctor), 'Anesthetist' => $staffName($od['intra']->anesthetist),
'Assistant' => $staffName($od['intra']->assistant), 'Assistant 2' => $staffName($od['intra']->assistant_2),
'Induction drug' => $od['intra']->induction_drug, 'Maintenance drug' => $od['intra']->maintenance_drug,
'Operative drug' => $od['intra']->operative_drug, 'Surgery time' => $od['intra']->surgery_time,
'Blood loss' => $od['intra']->blood_loss, 'Patient condition' => $od['intra']->patient_condition,
'Special instructions' => $od['intra']->special_instructions,
] : []) !!}
Post-operation
{!! $kvt($od && $od['post'] ? [
'Provisional diagnosis' => $od['post']->provisional_diagnosis, 'Definitive diagnosis' => $od['post']->definitive_diagnosis,
'Surgical procedure' => $od['post']->surgical_procedure, 'Procedure report' => $od['post']->procedure_report,
'Post-operative orders' => $od['post']->post_operative_order, 'Post-operative intensive care' => $od['post']->post_operative_intensive,
] : []) !!}
@if ($od && $od['obs']->count())
Observations
Date Time BP Pulse Temp Resp Notes
@foreach ($od['obs'] as $o)
{{ $fmtDate($o->date) }} {{ $fmtTime($o->time) }} {{ $o->blood_pressure }} {{ $o->pulse }}
{{ $o->temperature }} {{ $o->respiratory }} {{ $o->notes }}
@endforeach
@endif
@endforeach
@endif
@endif
{{-- ===== Delivery ===== --}}
@if ($sections->has('deliveries'))
{!! $head('deliveries') !!}
Date Delivery mode @if ($showBill)Amount Payment @endif @if ($showMed)Delivery note @endifBy
@foreach ($deliveries as $d)
{{ $fmtDate($d->date) }}
{{ $d->mode?->name }}
@if ($showBill)${{ number_format($d->rate, 2) }} {{ $d->payment_status ?: 'Pending' }} @endif
@if ($showMed){{ $d->notes }} @endif
{{ $d->user?->name }}
@endforeach
{{-- each delivery: pre-delivery checks (labour progress) and the post-delivery record --}}
@if ($showMed)
@foreach ($deliveries as $d)
@php($dd = $deliveryDetails[$d->id] ?? null)
Delivery — {{ $fmtDate($d->date) }}{{ $d->mode?->name ? ' · ' . $d->mode->name : '' }}
Pre-delivery
@if ($dd && $dd['pre']->count())
Date Time FHR Vulva Cervical dilation Effacement Descent Membranes Presentation Notes
@foreach ($dd['pre'] as $pr)
{{ $fmtDate($pr->date) }} {{ $fmtTime($pr->time) }} {{ $pr->fhr }} {{ $pr->vulva_condition }}
{{ $pr->cervical_dilation }} {{ $pr->cervical_effacement }} {{ $pr->descent }}
{{ $pr->membrane_condition }} {{ $pr->presentation }} {{ $pr->notes }}
@endforeach
@else
Nothing recorded.
@endif
Post-delivery
{!! $kvt($dd && $dd['post'] ? [
'Born' => trim($fmtDate($dd['post']->dob) . ' ' . $fmtTime($dd['post']->dob_time)),
'Delivery mode' => $dd['post']->mode_name, 'Baby sex' => $dd['post']->baby_sex,
'Baby weight' => $dd['post']->baby_weight ? $dd['post']->baby_weight . ' kg' : null, 'APGAR score' => $dd['post']->apgar_score,
'Placenta expressed' => $dd['post']->placenta_expressed, 'Episiotomy' => $dd['post']->episiotomy, 'Repaired' => $dd['post']->repaired,
'Complication' => $yn($dd['post']->complication, $dd['post']->complication_text),
'Midwife' => $staffName($dd['post']->midwife), 'Supervisor' => $staffName($dd['post']->supervisor),
] : []) !!}
@endforeach
@endif
@endif