<div visit-moe no-auto-save id="{{$label}}-add-multi-preexisting-{{$note->id}}" class="w-100">
    <form show url="/api/visitPoint/addTopLevelBulkPreExisting" class="mcp-theme-1 w-100 pb-3" novalidate>
        <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
        <input type="hidden" name="category" value="{{@$category ?: strtoupper($label)}}">
        <input type="hidden" name="dataJson">

        <table class="table table-sm table-bordered stag-sheet allow-row-addition bg-white mb-2 point-table read" style="table-layout: fixed">
            <thead>
            <tr class="bg-light">
                @if(in_array($label, ['allergy', 'medication', 'problem']) && @$favorites && count($favorites))
                    <th class="border-bottom-0 text-secondary width-30px text-center"><i class="fa fa-bookmark text-info text-sm on-hover-opaque"></i></th>
                @endif
                <th class="border-bottom-0 text-secondary text-nowrap">{{ucwords($label)}}</th>
                @if($label === 'problem')
                    <th class="border-bottom-0 text-secondary width-70px">ICD</th>
                @elseif($label === 'care team member')
                    <th class="border-bottom-0 text-secondary">Specialty</th>
                    <th class="border-bottom-0 text-secondary">Organization</th>
                @endif
                <th class="border-bottom-0 text-secondary {{$label === 'medication' ? 'width-150px' : '' }}">{{$label === 'medication' ? 'Subj. Frequency' : 'Subjective'}}</th>
                @if($label === 'medication')
                    <th class="border-bottom-0 text-secondary">Subj. Experience</th>
                @endif
                <th class="border-bottom-0 text-secondary {{$label === 'medication' ? 'width-150px' : '' }}">{{$label === 'medication' ? 'Plan Frequency' : 'Plan'}}</th>
                <th class="border-bottom-0 text-secondary width-140px">Start Date</th>
                <th class="d-none border-bottom-0 text-secondary text-nowrap">{{$adder}}</th>
                <th class="border-bottom-0 text-secondary width-50px"></th>
            </tr>
            </thead>
            <tbody>
            <tr>
                @if(in_array($label, ['allergy', 'medication', 'problem']) && @$favorites && count($favorites))
                    <td class="text-center align-middle">
                        <div class="d-inline position-relative on-click-menu">
                            <span class="text-primary c-pointer"><i class="fa fa-caret-down"></i></span>
                            <div menu right class="bg-white border">
                                @foreach($favorites as $favorite)
                                    <a native target="_blank" href="#"
                                       data-name="{{@($favorite->data->name)}}"
                                       @if($label === 'allergy')
                                       data-damConceptId="{{@($favorite->data->damConceptId)}}"
                                       data-damConceptIdType="{{@($favorite->data->damConceptIdType)}}"
                                       @elseif($label === 'medication')
                                       data-medId="{{@($favorite->data->medId)}}"
                                       data-routedMedId="{{@($favorite->data->routedMedId)}}"
                                       data-routedDosageFormMedId="{{@($favorite->data->routedDosageFormMedId)}}"
                                       data-gcnSeqno="{{@($favorite->data->gcnSeqno)}}"
                                       @elseif($label === 'problem')
                                       data-dxid="{{@($favorite->data->dxid)}}"
                                       data-icd="{{@($favorite->data->icd)}}"
                                       data-icd-type="{{@($favorite->data->{'icd-type'})}}"
                                       @endif
                                       class="px-2 py-1 d-block text-nowrap text-sm multi-favorite-item text-left">
                                        {{$favorite->data->name}}
                                    </a>
                                @endforeach
                            </div>
                        </div>
                    </td>
                @endif
                <td class="p-0">
                    <input type="text" key="{{$label === 'goal' ? 'goal' : 'name'}}" bucket="data" required
                           @if($label === 'medication')
                           stag-suggest
                           stag-suggest-bottom-left
                           stag-suggest-ep="/fdb-med-suggest-v2/json"
                           @elseif($label === 'problem')
                           stag-suggest
                           stag-suggest-bottom-left
                           stag-suggest-text-only
                           stag-suggest-ep="/fdb-dx-suggest-v2/json"
                           value="{{trim(request()->input('dx')) ? trim(request()->input('dx')) : ''}}"
                           @elseif($label === 'allergy')
                           stag-suggest
                           stag-suggest-bottom-left
                           stag-suggest-text-only
                           stag-suggest-ep="/fdb-allergy-suggest/json"
                           @endif
                    >
                    @if($label === 'medication')
                        <input type="hidden" key="routedMedId" bucket="data">
                        <input type="hidden" key="routedDosageFormMedId" bucket="data">
                        <input type="hidden" key="gcnSeqno" bucket="data">
                        <input type="hidden" key="medId" bucket="data">
                    @elseif($label === 'problem')
                        <input type="hidden" key="dxid" bucket="data">
                        <input type="hidden" key="icd-type" bucket="data">
                    @elseif($label === 'allergy')
                        <input type="hidden" key="damConceptId" bucket="data">
                        <input type="hidden" key="damConceptIdType" bucket="data">
                    @endif
                </td>
                @if($label === 'problem')
                    <td class="p-0">
                        <input type="text" key="icd" bucket="data">
                    </td>
                @elseif($label === 'care team member')
                    <td class="p-0">
                        <input type="text" key="specialty" bucket="data">
                    </td>
                    <td class="p-0">
                        <input type="text" key="organization" bucket="data">
                    </td>
                @endif
                @if($label === 'medication')
                    <td class="p-0">
                        <textarea rows="1" key="value" bucket="childReviewData"></textarea>
                    </td>
                    <td class="p-0">
                        <div note-rte class="rte-holder" key="experience" bucket="childReviewData"></div>
                    </td>
                @else
                    <td class="p-0">
                        <div note-rte class="rte-holder" key="value" bucket="childReviewData"></div>
                    </td>
                @endif
                <td class="p-0">
                    <div note-rte class="rte-holder" key="value" bucket="childPlanData"></div>
                </td>
                <td class="p-0">
                    <input type="date" key="start_date" bucket="data">
                </td>
                <td class="p-0 d-none">
                    <input type="text" key="prescriber" bucket="data">
                </td>
                <td class="px-2 align-middle text-center text-nowrap">
                    <a href="#" class="delete-line mr-2"><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>
                    <a href="#" class="add-line mr-2"><i class="fa fa-plus text-primary on-hover-opaque"></i></a>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="d-flex align-items-center">
            <button class="btn-save-lines btn btn-sm btn-primary mr-2">Save</button>
            <button class="btn btn-sm btn-default border bg-white" onclick="closeStagPopup(); return false;">Close</button>
        </div>
    </form>
</div>
