{{-- Recursively renders one lab type's result rows for the "+" expand row on the appointment Laboratory tab. A "grouped" type is a section made of further sub-panels — print a bold header for it and recurse into each of its own bridge routines; anything else is a plain test whose own routine rows are the actual leaves to show a value for. Nesting can go arbitrarily deep (e.g. panel → URINE ANALYSIS → Chemical Examination → its own leaves), so this includes itself rather than hardcoding a fixed depth. --}} @if ($labType->result_format === 'grouped') @foreach ($labType->routine as $bridge) @continue(empty($bridge->result_component)) @php $target = \App\Models\LabLabType::with('routine.measurement')->find($bridge->result_component); @endphp @continue(! $target) {{ $target->name }} @include('patient_mangement.appointment.laboratory._result_rows', ['labType' => $target, 'requestResults' => $requestResults]) @endforeach @else @foreach ($labType->routine as $leaf) @php $res = $requestResults->firstWhere('routine_id', $leaf->id); @endphp @continue(! $res) {{ $leaf->routine_name ?: $labType->name }} {{ $res->result }} {{ $leaf->measurement?->name == 'Random sample' ? '' : $leaf->measurement?->name }} {!! $leaf->normal_range !!} @endforeach @endif