@extends('layouts.portal') @section('title', $reviewer->full_name . ' — ' . config('app.name')) @section('page_title', $reviewer->full_name) @section('page_subtitle', ($reviewer->file_number ? $reviewer->file_number . ' · ' : '') . __('patients.age') . ': ' . ($summary['age'] ?? '—') . ($reviewer->gender ? ' · ' . __('common.' . $reviewer->gender) : '')) @section('page_actions') {{-- {{ __('common.edit') }} --}} {{ __('patients.visit_log') }} {{ __('patients.new_visit') }} @if ($latestVisit ?? null) {{ __('patients.edit_last_visit') }} @endif {{-- {{ __('menus.generate') }} --}}
@csrf
@endsection @section('content') {{-- Nutrition snapshot --}}

{{ __('patients.bmr') }}

{{ $summary['bmr'] !== null ? number_format($summary['bmr']) : '—' }}

{{ __('common.kcal') }}

{{ __('patients.tdee') }}

{{ $summary['tdee'] !== null ? number_format($summary['tdee']) : '—' }}

{{ __('common.kcal') }}

{{ __('patients.target_calories') }}

{{ $summary['target_calories'] !== null ? number_format($summary['target_calories']) : '—' }}

{{ $reviewer->dietType?->name }}

{{ __('patients.bmi') }}

{{ $summary['bmi'] }}

{{ __('patients.bmi_category.' . $summary['bmi_category']) }}

{{-- Macros --}}

{{ __('patients.macros') }}

@foreach ([['protein', 'protein_g', 'bg-brand-50 text-brand-700'], ['carbs', 'carbs_g', 'bg-amber-50 text-amber-700'], ['fat', 'fat_g', 'bg-sky-50 text-sky-700']] as [$label, $key, $tone])

{{ $summary['macros'][$key] }}{{ __('common.grams') }}

{{ __('patients.' . $label) }}

@endforeach

{{ __('patients.water') }}: {{ $summary['water_litres'] }} L

{{-- Generate menu --}} {{--
--}} {{--

{{ __('menus.generate') }}

--}} {{--
@csrf
--}} {{--
@forelse ($reviewer->menuPlans as $menu)
{{ $menu->title ?? $menu->dietType?->name }}

{{ $menu->starts_on?->format('Y-m-d') }} · {{ $menu->duration_days }} {{ __('common.days') }} · {{ number_format($menu->target_calories) }} {{ __('common.kcal') }}

{{ __('menus.statuses.' . $menu->status) }}
@empty

{{ __('menus.empty') }}

@endforelse
--}} {{--
--}} {{-- Measurements --}} @php $logFields = [ 'height_cm' => ['label' => 'patients.log_height_cm', 'color' => '#7c3aed'], 'weight_kg' => ['label' => 'patients.log_weight_kg', 'color' => '#0d9488'], 'muscle_mass_kg' => ['label' => 'patients.log_muscle_mass_kg', 'color' => '#2563eb'], 'body_fat_percent' => ['label' => 'patients.log_fat_mass_kg', 'color' => '#d97706'], 'waist_cm' => ['label' => 'patients.log_waist_cm', 'color' => '#dc2626'], ]; $trends = collect($logFields)->map(function ($meta, $field) use ($measurements) { $points = $measurements->filter(fn ($m) => $m->{$field} !== null)->values(); return [ 'key' => $field, 'label' => __($meta['label']), 'color' => $meta['color'], 'labels' => $points->map(fn ($m) => $m->measured_on->format('Y-m-d'))->all(), 'values' => $points->map(fn ($m) => $m->{$field})->all(), 'change' => $points->count() > 1 ? round($points->last()->{$field} - $points->first()->{$field}, 1) : null, ]; })->values(); @endphp

{{ __('patients.measurements') }}

{{ __('patients.measurement_optional_hint') }}

@csrf
@error('measured_on')

{{ $message }}

@enderror
@error('height_cm')

{{ $message }}

@enderror
@error('weight_kg')

{{ $message }}

@enderror
@error('muscle_mass_kg')

{{ $message }}

@enderror
@error('body_fat_percent')

{{ $message }}

@enderror
@error('waist_cm')

{{ $message }}

@enderror
{{-- Period filter --}}
@error('from')

{{ $message }}

@enderror
@error('to')

{{ $message }}

@enderror
{{ __('common.reset') }}
@forelse ($measurements->reverse() as $m) @empty @endforelse
{{ __('patients.measured_on') }} {{ __('patients.log_height_cm') }} {{ __('patients.log_weight_kg') }} {{ __('patients.log_muscle_mass_kg') }} {{ __('patients.log_fat_mass_kg') }} {{ __('patients.log_waist_cm') }} {{ __('patients.consultant') }}
{{ $m->measured_on->format('Y-m-d') }} {{ $m->height_cm ?? '—' }} {{ $m->weight_kg ?? '—' }} {{ $m->muscle_mass_kg ?? '—' }} {{ $m->body_fat_percent ?? '—' }} {{ $m->waist_cm ?? '—' }} {{ $m->recorder?->name ?? '—' }}
{{ ($measurementFrom || $measurementTo) ? __('patients.no_measurements_in_range') : __('patients.no_measurements') }}
{{-- Trend charts --}} @if ($measurements->isNotEmpty())

{{ __('patients.trend_title') }}

@foreach ($trends as $trend)

{{ $trend['label'] }}

@if ($trend['change'] === null) {{ __('patients.trend_not_enough') }} @else {{ $trend['change'] > 0 ? '▲ +' : ($trend['change'] < 0 ? '▼ ' : '') }}{{ $trend['change'] }} @endif
@if (count($trend['values']) > 0)
@else

—

@endif
@endforeach
@endif
{{-- Email log: every file/plan emailed to this reviewer and when --}}

{{ __('patients.email_log') }}

{{ __('patients.email_log_hint') }}

@forelse ($emailLogs as $log) @empty @endforelse
{{ __('patients.email_log_item') }} {{ __('patients.email_log_type') }} {{ __('patients.email_log_sent_to') }} {{ __('patients.email_log_shared_on') }} {{ __('patients.email_log_sent_by') }} {{ __('patients.email_log_status') }}
@if ($log->loggable instanceof \App\Models\Attachment && $log->loggable->consultant_id === auth()->id()) {{ $log->itemLabel() }} @elseif ($log->loggable instanceof \App\Models\MenuPlan) {{ $log->itemLabel() }} @else {{ $log->itemLabel() }} @endif {{ __('patients.email_log_types.' . $log->type) }} {{ $log->recipient }} {{ $log->formattedSentAt() }} {{ $log->user?->name ?? '—' }} isFailed() && $log->error) title="{{ $log->error }}" @endif> {{ __('patients.email_log_statuses.' . $log->status) }}
{{ __('patients.email_log_empty') }}
{{-- Side column --}}

{{ __('patients.section_body') }}

@foreach ([ ['patients.height_cm', $reviewer->height_cm], ['patients.weight_kg', $reviewer->weight_kg], ['patients.target_weight_kg', $reviewer->target_weight_kg ?? '—'], ['patients.body_fat_percent', $reviewer->body_fat_percent ?? '—'], ['patients.waist_cm', $reviewer->waist_cm ?? '—'], ['patients.hip_cm', $reviewer->hip_cm ?? '—'], ] as [$label, $value])
{{ __($label) }}
{{ $value }}
@endforeach

{{ __('patients.section_lifestyle') }}

{{ __('patients.activity_level') }}
{{ __('patients.activity.' . $reviewer->activity_level) }}
{{ __('patients.goal') }}
{{ __('patients.goals.' . $reviewer->goal) }}
{{ __('patients.consultant') }}
{{ $reviewer->consultant?->name }}

{{ __('patients.section_clinical') }}

@foreach ([ ['patients.medical_conditions', $reviewer->medical_conditions], ['patients.medications', $reviewer->medications], ['patients.allergies', $reviewer->allergies], ['patients.disliked_foods', $reviewer->disliked_foods], ] as [$label, $items])

{{ __($label) }}

@if (filled($items))
@foreach ($items as $item) {{ $item }} @endforeach
@else {{ __('common.none') }} @endif
@endforeach @if ($reviewer->notes)
{{ $reviewer->notes }}
@endif
@endsection @if ($measurements->isNotEmpty()) @push('scripts') @endpush @endif