<?php

use App\Models\Point;

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

$supplements = Point::getIntakePointsOfCategory($patient, 'SUPPLEMENT', $note);

$numRelevant = 0;

?>

<?php if (!count($supplements)): ?>
    <div class="text-secondary">-</div>
<?php else: ?>
    <?php foreach ($supplements as $supplement): ?>
        <?php $rel = $supplement->relevanceToNote($note); ?>
        <div class="mb-2">
            <div class="d-flex align-items-baseline">
                @if($rel)
                    <span class="text-info mr-1">
                        <i class="fa fa-star"></i>
                    </span>
                    <?php $numRelevant++; ?>
                @endif
                <div class="<?= $supplement->is_removed ? 'strike-through' : '' ?>">
                    <b><?= !!@($supplement->data->name) ? @($supplement->data->name) : '-' ?></b>
                    <?= !!@($supplement->data->start_date) ? '/&nbsp;From ' . @($supplement->data->start_date) : '' ?>
                </div>
                <?php if ($supplement->is_removed): ?>
                    @if($supplement->removal_reason_category === 'DURING_VISIT')
                        <span class="ml-2 text-sm text-secondary">Removed during visit</span>
                    @elseif($supplement->removal_reason_category === 'ON_INTAKE')
                        <span class="ml-2 text-sm text-secondary">Historic</span>
                    @endif
                <?php elseif ($supplement->added_in_note_id === $note->id): ?>
                <span class="ml-2 text-sm text-success">* Added on intake</span>
                <?php endif; ?>
            </div>
            <?php $review = $supplement->childReviewAddedInNote($note); ?>
            <?php if(!!$review): ?>
            <div class="pl-3 mt-1">
                <div class="text-secondary font-weight-bold">Subjective</div>
                <div>{!! $review->data->value !!}</div>
            </div>
            <?php endif; ?>
        </div>
    <?php endforeach; ?>
    @if($numRelevant)
        <div class="d-flex align-items-baseline text-info mr-1 mt-3">
            <span class="text-sm mr-1"><i class="fa fa-star text-sm"></i></span>
            <span class="text-sm">Supplements relevant to this note</span>
        </div>
    @endif
<?php endif; ?>

