@extends('backend.template.layouts.template-base') @section('title', $printDocumentTitle ?? 'Lab Report') @section('styles') @php $reportPrintPageSize = $printSettings['page_size'] ?? 'A4'; $reportPrintOrientation = $printSettings['orientation'] ?? 'portrait'; @endphp @endsection @section('content') @php $patient = $bill->patient; $patientName = $reportPatientName ?? ($patient ? (trim($patient->name ?? '') ?: trim(($patient->title ?? '') . ' ' . ($patient->first_name ?? '') . ' ' . ($patient->last_name ?? ''))) : '-'); $demo = $patientDemo ?? []; $ageYears = $demo['ageYears'] ?? $patient?->age; $sexLetter = $demo['sexLetter'] ?? ($patient && $patient->sex ? strtoupper(substr((string) $patient->sex, 0, 1)) : '—'); $sexLabel = $demo['sexLabel'] ?? ($patient && $patient->sex ? strtoupper((string) $patient->sex) : '—'); $sexIsFemale = $demo['sexIsFemale'] ?? false; $sexIsMale = $demo['sexIsMale'] ?? false; $ageSex = $demo['ageSex'] ?? ($ageYears !== null ? $ageYears . ' YRS / ' . $sexLetter : '— / ' . $sexLetter); $regNo = $bill->id; $lineCode = $lineCode ?? ($bill->transaction?->dcn ?: 'L1'); $billNav = array_merge([ 'prev' => null, 'next' => null, 'prev_report_url' => null, 'next_report_url' => null, 'prev_edit_url' => null, 'next_edit_url' => null, ], $billNav ?? []); $goToMode = $goToMode ?? old('mode', 'daily'); $goToDateDisplay = $goToDateDisplay ?? ($bill->created_at?->format('d/m/Y') ?? now()->format('d/m/Y')); $printReadyIds = $printReadyIds ?? []; $printReadyConfigured = is_array($bill->result_panel_config ?? null) && array_key_exists('print_ready_ids', $bill->result_panel_config ?? []); $referralDoctor = $referralDoctor ?? null; $reportActivities = $reportActivities ?? collect(); $patientPhone = $patient?->mobile ?: 'Not Available'; $patientEmail = filled($patient?->email) ? $patient->email : 'Not Available'; $patientAddress = filled($patient?->address) ? $patient->address : 'Not Available'; $doctorDisplayName = $referralDoctor ? trim(($referralDoctor->title ? $referralDoctor->title . ' ' : '') . $referralDoctor->first_name . ' ' . ($referralDoctor->last_name ?? '')) : ($bill->referred_by && strcasecmp($bill->referred_by, 'self') !== 0 ? $bill->referred_by : 'Self'); $doctorPhone = $referralDoctor?->contact_number ?: 'Not Available'; $doctorEmail = filled($referralDoctor?->email) ? $referralDoctor->email : 'Not Available'; $doctorAddress = filled($referralDoctor?->address) ? $referralDoctor->address : 'Not Available'; $wf = $workflowStatus ?? []; $statusKey = $wf['statusKey'] ?? ($bill->report_status ?? 'pending'); $statusLabel = $wf['statusLabel'] ?? match ($statusKey) { 'final' => 'Final', 'signed_off' => 'Signed off', default => 'Pending', }; $statusIsFinal = $wf['statusIsFinal'] ?? in_array($statusKey, ['final', 'signed_off'], true); $reportIsSignedOff = $bill->isSignedOff(); $reportCanBeSent = $bill->isPatientPortalReady(); $fmt = fn ($dt) => $dt ? \Carbon\Carbon::parse($dt)->format('d/m/Y h:i A') : '-'; $registeredOn = $fmt($bill->created_at); $collectedOn = $fmt($bill->collected_on ?? $bill->created_at); $receivedOn = $fmt($bill->received_on ?? $bill->created_at); $reportedOn = $fmt($bill->reported_on); $investigationTitle = $investigationTitle ?? '—'; $grouped = $resultGroups ?? $bill->results->groupBy(fn ($r) => $r->category ?: 'GENERAL'); $shownNoteFingerprints = []; foreach (($resultGroups ?? $grouped ?? []) as $noteCategory => $groupTests) { $catNoteMeta = app(\App\Http\Controllers\Backend\CasesController::class) ->categoryPanelMeta($bill, (string) $noteCategory); $noteFp = \App\Support\RichTextSanitizer::plainTextFingerprint($catNoteMeta['note'] ?? ''); if ($noteFp !== '') { $shownNoteFingerprints[] = $noteFp; } } $reportInterpretation = trim((string) ($bill->report_interpretation ?? '')); $perTestInterpFingerprints = []; foreach (($resultGroups ?? []) as $groupTests) { foreach ($groupTests as $row) { if (! empty($row->skip_interpretation)) { continue; } $rowInterp = trim((string) ($row->interpretation ?? '')); if ($rowInterp === '') { continue; } $rowFp = \App\Support\RichTextSanitizer::plainTextFingerprint($rowInterp); if ($rowFp !== '') { $perTestInterpFingerprints[] = $rowFp; } } } $interpFp = \App\Support\RichTextSanitizer::plainTextFingerprint($reportInterpretation); if ($interpFp !== '' && ( in_array($interpFp, $shownNoteFingerprints, true) || in_array($interpFp, $perTestInterpFingerprints, true) )) { $reportInterpretation = ''; } elseif ($reportInterpretation !== '') { $reportInterpretation = \App\Support\RichTextSanitizer::cleanClinicalNotes($reportInterpretation); } @endphp
|
@include('backend.template.diagnostic.cases.bill.partials.branch_letterhead', [
'branchName' => $branchName ?? null,
'branchAddress' => $branchAddress ?? null,
'branchPhone' => $branchPhone ?? null,
'branchEmail' => $branchEmail ?? null,
'branchLogoUrl' => $branchLogoUrl ?? null,
'brandName' => $labBrandName ?? ($brandName ?? null),
])
{{ $patientName }}
Age / Sex
:
{{ $ageSex }}
Referred by
:
{{ $bill->referred_by ?: 'Self' }}
UHID
:
{{ $patient?->uhid ?: '' }}
Investigations
:
{{ $investigationTitle }}
@if (!empty($reportQrSvg) || !empty($reportQrSrc) || filled($reportQrUrl ?? null))
@if (!empty($reportQrSvg))
{!! $reportQrSvg !!}
@elseif (!empty($reportQrSrc))
Scan to download
@endif
|
||||||||||||
|
No results entered yet. Use Enter results to add test values.
|
||||||||||||
|
{{ strtoupper($categoryLabels[$category] ?? $category) }}
~~~ End of report ~~~
--- End of report ---
Signature image missing.
@if ($missingMdImage)
Managing Director signature is marked on this report, but no MD image was found for this lab branch.
@endif
@if ($missingStaffImage)
Lab report signature is marked on this report, but no staff image was found for this lab branch.
@endif
Upload the image under
Labs → Signature,
then sign off again.
@endif
@endif
|
||||||||||||
|
Clinical Notes
{!! $reportInterpretation !!}
~~~ End of report ~~~
--- End of report ---
Signature image missing.
@if ($missingMdImage)
Managing Director signature is marked on this report, but no MD image was found for this lab branch.
@endif
@if ($missingStaffImage)
Lab report signature is marked on this report, but no staff image was found for this lab branch.
@endif
Upload the image under
Labs → Signature,
then sign off again.
@endif
|
||||||||||||
|
~~~ End of report ~~~
--- End of report ---
|
||||||||||||
| @include('backend.template.diagnostic.cases.bill.partials.lab-report-running-footer') | ||||||||||||