@extends ('layouts.patient')
@section('inner-content')
    {{-- canvas based rx --}}
    <div class="client-single-dashboard" id="client-rx-container">
        <div class="d-flex align-items-center pb-2">
            <h6 class="my-0 font-weight-bold">Current Medications</h6>
            <span class="mx-2 text-secondary">|</span>
            @include('app.patient.canvas-sections.canvas-editor-modal', ['key' => 'rx', 'class' => 'wide'])
            <span class="mx-2 text-secondary">|</span>
            <a href="/patients/view/{{$patient->uid}}/tickets/erx?popupmode=1"
               native target="_blank"
               class="ticket-popup-trigger d-block text-nowrap mr-3">
                Erx/Orders
            </a>
        </div>
        <div class="bg-light border p-2 mb-3">
            @include('app.patient.canvas-sections.rx.summary')
        </div>
    </div>
    <div class="stag-popup stag-popup-lg ticket-popup mcp-theme-1" stag-popup-key="ticket-popup"></div>

    <script>
        (function() {
            function init() {
                // refresh once ticket popup is closed
                $('body').off('stag-popup-closed')
                /*$('body').on('stag-popup-closed', function() {
                    if($('#client-rx-container').length) {
                        fastReload();
                    }
                });*/
                // ticket-popup
                $(document)
                    .off('click', '.ticket-popup-trigger')
                    .on('click', '.ticket-popup-trigger', function() {
                        showMask();
                        window.noMc = true;
                        $.get(this.href, (_data) => {
                            $('.ticket-popup').html(_data);
                            showStagPopup('ticket-popup', true);
                            // $('.ticket-popup .stag-popup.stag-slide').attr('close-all-with-self', 1);
                            runMCInitializer('patient-tickets'); // run specific mc initer
                            hideMask();
                        });
                        return false;
                    });
            }
            addMCInitializer('client-erx-listing', init, '#client-rx-container');
        }).call(window);
    </script>
@endsection
