{{-- An ultrasound report written on a template (App\Services\UltrasoundTemplates), laid out like the paper form:
section bars, label | value rows, ■ ticked / □ not ticked; empty fields print as blank lines to write on. --}}
@php
$d = $report->report_data ?? [];
$blank = fn ($w = 160) => " ";
$out = fn ($x, $w = 160) => trim((string) $x) !== '' ? '' . e($x) . '' : $blank($w);
$box = fn ($on) => $on ? '■' : '□'; // ■ / □
$date = fn ($x) => trim((string) $x) !== '' ? \Carbon\Carbon::parse($x)->format('d / m / Y') : '____ / ____ / ______';
// one field as the paper form shows it
$render = function ($f) use ($d, $out, $box, $date, $blank) {
$v = $d[$f['key']] ?? null;
switch ($f['type']) {
case 'date':
return e($date($v));
case 'num':
return $out($v, 80) . (!empty($f['unit']) ? ' ' . e($f['unit']) : '');
case 'ga':
return $out($v['weeks'] ?? '', 60) . ' weeks ' . $out($v['days'] ?? '', 50) . ' days';
case 'ga_parts':
return collect($f['parts'])->map(fn ($p) => e($p[1]) . ': ' . $out($v[$p[0] . '_w'] ?? '', 34) . 'w ' . $out($v[$p[0] . '_d'] ?? '', 26) . 'd')->implode(' ');
case 'measure':
$html = collect($f['choices'] ?? [])->map(fn ($o) => $box(($v['choice'] ?? '') === $o) . ' ' . e($o))->implode(' ');
foreach ($f['parts'] as [$pk, $pl, $unit]) {
$html .= ($html ? ' ' : '') . e($pl) . ': ' . $out($v[$pk] ?? '', $unit === '' ? 140 : 60) . ($unit ? ' ' . e($unit) : '');
}
if (!empty($f['notes']) && trim((string) ($v['notes'] ?? '')) !== '') {
$html .= '
' . e($v['notes']) . '
';
}
return $html;
case 'choice':
$picked = $v['value'] ?? '';
$html = collect($f['options'])->map(fn ($o) => $box($picked === $o) . ' ' . e($o) . ($o === 'Other' && !empty($f['other']) ? ': ' . $out($v['other'] ?? '', 160) : ''))->implode(' ');
if ($picked !== '' && !in_array($picked, $f['options'], true)) {
$html .= ' ' . $box(true) . ' ' . e($picked); // saved before the options changed
}
foreach ($f['extra'] ?? [] as [$ek, $el, $eu]) {
$html .= ' ' . e($el) . ': ' . $out($v[$ek] ?? '', 60) . ($eu ? ' ' . e($eu) : '');
}
if (!empty($f['notes'])) {
$html .= ' Notes: ' . $out($v['notes'] ?? '', 140);
}
return $html;
default:
return trim((string) $v) !== '' ? nl2br(e($v)) : $blank(380);
}
};
$impression = $d['impression'] ?? [];
@endphp
{{-- hospital logo watermark (permission image-report-watermark) --}}
@include('partials.report_watermark', ['perm' => 'image-report-watermark'])
@include('layouts.print_header', ['printTitle' => ''])
{{ $tpl['title'] }}
Patient information
| Patient name: {!! $out($patientInfo['name'], 220) !!} | Age: {!! $out($patientInfo['age'], 70) !!} Hospital ID: {!! $out($patientInfo['code'], 110) !!} |
| Examination date: {{ $patientInfo['date'] }} | Doctor: {!! $out($patientInfo['doctor'], 180) !!} |
@foreach (array_chunk($tpl['patient'], 2) as $pair)
@foreach ($pair as $f)
{{-- a measurement already names its parts (Gravida: 3 Para: 2 …) --}}
| {!! $f['type'] === 'measure' ? '' : e($f['label']) . ': ' !!}{!! $render($f) !!} |
@endforeach
@if (count($pair) === 1) | @endif
@endforeach
Ultrasound findings
@foreach ($tpl['findings'] as $f)
@php
$__lv = $d[$f['key']] ?? null;
$__has = is_array($__lv) ? collect($__lv)->flatten()->contains(fn ($x) => trim((string) $x) !== '') : trim((string) $__lv) !== '';
@endphp
@continue(!empty($f['legacy']) && !$__has)
| {{ $f['label'] }} | {!! $render($f) !!} |
@endforeach
Impression / conclusion
@foreach (array_pad($impression, 3, '') as $i => $line)
| {{ $i + 1 }}. {!! trim($line) !== '' ? '' . e($line) . '' : $blank(600) !!} |
@endforeach
Recommendations / follow-up
| {!! trim($d['recommendations'] ?? '') !== '' ? nl2br(e($d['recommendations'])) : '' !!} |
@if ($report->next_appointment_date)
Next appointment: {{ \Carbon\Carbon::parse($report->next_appointment_date)->format('d M, Y') }}
@endif
{{ $report->ReportingDoctor?->name ?: ($imageRequest->Dr?->name ?: 'Sonographer / Radiologist') }}
Signature
Date
{{ now()->format('d M, Y') }}
@include('partials.print_one_page', ['fitTarget' => '#print-content'])