@extends('layouts.master') @section('title', 'Admission record') @section('content')
{{-- Admission lists at a glance — click a card to pick admissions from it. --}}
@foreach ($record_cards as $key => $card)
{{ $card['label'] }}

{{ number_format($card['count']) }}

@if (($status_filter ?? 'admitted') === $key) @endif
@endforeach
{{-- Only the views this user may see (admission-record-medical / -billing). --}} @if (count($view_modes) === 1) @endif
@if (isset($admission)) @php $p = $admission->Patient; $fmtDate = fn($d) => $d ? \Carbon\Carbon::parse($d)->format('d M, Y') : null; $fmtTime = fn($t) => $t ? \Carbon\Carbon::parse($t)->format('h:i A') : ''; $num = fn($v) => rtrim(rtrim(number_format((float) $v, 2), '0'), '.'); // Only sections that actually have data are shown. $count = fn($grouped) => $grouped->sum(fn($g) => $g->count()); $labCount = $labRequests->sum(fn($g) => $g->count()); $showMed = ($view_mode ?? 'all') !== 'billing'; $showBill = ($view_mode ?? 'all') !== 'medical'; $sections = collect([ 'billing' => ['Billing summary', 'ti-cash', $showBill ? $billing['rows']->count() : 0], // billing view only: every bill, type by type, like the patient statement 'statement'=> ['Billing statement', 'ti-file-invoice', !$showMed ? ($typeGroups ?? collect())->sum(fn($g) => $g->count()) : 0], 'rooms' => ['Room history & transfers', 'ti-bed', $roomHistory->count()], 'consult' => ['Consultation / history', 'ti-stethoscope', $consultations->count()], 'discharge'=> ['Discharge summary', 'ti-door-exit', $discharge ? 1 : 0], 'vitals' => ['Vital signs', 'ti-heartbeat', $count($vitalsigns)], 'orders' => ['Doctor orders', 'ti-clipboard-list', $count($doctorOrders)], 'mar' => ['Medication given', 'ti-pill', $count($medications)], // pharmacy bill: billing view only — medical-only users see what was given in "Medication given" 'pres' => ['Prescriptions & pharmacy bill', 'ti-receipt', $showBill ? $prescriptions->count() : 0], 'labs' => ['Laboratory & results', 'ti-microscope', $labCount], 'images' => ['Imaging', 'ti-photo', $images->count()], 'services' => ['Services', 'ti-bell', $services->count()], 'progress' => ['Progress notes', 'ti-notes', $count($progressNotes)], 'insulin' => ['Insulin chart', 'ti-vaccine', $count($insulinChart)], 'fluid' => ['IV fluid chart', 'ti-droplet', $count($fluidChart)], 'products' => ['Products used', 'ti-package', $count($productsUsed)], 'operations' => ['Operations', 'ti-scissors', $operations->count()], 'deliveries' => ['Delivery', 'ti-baby-carriage', $deliveries->count()], ])->filter(fn($s) => $s[2] > 0) // Billing only: the summary, then the statement tables — no clinical charts. ->filter(fn($s, $key) => $showMed || in_array($key, ['billing', 'statement'])) // each medical section has its own permission (admission-record-sec-), e.g. vital signs only ->filter(fn($s, $key) => in_array($key, ['billing', 'statement']) || auth()->user()->can('admission-record-sec-' . $key)); $statusCls = $admission->status === 'Discharged' ? 'success' : 'danger'; @endphp
@if (!empty($payScope)) @endif @endif
@if (isset($admission) && !empty($billing)) {{-- the bill as an 80mm POS slip (Print bill → POS) --}} @include('partials.pos_bill', [ 'posTitle' => 'Admission bill', 'posInfo' => ['Admission No' => $admission->admission_no ?: $admission->id, 'Patient' => $admission->Patient?->name . ($admission->Patient?->patient_id ? ' (' . $admission->Patient->patient_id . ')' : ''), 'Admitted' => \Carbon\Carbon::parse($admission->date_in ?? $admission->date)->format('d M, Y'), 'Discharged' => $admission->date_out ? \Carbon\Carbon::parse($admission->date_out)->format('d M, Y') : 'still admitted', 'Room' => trim(($admission->Room?->name ?? '') . ($admission->bed ? ' · bed ' . $admission->bed : '')), 'Doctor' => $admission->Dr?->name], 'posLines' => collect($billing['rows'])->filter(fn ($r) => $r['charge'] > 0.009)->map(fn ($r) => [$r['label'], $r['charge']])->values()->all(), 'posTotals' => $billing['total'], ]) @endif @endsection @section('page_js') @endsection