{{-- ICTHospital - OPD history: tokens, times and payment per visit. Copyright (c) DEVtrust Part of ICTHospital Licensed under the GNU General Public License v3.0. --}} @extends('layouts.master') @section('content') @include('app.partials._alerts') @php($mins = fn ($a, $b) => ($a && $b) ? max(0, (int) floor(\Carbon\Carbon::parse($a)->diffInMinutes(\Carbon\Carbon::parse($b)))) : null)

OPD history

@php($waits = $visits->map(fn ($v) => $mins($v->checked_in_at, $v->consult_started_at))->filter(fn ($x) => $x !== null)) @if ($waits->isNotEmpty())

Average wait: {{ round($waits->avg()) }} min over {{ $waits->count() }} visit(s).

@endif
@forelse ($visits as $v) @php($p = $patients[$v->patient] ?? null) @php($inv = $v->payment_id ? ($invoices[$v->payment_id] ?? null) : null) @empty @endforelse @if ($invoices->isNotEmpty())@endif
TokenDate and timeInvoicePatient / MR / phoneConsultantCheck in / outWaiting / treatmentStatusPayment
{{ $v->token_no ?: '-' }} {{ $v->s_time ? \Carbon\Carbon::parse($v->s_time)->format('d M, H:i') : $v->date }} @if ($inv)#{{ $inv->id }}@endif {{ optional($p)->name }} / {{ optional($p)->patient_id }} / {{ optional($p)->phone }} {{ $doctorNames[$v->doctor] ?? '' }} {{ $v->checked_in_at ? \Carbon\Carbon::parse($v->checked_in_at)->format('H:i') : '-' }} / {{ $v->checked_out_at ? \Carbon\Carbon::parse($v->checked_out_at)->format('H:i') : '-' }} {{ $mins($v->checked_in_at, $v->consult_started_at) ?? '-' }} / {{ $mins($v->consult_started_at, $v->checked_out_at) ?? '-' }} min {{ ucfirst($v->status) }} {{ $inv ? number_format((float) $inv->gross_total, 2) . ' (' . $inv->settlement() . ')' : '' }}
No visits in this range.
Total{{ number_format($invoices->sum('gross_total'), 2) }}
@stop