@extends('layouts.master') @section('title', $title) @section('page_css') @endsection @section('content') @php $ppPatientLine = collect([$patient->name, 'ID ' . $patient->patient_id, ucfirst((string) $patient->gender) ?: null, $age, $patient->phone])->filter()->implode(' · '); $fmt = fn ($d) => $d ? \Carbon\Carbon::parse($d)->format('d M, Y') : '-'; $money = fn ($v) => '$ ' . number_format((float) $v, 2); $female = strtolower((string) $patient->gender) === 'female'; $kinds = [ 'visit' => ['Visit', 'ti-stethoscope', 'primary'], 'admission' => ['Admission', 'ti-bed', 'warning'], 'emergency' => ['Emergency', 'ti-ambulance', 'danger'], ]; $balancePill = function ($m) use ($money) { if (!$m) return ''; if ($m['balance'] > 0.009) return 'Owes ' . $money($m['balance']) . ''; return 'Paid'; }; @endphp {{-- ===== Who the patient is + what you can do ===== --}}
{{ mb_strtoupper(mb_substr($patient->name, 0, 1)) }}

{{ $patient->name }} @if ($inside) In hospital now @endif

{{ $patient->patient_id }} @if ($patient->gender) {{ ucfirst($patient->gender) }}@endif @if ($age) {{ $age }}@endif @if ($patient->phone) {{ $patient->phone }}@endif @if ($patient->address) {{ $patient->address }}@endif Registered {{ $fmt($patient->created_at) }}
@if ($newAppointment) New appointment @endif @if ($newAdmission) Admit patient @endif @if ($newEmergency) Emergency @endif @if ($statement) Statement / pay @endif
@if ($show['visits'])
Visits
{{ $visits->count() }}
last {{ $lastVisit ? $fmt($lastVisit['date']) : 'never' }}
@endif @if ($show['admissions'])
Admissions
{{ $admissions->count() }}
{{ $inside ? 'admitted since ' . $fmt($inside['date_in']) : 'not admitted now' }}
@endif @if ($show['emergency'])
Emergencies
{{ $emergencies->count() }}
 
@endif @if ($canFinancial && $totals)
Total billed
{{ $money($totals['charge']) }}
paid {{ $money($totals['paid']) }} · discount {{ $money($totals['discount']) }}
Balance owed
{{ $money($totals['balance']) }}
{{ $totals['balance'] > 0.009 ? 'not paid yet' : 'nothing owed' }}
@endif
{{-- ===== Tabs ===== --}} @php // each tab has its own permission (patient-profile-tab-* / -medical / -financial); the first one shown opens $tabs = collect([ 'overview' => [$show['history'], 'ti-timeline', 'History', null, null], 'visits' => [$show['visits'], 'ti-stethoscope', 'Visits', $visits->count(), 'primary'], 'admissions' => [$show['admissions'], 'ti-bed', 'Admissions', $admissions->count(), 'warning'], 'emergency' => [$show['emergency'], 'ti-ambulance', 'Emergency', $emergencies->count(), 'danger'], 'medical' => [$canMedical, 'ti-heartbeat', 'Medical history', null, null], 'financial' => [$canFinancial, 'ti-cash', 'Financial history', null, null], ])->filter(fn ($t) => $t[0]); $firstTab = $tabs->keys()->first(); @endphp @if ($tabs->isEmpty())
No part of the patient profile is given to your role — ask an admin.
@endif
{{-- History: everything, newest first --}} @if ($show['history'])

Everything that happened to this patient, newest first. Click Open to manage it, Record to see all of its information on one page.

@if ($timeline->isEmpty())
No visits, admissions or emergencies yet.
@else
@foreach ($timeline as $t) @php [$kLabel, $kIcon, $kColor] = $kinds[$t['kind']]; $it = $t['item']; @endphp
{{ $kLabel }} {{ $fmt($t['date']) }}
{{ $t['title'] }}
@if ($t['sub'])
{{ $t['sub'] }}
@endif
@if ($canFinancial){!! $balancePill($it['money'] ?? null) !!}@endif @if (!empty($it['record'])) Record@endif @if (!empty($it['open'])) Open@endif
@endforeach
@endif
@endif {{-- Visits --}} @if ($show['visits'])
Visits (appointments)
@if ($newAppointment) New appointment@endif
@if ($canFinancial)@endif @forelse ($visits as $v) @if ($canFinancial) @endif @empty @endforelse
DateNo.Doctor / departmentTypeComplaint / diagnosisSeenChargeBalance
{{ $fmt($v['date']) }} #{{ $v['no'] }} {{ $v['doctor'] ?? '-' }}
{{ $v['department'] }}
{{ $v['type'] ?? '-' }} {{ $v['diagnosis'] ?: ($v['complaint'] ?: '-') }} {{ $v['entry'] === 'Entered' ? 'Seen' : 'Not seen' }}{{ $v['money'] ? $money($v['money']['charge']) : '-' }} {!! $balancePill($v['money']) ?: '-' !!} @if ($v['record']) Record@endif @if ($v['open']) Open@endif
No visits yet.
@endif {{-- Admissions --}} @if ($show['admissions'])
Admissions
@if ($newAdmission) Admit patient@endif
@if ($canFinancial)@endif @forelse ($admissions as $a) @if ($canFinancial) @endif @empty @endforelse
No.AdmittedDischargedDaysDoctorRoom / bedStatusChargeBalance
#{{ $a['no'] }} {{ $fmt($a['date_in']) }} {{ $a['date_out'] ? $fmt($a['date_out']) : 'Still admitted' }} {{ $a['days'] }} {{ $a['doctor'] ?? '-' }} {{ $a['room'] }} {{ $a['status'] }}{{ $a['money'] ? $money($a['money']['charge']) : '-' }} {!! $balancePill($a['money']) ?: '-' !!} @if ($a['record']) Record@endif @if ($a['open']) Open@endif
Never admitted.
@endif {{-- Emergency --}} @if ($show['emergency'])
Emergency
@if ($newEmergency) New emergency@endif
@if ($canFinancial)@endif @forelse ($emergencies as $e) @if ($canFinancial) @endif @empty @endforelse
No.ArrivedLeftDoctorComplaintStatusChargeBalance
#{{ $e['no'] }} {{ $fmt($e['date']) }} {{ $e['date_out'] ? $fmt($e['date_out']) : '-' }} {{ $e['doctor'] ?? '-' }} {{ $e['complaint'] ?: '-' }} {{ $e['status'] }}{{ $e['money'] ? $money($e['money']['charge']) : '-' }} {!! $balancePill($e['money']) ?: '-' !!}@if ($e['open']) Open@endif
No emergency visits.
@endif {{-- Medical history: one sub-tab per kind of record, each searchable and printable --}} @if ($canMedical) @php $md = $medical; // "Admission #3" badge, linked to that section of it when allowed $src = function ($x) { $text = e($x['from']) . ($x['no'] ? ' #' . e($x['no']) : ''); return $x['open'] ? '' . $text . '' : '' . $text . ''; }; $at = fn ($v) => $v ? \Carbon\Carbon::parse($v)->format('d M, Y') . (strlen($v) > 10 ? ' · ' . \Carbon\Carbon::parse($v)->format('h:i A') : '') : '-'; $statusPill = fn ($st) => '' . e($st) . ''; $hist = array_filter($md['history'], fn ($v) => trim((string) $v) !== ''); $subs = [ 'summary' => ['ti-clipboard-heart', 'Summary', count($md['diagnoses']) + count($hist)], 'vitals' => ['ti-heartbeat', 'Vital signs', count($md['vitals'])], 'labs' => ['ti-microscope', 'Laboratory', count($md['labs'])], 'images' => ['ti-photo', 'Imaging', count($md['images'])], 'pres' => ['ti-prescription', 'Prescriptions', count($md['prescriptions'])], 'orders' => ['ti-clipboard-list', 'Doctor orders', count($md['orders'])], 'given' => ['ti-pill', 'Medication given', count($md['given'])], 'fluid' => ['ti-droplet', 'Fluid chart', count($md['fluid'])], 'insulin' => ['ti-vaccine', 'Insulin chart', count($md['insulin'])], 'ops' => ['ti-scissors', 'Operations', count($md['operations'])], ]; $secHead = fn ($key, $help, $search = null) => '
' . '
' . e($subs[$key][1]) . '
' . e($help) . '
' . '
' . ($search ? '' : '') . '
'; @endphp
{{-- Summary: diagnoses + past history --}}
{!! $secHead('summary', 'Diagnoses from every visit and the latest past history written') !!}
Diagnoses
@forelse ($md['diagnoses'] as $d)
{{ $d['name'] }}{{ $fmt($d['date']) }}
@empty
No diagnosis recorded.
@endforelse
Past history
@forelse ($hist as $label => $text)
{{ $label }}
{{ $text }}
@empty
No past history recorded.
@endforelse
{{-- Vital signs --}}
{!! $secHead('vitals', 'Every vital sign taken in a visit, an admission or emergency — newest first', 'Find…') !!}
@forelse ($md['vitals'] as $v) @empty @endforelse
Date / timeTaken inTempBPPulseRespSpO₂WeightOther
{{ $at($v['at']) }}{!! $src($v) !!} {{ $v['temp'] ? $v['temp'] . ' °C' : '-' }}{{ $v['bp'] ?: '-' }} {{ $v['pulse'] ?: '-' }}{{ $v['resp'] ?: '-' }} {{ $v['spo2'] ? $v['spo2'] . '%' : '-' }} {{ $v['weight'] ? $v['weight'] . ' kg' : '-' }}{{ $v['other'] ?: '-' }}
No vital signs recorded.
{{-- Laboratory --}}
{!! $secHead('labs', 'Every lab request — View shows its results; Print includes all results', 'Find a test…') !!}
@php $statusColor = ['Processed' => 'success', 'Draft' => 'info']; // "4.0 - 11.0" → is the value outside it? $outOfRange = function ($value, $range) { if (!is_numeric($value) || !preg_match('/^\s*(-?[\d.]+)\s*-\s*(-?[\d.]+)\s*$/', (string) $range, $m)) return false; return $value < (float) $m[1] || $value > (float) $m[2]; }; @endphp @forelse ($md['labs'] as $l) @empty @endforelse
DateRequestTestsStatus
{{ $fmt($l['date']) }} #{{ $l['no'] }}
@if ($l['open']){{ $l['from'] }}@else{{ $l['from'] }}@endif
{{ $l['tests'] ?: '-' }} {{-- the results, copied into the modal by "View" (also what "Find a test" searches) --}}
@if ($l['rows']) @foreach ($l['rows'] as $r) @if ($r['type'] === 'header') @else @php $bad = $outOfRange($r['value'], $r['normal_range']); @endphp @endif @endforeach
TestResultNormal range
{{ $r['title'] }}
{{ $r['name'] }} {{ $r['value'] }} {{ $r['unit'] }}@if ($bad) @endif {{ $r['normal_range'] ?: '-' }}
@else
{{ $l['status'] === 'Draft' ? 'The lab has started this request — results are not completed yet.' : 'Waiting for the lab — no results yet.' }}
@endif
{{ $l['status'] === 'Processed' ? 'Completed' : $l['status'] }}
No lab requests.
{{-- Imaging --}}
{!! $secHead('images', 'Every imaging exam with its report', 'Find an exam…') !!}
@forelse ($md['images'] as $i) @empty @endforelse
DateExamFromStatusReport
{{ $fmt($i['date']) }}
#{{ $i['no'] }}
{{ $i['exam'] }}{!! $src($i['src']) !!}{!! $statusPill($i['status'] === 'Processed' ? 'Completed' : $i['status']) !!} @forelse ($i['report'] as $r)
@if ($r['name']){{ $r['name'] }}: @endif{{ $r['text'] }}
@empty{{ $i['notes'] ?: 'No report yet.' }}@endforelse
No imaging.
{{-- Prescriptions --}}
{!! $secHead('pres', 'Every prescription with where it was written — appointment, admission or emergency', 'Find a drug…') !!}
@forelse ($md['prescriptions'] as $h) @foreach ($h['drugs'] as $d) @if ($loop->first) @endif @endforeach @empty @endforelse
DateFromDrugDoseFrequencyDurationQtyInstruction
{{ $fmt($h['date']) }}
Rx #{{ $h['no'] }}{{ $h['type'] === 'POS' ? ' · pharmacy sale' : '' }}
{!! $src($h) !!}{{ $d->name ?? '-' }}{{ $d->dose ?: '-' }}{{ $d->frequency ?: '-' }} {{ $d->duration ? (is_numeric($d->duration) ? $d->duration . ' days' : $d->duration) : '-' }}{{ $d->quantity ? $d->quantity + 0 : '-' }}{{ $d->instruction ?: '' }}
No prescriptions.
{{-- Doctor orders --}}
{!! $secHead('orders', 'Orders written for admissions and emergency, with who completed them', 'Find…') !!}
@forelse ($md['orders'] as $o) @empty @endforelse
Date / timeFromOrderDose / routeHowDoctorStatus
{{ $at($o['at']) }}{!! $src($o) !!} {{ $o['drug'] ?: $o['type'] }}
{{ $o['type'] }}{{ $o['instruction'] ? ' — ' . $o['instruction'] : '' }}
{{ collect([$o['dose'], $o['route']])->filter()->implode(' · ') ?: '-' }}{{ $o['how'] ?: '-' }}{{ $o['doctor'] ?? '-' }} {!! $statusPill($o['status']) !!}@if ($o['done'])
{{ $o['done'] }}
@endif
No doctor orders.
{{-- Medication given (ward chart) --}}
{!! $secHead('given', 'Medication given on the ward during admissions', 'Find a drug…') !!}
@forelse ($md['given'] as $m) @empty @endforelse
Date / timeFromDrugDoseRouteGiven byStatus
{{ $at($m['at']) }}{!! $src($m) !!}{{ $m['drug'] ?: '-' }}@if ($m['note'])
{{ $m['note'] }}
@endif
{{ $m['dose'] ?: '-' }}{{ $m['route'] ?: '-' }}{{ $m['by'] ?? '-' }}{!! $statusPill($m['status'] ?: '-') !!}
No medication given on the ward.
{{-- Fluid chart --}}
{!! $secHead('fluid', 'IV fluids, intake and output recorded during admissions') !!}
@forelse ($md['fluid'] as $f) @php $bal = $f['in_total'] - $f['out_total']; @endphp @empty @endforelse
Date / timeFromFluidIntakeOutputBalanceObservation
{{ $at($f['at']) }}{!! $src($f) !!}{{ $f['fluid'] ?: '-' }} {{ $f['in'] ?: '-' }}{{ $f['out'] ?: '-' }} {{ ($f['in'] || $f['out']) ? ($bal > 0 ? '+' : '') . ($bal + 0) . ' ml' : '-' }} {{ $f['note'] }}{{ $f['by'] ? ' — ' . $f['by'] : '' }}
No fluid chart entries.
{{-- Insulin chart --}}
{!! $secHead('insulin', 'Blood sugar results and insulin given during admissions') !!}
@forelse ($md['insulin'] as $i) @empty @endforelse
Date / timeFromResultInsulin (units)ObservationBy
{{ $at($i['at']) }}{!! $src($i) !!}{{ $i['result'] ?: '-' }} {{ $i['unit'] ?: '-' }}{{ $i['note'] }}{{ $i['by'] ?? '-' }}
No insulin chart entries.
{{-- Operations --}}
{!! $secHead('ops', 'Every operation of this patient') !!}
@forelse ($md['operations'] as $o) @empty @endforelse
DateFromOperationSurgeonStatusNotes
{{ $fmt($o['date']) }}
#{{ $o['no'] }}
{!! $src($o) !!}{{ $o['name'] }} {{ $o['surgeon'] ?? '-' }}{!! $statusPill($o['status']) !!}{{ $o['notes'] }}
No operations.
{{-- the hospital header for the section prints (shared print header) --}}
@include('layouts.print_header')
@endif {{-- Financial history --}} @if ($canFinancial)
Financial history
Every visit, admission and emergency with what it cost and what is still owed. Click a row to see its bills.
@if ($statement) Pay / full statement@endif
@forelse ($episodes as $i => $e) @empty @endforelse @if ($episodes->isNotEmpty()) @endif
DateWhatChargePaidDiscountBalance
{{ $fmt($e['date']) }} {{ $e['title'] }}
{{ $e['subtitle'] ?? '' }}
{{ $money($e['totals']['charge']) }} {{ $money($e['totals']['paid']) }} {{ $money($e['totals']['discount']) }} {{ $money($e['totals']['balance']) }}
@foreach ($e['items'] as $b) @endforeach
{{ $b['label'] }}{{ $fmt($b['date']) }} {{ $money($b['charge']) }}{{ $money($b['paid']) }} {{ $money($b['discount']) }}{{ $money($b['balance']) }}
No bills yet.
Total{{ $money($totals['charge']) }}{{ $money($totals['paid']) }} {{ $money($totals['discount']) }}{{ $money($totals['balance']) }}
@endif
{{-- one lab request's results (filled by ppLab) --}} @if (!empty($md['labs']) && $md['labs']->isNotEmpty()) @endif @endsection @section('page_js') @endsection