<?php

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

$point = Point::getOnlyTopLevelPointOfCategory($note, 'PSYCH_RISK_ASSESSMENT', true);

if($point) {
    ?> <div class="popup-content-container px-3"> <?php
    foreach ($point->childReviews as $childReview) {
        $contentData = $parsed = false;
        if ($childReview->data) {
            $childReview->data = json_decode($childReview->data, true);
            $contentData = $parsed = $childReview->data;

            if($contentData && !$contentData['no_risks'] && !!$contentData['count']) {
                ?>
                <div class="mb-1 font-weight-bold">{{$childReview->creatorPro->displayName()}} - {{friendly_date($childReview->note->effective_dateest)}}</div>
                <div class="pl-3 bg-light border p-3 mb-3">
                <?php
                for ($i = 0; $i < $contentData['count']; $i++) {
                    ?>
                    <div class="<?= $i > 0 ? 'mt-1' : '' ?>">
                        <div class="d-flex align-items-baseline mb-1">
                            <b class="mr-3"><?= @($contentData['items'][$i]['area']) ?></b>
                            <div class="mr-2">Level: <?= @($contentData['items'][$i]['level']) ?></div>
                            <div class="mr-2">Intent: <?= @($contentData['items'][$i]['intent']) ?></div>
                            <div class="mr-2">Plan: <?= @($contentData['items'][$i]['plan']) ?></div>
                            <div class="mr-2">Means: <?= @($contentData['items'][$i]['means']) ?></div>
                            <div class="ml-3">
                                <div class="">Risk Factors: <?= @($contentData['items'][$i]['risk_factors']) ?></div>
                                <div class="">Protective Factors: <?= @($contentData['items'][$i]['protective_factors']) ?></div>
                                <div class="">Additional Details: <?= @($contentData['items'][$i]['additional_details']) ?></div>
                            </div>
                        </div>
                    </div>
                    <?php
                }
                ?>
                </div>
                <?php
            }
        }
    }
    ?> </div> <?php
}