<?php

use App\Models\Point;

/** @var \App\Models\Client $patient */
/** @var \App\Models\Note $note */

?>
<div class="system_segment">
<?php

$allPoints = Point::getPlanPoints($patient, $note);

// allergies/meds/problems/goals/careteam
$topLevelPointToRendererMap = [
    'ALLERGY' => 'allergy',
    'MEDICATION' => 'medication',
    'PROBLEM' => 'problem',
    'GOAL' => 'goal',
    'CARE_TEAM_MEMBER' => 'care_team_member'
];

$pointMap = [];

foreach($allPoints as $point){
    if(!isset($topLevelPointToRendererMap[$point->category])) continue;
    $renderer = $topLevelPointToRendererMap[$point->category];
    if(!isset($pointMap[$renderer])) $pointMap[$renderer] = [];
    $pointMap[$renderer][] = $point;
}

foreach ($pointMap as $renderer => $points) {
?>
@include('app.patient.module-specific-summary-renderers.' . $renderer . '.plan', compact('points'))
<?php
}

// rest of it
$topLevelPointToRendererMap = [
    'HIGH_SUGAR_BEVERAGES' => 'nutrition',
    'WATER_INTAKE' => 'nutrition',
    'FAST_FOOD' => 'nutrition',
    'SNACKS' => 'nutrition',
    'VEGETABLES' => 'nutrition',
    'PORTION_SIZES' => 'nutrition',
    'DAILY_INTAKE_CARBOHYDRATES' => 'nutrition',
    'DAILY_INTAKE_CALORIES' => 'nutrition',
    'AEROBIC_ACTIVITY' => 'exercise',
    'STRENGTH_TRAINING' => 'exercise',
    'NEAT,' => 'exercise',
    'SELF_MONITORING' => 'behavior',
    'FOOD_TRIGGERS' => 'behavior',
    'CRAVINGS' => 'behavior',
    'SLEEP_HABITS' => 'behavior',
    'WEIGHT_LOSS_INTAKE' => 'weight_loss_intake',
];

$pointMap = [];

foreach($allPoints as $point){
    if(!isset($topLevelPointToRendererMap[$point->category])) continue;
    $renderer = $topLevelPointToRendererMap[$point->category];
    if(!isset($pointMap[$renderer])) $pointMap[$renderer] = [];
    $pointMap[$renderer][] = $point;
}

foreach ($pointMap as $renderer => $points) {
?>
@include('app.patient.module-specific-summary-renderers.' . $renderer . '.plan', compact('points'))
<?php
}
?>
</div>

