{{-- 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 @include('partials.print_one_page', ['fitTarget' => '#print-content'])