<?php
$medications = \App\Models\Point::getPointsOfCategory($patient, "MEDICATION");
?>
<div class="pt-2 mt-2">
    <div class="d-flex align-items-center pb-2">
        <h6 class="my-0 font-weight-bold">Current Medications</h6>
        @if($isOldClient && @$hasRxInCanvas)
            <div class="px-2 font-weight-bold alert alert-info text-sm my-0 ml-2 py-1">New</div>
        @endif
        @if($patient->coreNote)
            @if(!@$disallowPointEdits)
            <a native target="_blank"
               class="c-pointer d-inline-flex align-items-center ml-3 text-decoration-none"
               open-in-stag-popup
               update-parent
               mc-initer="medications-center-{{$patient->coreNote->id}}"
               title="Medications Center"
               popup-style="overflow-visible"
               href="/medications-center/{{$patient->uid}}/{{$patient->coreNote->uid}}">
                <i class="fa fa-bolt mr-1"></i>
                <span>Manage</span>
            </a>
            @else
                <span class="text-secondary text-sm ml-3">Editable from within notes.</span>
            @endif
        @endif
    </div>
    <div class="bg-light border p-2 mb-3 point-content">
        @foreach($medications as $medication)
            <div class="mb-1">
                <b><?= !!@($medication->data->name) ? @($medication->data->name) : '-' ?></b>
                <div class="ml-3 mt-1">
                    <?php
                    $point = $medication;
                    $note = $point->note;
                    $childHeading = 'Subjective';
                    include resource_path('views/app/patient/segment-templates/_child_review/last-review-optimized-flat.php');
                    ?>
                </div>
                <div class="ml-3 mt-1">
                    <?php
                    $point = $medication;
                    $note = $point->note;
                    $childHeading = 'Plan';
                    include resource_path('views/app/patient/segment-templates/_child_plan/last-plan-optimized-flat.php');
                    ?>
                </div>
            </div>
        @endforeach
        @if(!count($medications))
            <div class="text-secondary">Nothing here yet</div>
        @endif
    </div>
</div>