<?php
use App\Models\Point;

$category = 'PLAN_FREE_TEXT';
$endPoint = 'upsertNoteSingleton';

$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
$parsed = null;
if (!!@$point->data) {
    $parsed = json_decode($point->data);
}
?>
<div visit-moe close-on-save close-on-cancel class="d-block">
    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
        <input type="hidden" name="category" value="<?= $category ?>">
        <input type="hidden" name="data">
        <div note-rte short
             class="form-group mb-2 border-left border-right rte-holder"
             data-field-name="free_text"
        ><?= $parsed && @$parsed->free_text ? $parsed->free_text : '' ?></div>
        <div class="bg-white">
            <div class="px-2 c-pointer on-hover-aliceblue" onclick="$('.note-bottom-toolbar .allergies-center-trigger').trigger('click'); return false;">@include('app.patient.segment-templates.plan_free_text_v2.allergies')</div>
            <div class="px-2 c-pointer on-hover-aliceblue" onclick="$('.note-bottom-toolbar .medications-center-trigger').trigger('click'); return false;">@include('app.patient.segment-templates.plan_free_text_v2.medications')</div>
            <div class="px-2 c-pointer on-hover-aliceblue" onclick="$('.note-bottom-toolbar .problems-center-trigger').trigger('click'); return false;">@include('app.patient.segment-templates.plan_free_text_v2.problems')</div>
            <div class="px-2 c-pointer on-hover-aliceblue" onclick="$('.note-bottom-toolbar .goals-center-trigger').trigger('click'); return false;">@include('app.patient.segment-templates.plan_free_text_v2.goals')</div>
            <div class="px-2 c-pointer on-hover-aliceblue" onclick="$('.note-bottom-toolbar .careteam-center-trigger').trigger('click'); return false;">@include('app.patient.segment-templates.plan_free_text_v2.care_team')</div>
        </div>
        <div class="m-2">
            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
            <div class="d-inline-flex align-self-stretch align-items-center">
                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
                <span class="autosave-indicator saved text-sm text-secondary">
                    <i class="fa fa-check"></i>
                    Saved
                </span>
            </div>
        </div>
    </form>
</div>