<?php

use App\Models\Point;

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

$wizardLinks = [
    [
        "name" => 'Nutrition Rx',
        "title" => '<img src=\'/img/nutrition-rx.png\'/> Nutrition Rx',
        "href" => "/nutrition-center/{$note->client->uid}/{$note->uid}",
        "initer" => "nutrition-center-{$note->id}"
    ],
    [
        "name" => 'Exercise Rx',
        "title" => '<img src=\'/img/exercise-rx.png\'/> Exercise Rx',
        "href" => "/exercise-center/{$note->client->uid}/{$note->uid}",
        "initer" => "exercise-center-{$note->id}"
    ],
    [
        "name" => 'Behavior Rx',
        "title" => '<img src=\'/img/behavior-rx.png\'/> Behavior Rx',
        "href" => "/behavior-center/{$note->client->uid}/{$note->uid}",
        "initer" => "behavior-center-{$note->id}"
    ],
];

?>

<div class="hide-if-note-signed">
    <div class="d-none d-md-block my-1">
        @foreach($wizardLinks as $link)
            @if(@$link['name'])
                <a href="{{$link['href']}}"
                   open-in-stag-popup
                   popup-style="overflow-visible {{@$link['style']}}"
                   title="{!! @$link['title'] ?: $link['name'] !!}"
                   mc-initer="{{ @$link['initer']  }}"
                   class="mr-2 d-inline-block text-nowrap font-underline">{!! $link['name'] !!}</a>
            @endif
        @endforeach
    </div>
</div>

<div class="system_segment">
<?php
/*
$inPoints = Point::getPointsOfCategory($patient, 'ALLERGY');
if(count($inPoints)) {
?>
    @include('app.patient.module-specific-summary-renderers.allergy.subjective', ['points' => $inPoints])
<?php
}

$inPoints = Point::getPointsOfCategory($patient, 'MEDICATION');
if(count($inPoints)) {
?>
    @include('app.patient.module-specific-summary-renderers.medication.subjective', ['points' => $inPoints])
<?php
}

$inPoints = Point::getIntakePointsWithChildReview($patient, $note);

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

$pointMap = [];

foreach($inPoints 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 . '.subjective', compact('points'))
<?php
}

// history, ros
$topLevelPointToRendererMap = [
    'PAST_MEDICAL_HISTORY' => 'past_medical_history',
    'FAMILY_HISTORY' => 'history_family',
    'SOCIAL_HISTORY' => 'history_social',
    'SURGICAL_HISTORY' => 'history_surgical',
    'ROS' => 'ros',
];

$pointMap = [];

foreach($inPoints 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 . '.subjective', compact('points'))
<?php
}
*/

$inPoints = Point::getIntakePointsWithChildReview($patient, $note);

$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',

    // lifestyle
    'LIFESTYLE_GENERAL' => 'lifestyle_general',
    'LIFESTYLE_NUTRITION' => 'lifestyle_nutrition',
    'LIFESTYLE_PHYSICAL_ACTIVITY' => 'lifestyle_physical_activity',
    'LIFESTYLE_SLEEP' => 'lifestyle_sleep',
    'LIFESTYLE_SOCIAL_RELATIONSHIPS' => 'lifestyle_social_relationships',
    'LIFESTYLE_STRESS' => 'lifestyle_stress',
    'LIFESTYLE_SUBSTANCE_USE' => 'lifestyle_substance_use',
    'WEIGHT_LOSS_INTAKE' => 'weight_loss_intake',
    'SLEEP_HEALTH_INTAKE' => 'sleep_health_intake'
];

$pointMap = [];

foreach($inPoints 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 . '.subjective', compact('points'))
<?php
}
?>
</div>

