@extends('layouts.app') @section('title', 'Invoice | ' . ($invoice->invoice_number ?? '')) @section('styles') @endsection @section('content') @php $hs = \App\Helpers\HospitalSettings::all(); $patient = $invoice->patient; $visit = $invoice->visit; // Resolve payment mode — invoice first, then visit, then actual payments $paymentMode = $invoice->payment_mode ?? $visit?->payment_mode ?? 'cash'; $insurancePayment = $invoice->payments->where('payment_method', 'insurance')->first(); if ($insurancePayment) { $paymentMode = 'insurance'; } $isInsurance = strtolower($paymentMode) === 'insurance'; // Resolve insurer name $insurerName = null; if ($isInsurance) { $insurerName = $invoice->insuranceCompany?->name ?? $visit?->insuranceCompany?->name ?? $insurancePayment?->description ?? 'Insurance'; } // Authorization code $authCode = $visit?->authorization_code ?? null; // Financial summary $subtotal = $invoice->subtotal ?? $invoice->total_amount; $discount = $invoice->discount_amount ?? 0; $waiver = $invoice->waiver_amount ?? 0; $grandTotal= $invoice->total_amount ?? 0; // Address split $addr = $hs['hospital_address'] ?? 'Utawala | 83 Park Estate, Kiguathi Rd'; if (str_contains($addr, '(')) { $addrLine1 = trim(substr($addr, 0, strpos($addr, '('))); $addrLine2 = trim(substr($addr, strpos($addr, '('))); } else { $addrLine1 = $addr; $addrLine2 = ''; } @endphp
{{ $hs['hospital_name'] ?? 'Clara Rosa Hospital Utawala' }}
{{ $addrLine1 }}
@if($addrLine2){{ $addrLine2 }}
@endifTel: {{ $hs['hospital_phone'] ?? '' }}
{{ $isInsurance ? 'INSURANCE INVOICE' : 'INVOICE' }}
No: {{ $invoice->invoice_number }}
Date: {{ $invoice->created_at->format('d M Y') }}
PATIENT INFORMATION
| Patient No.: | {{ $patient->mrn ?? '' }} |
| Full Name: | {{ $patient->full_name ?? '' }} |
| Date of Birth: | {{ $patient->date_of_birth ? \Carbon\Carbon::parse($patient->date_of_birth)->format('d M Y') : '-' }} |
| Gender: | {{ ucfirst($patient->gender ?? '-') }} |
| Clinician: | {{ $visit?->clinician?->name ?? '-' }} |
| Visit Date: | {{ $invoice->created_at->format('d M Y, H:i') }} |
INSURANCE INFORMATION
| Insurer: | {{ $insurerName }} |
| Scheme/Plan: | {{ $patient->insurance_scheme }} |
| Auth. Code: | {{ $authCode }} |
| Payer Type: | Insurance |
SERVICES RENDERED
| DESCRIPTION | UNIT PRICE (KES) | QTY | TOTAL (KES) |
|---|---|---|---|
| {{ $item->description }} @if($item->category && $item->category !== 'General') · {{ $item->category }} @endif | {{ number_format($item->unit_price) }} | {{ $item->quantity }} | {{ number_format($item->total) }} |
| Subtotal: | {{ number_format($subtotal) }} | ||
| Discount{{ $invoice->discount_reason ? ' ('.$invoice->discount_reason.')' : '' }}: | - {{ number_format($discount) }} | ||
| Waiver{{ $invoice->waiver_reason ? ' ('.$invoice->waiver_reason.')' : '' }}: | - {{ number_format($waiver) }} | ||
| AMOUNT DUE: | KES {{ number_format($grandTotal) }} | ||
PAYER INFORMATION
| PAYER NAME | CURRENCY | AMOUNT | |
|---|---|---|---|
| PLEASE PAY: | {{ $isInsurance ? $insurerName : ucfirst($paymentMode) }} | KES | {{ number_format($grandTotal) }} |
PAYMENT INFORMATION
Paybill: 522533
Account Number: 6346132
KCB Bank, Clara Rosa Hospital Utawala
Authorized Signature & Stamp
Patient / Guardian Signature
Date