@extends('layouts.template')
<?php
/** @var \App\Models\Client $patient */
?>
@section('content')
    <div class="container-fluid h-100">
        <div class="main-row h-100">
            <nav id="sidebarMenu" class="d-md-block bg-light sidebar collapse px-0">
                <div class="sidebar-sticky pt-3">
                    <ul class="nav flex-column mcp-theme-1">
                        <?php $routeName = request()->route()->getName(); ?>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.dashboard') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.dashboard', ['patient' => $patient]) }}">Dashboard</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.calendar') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.calendar', ['patient' => $patient]) }}">Calendar</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.appointments') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.appointments', ['patient' => $patient, 'forPro' => 'all', 'status' => 'all']) }}">Appointments</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.programs') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.programs', ['patient' => $patient]) }}">Programs</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.flowsheets') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.flowsheets', ['patient' => $patient]) }}">Flowsheets</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.vitals-graph') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.vitals-graph', ['patient' => $patient]) }}">Vitals Graph</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.care-months') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.care-months', ['patient' => $patient]) }}">Care Months</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.devices') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.devices', ['patient' => $patient]) }}">Devices</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.measurements') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.measurements', ['patient' => $patient]) }}">Measurements</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.notes') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.notes', ['patient' => $patient]) }}">Notes</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.sections') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.sections', ['patient' => $patient]) }}">Sections</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.handouts') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.handouts', ['patient' => $patient]) }}">Handouts</a>
                        </li>
                        <?php /* <li class="nav-item">
                            <a class="nav-link d-flex align-items-center {{ strpos($routeName, 'patients.view.action-items') === 0 ? 'active' : '' }}"
                               native onclick="return false">
                                <span class="text-dark">ERx/Orders</span>
                            </a>
                            <ul class="m-0 p-0 nav-child-list">
                                <li class="nav-item">
                                    <a class="nav-link {{ strpos($routeName, 'patients.view.action-items-erx') === 0 ? 'active' : '' }}"
                                       href="{{ route('patients.view.action-items-erx', ['patient' => $patient]) }}">ERx</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link {{ strpos($routeName, 'patients.view.action-items-lab') === 0 ? 'active' : '' }}"
                                       href="{{ route('patients.view.action-items-lab', ['patient' => $patient]) }}">Lab</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link {{ strpos($routeName, 'patients.view.action-items-imaging') === 0 ? 'active' : '' }}"
                                       href="{{ route('patients.view.action-items-imaging', ['patient' => $patient]) }}">Imaging</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link {{ strpos($routeName, 'patients.view.action-items-equipment') === 0 ? 'active' : '' }}"
                                       href="{{ route('patients.view.action-items-equipment', ['patient' => $patient]) }}">Equipment</a>
                                </li>
                            </ul>
                        </li> */ ?>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.tickets') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.patient-tickets', ['patient' => $patient]) }}">Tickets</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.incoming-reports') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.incoming-reports', ['patient' => $patient]) }}">Incoming Reports</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.allergies') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.allergies', ['patient' => $patient]) }}">Allergies</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.medications') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.medications', ['patient' => $patient]) }}">Medications</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.dx-and-focus-areas') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.dx-and-focus-areas', ['patient' => $patient]) }}">Dx and
                                Focus Areas</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.care-team') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.care-team', ['patient' => $patient]) }}">Care Team</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.history') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.history', ['patient' => $patient]) }}">History</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.memos') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.memos', ['patient' => $patient]) }}">Memos</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ $routeName === 'patients.view.sms' ? 'active' : '' }}"
                               href="{{ route('patients.view.sms', ['patient' => $patient]) }}">SMS</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.sms-numbers') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.sms-numbers', ['patient' => $patient]) }}">SMS Numbers</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.documents') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.documents', ['patient' => $patient]) }}">Documents</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.settings') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.settings', ['patient' => $patient]) }}">Settings</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.pros') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.pros', ['patient' => $patient]) }}">Pros</a>
                        </li>
                        {{--<li class="nav-item">
                            <a class="nav-link" href="/patients/view/{{ $patient->uid }}/intake">Intake</a>
                        </li>--}}
                        @if($performer->pro->pro_type == 'ADMIN')
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.mcp-requests') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.mcp-requests', $patient) }}">MCP Requests</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link {{ strpos($routeName, 'patients.view.eligible-refreshes') === 0 ? 'active' : '' }}"
                               href="{{ route('patients.view.eligible-refreshes', $patient) }}">Eligible Refreshes</a>
                        </li>
                        @endif
                    </ul>
                    <div class="mt-3 mcp-theme-1">
                        @yield('left-nav-content')
                    </div>
                </div>
            </nav>
            <main role="main" class="w-100">
                <div class="card mt-3">
                    <div class="card-header py-1">
                        <?php
                        $thumbnail = $patient->profile_picture_base64;
                        $initials = !$thumbnail ? substr($patient->name_first, 0, 1) . substr($patient->name_last, 0, 1) : '';
                        $online = $patient->is_online ? 'online' : '';
                        $patientName = implode(', ', array_filter([$patient->name_last, $patient->name_first]));

                        $confirmedCell = empty($patient->cell_number) ? '-' : $patient->cell_number;
                        $confirmedEmail = empty($patient->email_address) ? '-' : $patient->email_address;

                        $location = implode(', ', array_filter([$patient->home_address_city, $patient->home_address_state]));
                        $location = empty($location) ? '-' : $location;

                        $mcpName = $patient->mcp ? implode(', ', array_filter([$patient->mcp->name_last, $patient->mcp->name_first])) : null;
                        $cmName = $patient->cm ? implode(', ', array_filter([$patient->cm->name_last, $patient->cm->name_first])) : null;

                        $memberSince = date_diff(date_create($patient->created_at), date_create('now'))->days;
                        if ($memberSince > 30) $memberSince = date('F, Y', strtotime($patient->created_at));
                        else if ($memberSince > 1) $memberSince .= ' days ago';
                        else if ($memberSince === 1) $memberSince = 'yesterday';
                        else if ($memberSince === 0) $memberSince = 'today';
                        ?>

                        <div class=z>
                            <div class=header>
                                @if($patient->is_duplicate)
                                    <div class="alert alert-secondary border-dark mcp-theme-1">
                                        <span class="text-dark">This chart is a duplicate of&nbsp;</span>
                                        <a class="font-weight-bold"
                                           href="/patients/view/{{ $patient->duplicateOf->uid }}">
                                            {{ $patient->duplicateOf->displayName() }}
                                        </a>
                                    </div>
                                @endif
                                <div class=hbox>
                                    <div class="mr-1 patient-presence-indicator thumbnail {{$online}}"
                                         data-patient-uid="{{$patient->uid}}"
                                         style="background-image:<?=$thumbnail?>"><?=$initials?></div>
                                    {{--<div>
                                        <div @if($patient->is_microphone_available)style="color:green" @else style="color:gray"  @endif>
                                            <i class="fa fa-microphone"></i>
                                        </div>
                                        <div @if($patient->is_camera_available)style="color:green" @else style="color:gray"  @endif>
                                            <i class="fa fa-video"></i>
                                        </div>
                                    </div>--}}
                                    <section>
                                        <div class=hbox>
                                            <h4>{{$patientName}}</h4>
                                            <i class=chart>[#{{$patient->chart_number}}]</i>
                                        </div>
                                        <div class=separators>
                                            <div>{{friendly_date_time($patient->dob, false)}}({{$patient->age_in_years}}
                                                y.o {{$patient->sex}})
                                            </div>
                                            <div>
                                                @if($patient->was_medicare_validation_successful && $patient->is_part_b_primary == 'YES')
                                                    Covered <span style="color:green"><i class="fa fa-check-circle"></i> </span>
                                                @elseif($patient->was_medicare_validation_successful)
                                                    <span>
                                                    @if($patient->is_part_b_primary == 'YES')
                                                            Medicare Part B
                                                        @else
                                                            Not Medicare Part B <i class="fa fa-times"></i>
                                                            @if($patient->is_medicare_advantage == 'YES')
                                                                , Medicare Advantage,
                                                                {{$patient->medicare_advantage_plan}}
                                                            @endif
                                                        @endif
                                                </span>
                                                @else
                                                    <div moe>
                                                        <a href="" start show>
                                                            @if($patient->mcn)
                                                                {{$patient->mcn}} Invalid MCN <i
                                                                    class="fa fa-times"></i>
                                                            @else
                                                                No Info Provided
                                                            @endif
                                                        </a>
                                                        <form url="/api/client/putMedicareInfo" class="mcp-theme-1">
                                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                            <div class="mb-2">
                                                                <input type="text" class="form-control form-control-sm"
                                                                       name="nameFirst"
                                                                       value="{{$patient->name_first}}"
                                                                       placeholder="First Name">
                                                            </div>
                                                            <div class="mb-2">
                                                                <input type="text" class="form-control form-control-sm"
                                                                       name="nameLast"
                                                                       value="{{$patient->name_last}}"
                                                                       placeholder="Last Name">
                                                            </div>
                                                            <div class="mb-2">
                                                                <input type="date" class="form-control form-control-sm"
                                                                       name="dob"
                                                                       value="{{$patient->dob}}"
                                                                       placeholder="Date of Birth">
                                                            </div>
                                                            <div class="mb-2">
                                                                <input type="text" class="form-control form-control-sm"
                                                                       name="mcn"
                                                                       value="{{$patient->mcn}}"
                                                                       placeholder="Medicare Number">
                                                            </div>
                                                            <div>
                                                                <button submit class="btn btn-sm btn-primary mr-2">
                                                                    Submit
                                                                </button>
                                                                <button cancel class="btn btn-sm btn-default border">
                                                                    Cancel
                                                                </button>
                                                            </div>
                                                        </form>
                                                    </div>
                                                @endif
                                            </div>
                                        </div>
                                        <div class=separators>
                                            <div>Joined <?=$memberSince?></div>
                                            <div><label>MCP:</label> {{$mcpName}}
                                                @if($patient->has_mcp_done_onboarding_visit !== 'YES' && $pro->pro_type == 'ADMIN')
                                                    <div moe class="ml-2">
                                                        <a start show><i class="fa fa-edit"></i></a>
                                                        <form url="/api/client/putMcp" class="mcp-theme-1">
                                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                            <div class="mb-2">
                                                                <label class="text-secondary text-sm">MCP Pro</label>
                                                                <select name="mcpProUid" provider-search data-pro-uid="{{ @$patient->mcp->uid }}"
                                                                        class="form-control form-control-sm">
                                                                    <option value=""> --select--</option>
                                                                    @foreach($pros as $iPro)
                                                                        <option
                                                                            value="{{$iPro->uid}}" {{ $patient->mcp && $iPro->uid === $patient->mcp->uid ? 'selected' : '' }}>{{$iPro->displayName()}}</option>
                                                                    @endforeach
                                                                </select>
                                                            </div>
                                                            <div>
                                                                <button submit class="btn btn-sm btn-primary mr-1">
                                                                    Submit
                                                                </button>
                                                                <button cancel class="btn btn-sm btn-default border">
                                                                    Cancel
                                                                </button>
                                                            </div>
                                                        </form>
                                                    </div>
                                                    @if($patient->mcp)
                                                        <div moe class="ml-2">
                                                            <a start show><i class="fa fa-times"></i></a>
                                                            <form url="/api/client/removeMcp" class="mcp-theme-1">
                                                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                                <div class="mb-2">
                                                                    <label class="text-secondary text-sm">Remove MCP Pro</label>

                                                                </div>
                                                                <div>
                                                                    <button submit class="btn btn-sm btn-primary mr-1">Submit
                                                                    </button>
                                                                    <button cancel class="btn btn-sm btn-default border">
                                                                        Cancel
                                                                    </button>
                                                                </div>
                                                            </form>
                                                        </div>
                                                    @endif
                                                @endif
                                            </div>
                                        </div>
                                        <div>
                                            @if($patient->has_mcp_done_onboarding_visit !== 'YES')
                                                <span class="text-dark d-inline-flex align-items-center">
                                            <span class="mr-2">
                                                <i class="fa fa-exclamation-triangle"></i>
                                                MCP Onboarding Visit Pending
                                            </span>
                                        </span>
                                                <span moe>
                                            <a start show><i class="fa fa-edit"></i></a>
                                            <form url="/api/client/updateMcpOnboardingVisitInfo" class="mcp-theme-1">
                                                <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                <div class="mb-2">
                                                    <select name="hasMcpDoneOnboardingVisit"
                                                            class="form-control form-control-sm"
                                                            onchange="toggleDisabledAsNeeded(this, 'YES', 'if-visit-done')">
                                                        <option value="">-- Select Status --</option>
                                                        <option value="YES" {{ $patient->has_mcp_done_onboarding_visit === 'YES' ? 'selected' : '' }}>YES</option>
                                                        <option value="NO" {{ $patient->has_mcp_done_onboarding_visit === 'NO' ? 'selected' : '' }}>NO</option>
                                                        <option value="UNKNOWN" {{ $patient->has_mcp_done_onboarding_visit === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
                                                    </select>
                                                </div>
                                                <div class="mb-2">
                                                    <input type="date"
                                                           class="if-visit-done form-control form-control-sm" disabled
                                                           name="mcpOnboardingVisitDate" value="{{ date('Y-m-d') }}"
                                                           max="{{ date('Y-m-d') }}">
                                                </div>
                                                <div class="mb-2">
                                                    <select name="mcpOnboardingVisitNoteUid" disabled
                                                            class="form-control form-control-sm if-visit-done"
                                                            onchange="if(this.value === '-- create --') createNewNote('{{$patient->uid}}', '{{$pro->uid}}', '{{date('Y-m-d')}}');">
                                                        <option value="">-- Visit Note --</option>
                                                        @foreach ($notes as $note)
                                                            @if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
                                                                <option
                                                                    {{ $patient->mcp_onboarding_visit_note_id === $note->id ? 'selected' : '' }}
                                                                    value="{{$note->uid}}">{{$note->title}} ({{friendly_date_time($note->effective_dateest, false)}})</option>
                                                            @endif
                                                        @endforeach
                                                        {{--<option value="-- create --">-- Create Note --</option>--}}
                                                    </select>
                                                </div>
                                                <div class="mb-2 if-note-outside-system">
                                                    <textarea class="form-control form-control-sm"
                                                              name="reasonOnboardingVisitNoteOutsideSystem"
                                                              placeholder="Visit note outside the system reason"
                                                              spellcheck="false" data-gramm="false"></textarea>
                                                </div>
                                                <div>
                                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
                                                </div>
                                            </form>
                                        </span>
                                            @else
                                                <span class="text-dark d-inline-flex align-items-center">
                                            <span class="mr-2 text-secondary">
                                                <i class="fa fa-check text-sm"></i>
                                                MCP Onboarding Visit Completed
                                            </span>
                                        </span>
                                            @endif
                                        </div>
                                        <div>
                                            <label>Physician:</label> {{$patient->pcp ? $patient->pcp->displayName() : '-' }}
                                            @if($pro->pro_type == 'ADMIN')
                                                <div moe class="ml-2">
                                                    <a start show><i class="fa fa-edit"></i></a>
                                                    <form url="/api/client/putPhysicianPro" class="mcp-theme-1">
                                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                        <div class="mb-2">
                                                            <label class="text-secondary text-sm">Physician Pro</label>
                                                            <select provider-search data-pro-uid="{{ @$patient->pcp->uid }}"
                                                                    name="physicianProUid"
                                                                    class="form-control form-control-sm">
                                                                <option value=""> --select--</option>
                                                                @foreach($pros as $iPro)
                                                                    <option
                                                                        value="{{$iPro->uid}}" {{ $patient->pcp && $iPro->uid === $patient->pcp->uid ? 'selected' : '' }}>{{$iPro->displayName()}}</option>
                                                                @endforeach
                                                            </select>
                                                        </div>
                                                        <div>
                                                            <button submit class="btn btn-sm btn-primary mr-1">Submit
                                                            </button>
                                                            <button cancel class="btn btn-sm btn-default border">
                                                                Cancel
                                                            </button>
                                                        </div>
                                                    </form>
                                                </div>
                                                @if($patient->pcp)
                                                <div moe class="ml-2">
                                                    <a start show><i class="fa fa-times"></i></a>
                                                    <form url="/api/client/removePhysicianPro" class="mcp-theme-1">
                                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                        <div class="mb-2">
                                                            <label class="text-secondary text-sm">Remove Physician Pro</label>

                                                        </div>
                                                        <div>
                                                            <button submit class="btn btn-sm btn-primary mr-1">Submit
                                                            </button>
                                                            <button cancel class="btn btn-sm btn-default border">
                                                                Cancel
                                                            </button>
                                                        </div>
                                                    </form>
                                                </div>
                                                @endif
                                            @endif
                                        </div>
                                    </section>
                                    {{--<section>
                                        <div>
                                            <label>Next Appt:</label>
                                            <?php
                                            $nextAppointment = $patient->nextMcpAppointment();
                                            $startTime = false;
                                            $endTime = false;
                                            if($nextAppointment) {
                                                $startTime = date('H:i', strtotime($nextAppointment->start_time));
                                                $endTime = date('H:i', strtotime($nextAppointment->end_time));
                                                $nextAppointment = date('Y-m-d', strtotime($nextAppointment->start_time));
                                            }
                                            ?>
                                            {{$nextAppointment ? friendly_date_time($nextAppointment . ($startTime ? ' ' . $startTime : ''), true, '') : '-'}}
                                            <span moe relative class="ml-1">
                                                <a start show><i class="fa fa-edit"></i></a>
                                                <form url="/api/appointment/create" class="mcp-theme-1" right>
                                                    <input type="hidden" name="clientUid" value="{{$patient->uid}}">
                                                    <input type="hidden" name="title" value="MCP Appointment">
                                                    <div class="mb-2">
                                                        <label class="text-secondary text-sm">Pro</label>
                                                        <select name="proUid" class="form-control form-control-sm">
                                                            <option value=""> --select-- </option>
                                                            @foreach($pros as $iPro)
                                                                <option value="{{$iPro->uid}}" {{ $iPro->uid === $pro->uid ? 'selected' : '' }}>{{$iPro->displayName()}}</option>
                                                            @endforeach
                                                        </select>
                                                    </div>
                                                    <div class="mb-2">
                                                        <label class="text-secondary text-sm">Date</label>
                                                        <input type="date" name="date" min="{{ date('Y-m-d') }}"
                                                               value="{{ $nextAppointment ? $nextAppointment : date('Y-m-d') }}"
                                                               class="form-control form-control-sm">
                                                    </div>
                                                    <div class="mb-2">
                                                        <label class="text-secondary text-sm">Start Time</label>
                                                        <input type="time" name="startTime" class="form-control form-control-sm"
                                                               value="{{ $startTime ? $startTime : '' }}">
                                                    </div>
                                                    <div class="mb-2">
                                                        <label class="text-secondary text-sm">End Time</label>
                                                        <input type="time" name="endTime" class="form-control form-control-sm"
                                                               value="{{ $endTime ? $endTime : '' }}">
                                                    </div>
                                                    <div>
                                                        <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
                                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
                                                    </div>
                                                </form>
                                            </span>
                                        </div>
                                        <div>
                                            <label>CM:</label> {{ $patient->is_enrolled_in_cm === 'YES' ? 'Yes' : 'No' }}
                                            <label class="ml-2">RM:</label> {{ $patient->is_enrolled_in_rm === 'YES' ? 'Yes' : 'No' }}
                                        </div>
                                    </section>--}}
                                    <section class="vbox mt-2 align-self-start ml-4">
                                        <div moe>
                                            <button start show><i class="fa fa-plus text-sm text-secondary"></i>&nbsp;Note
                                            </button>
                                            <form url="/api/note/createUsingTemplate"
                                                  redir="/patients/view/{{$patient->uid}}/notes/view/[data]"
                                                  class="mcp-theme-1">
                                                <input type="hidden" name="clientUid" value="{{$patient->uid}}">
                                                <input type="hidden" name="hcpProUid" value="{{$pro->uid}}">
                                                <input type="hidden" name="effectiveDateEST" value="{{date("Y-m-d")}}">
                                                <input type="hidden" name="effectiveTime" value="{{date("h:i")}}">
                                                <input type="hidden" name="title" id="note-create-title" value="">
                                                <div class="form-group mb-2">
                                                    <label for="" class="text-secondary text-sm mb-1">Note Template
                                                        *</label>
                                                    <select name="noteTemplateUid" class="form-control form-control-sm"
                                                            onchange="$('#note-create-title').val($(this).find('option:selected').text())"
                                                            required>
                                                        <option value=""> --select--</option>
                                                        @foreach($pro->noteTemplates as $noteTemplate)
                                                            <?php $nT = $noteTemplate->template(); ?>
                                                            <option value="{{$nT->uid}}">{{$nT->title}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                                <div class="form-group m-0">
                                                    <button submit class="btn btn-primary btn-sm">submit</button>
                                                </div>
                                            </form>
                                        </div>
                                        <div>
                                            <div moe relative>
                                                <button start show><i class="fa fa-plus text-sm text-secondary"></i>&nbsp;SMS
                                                </button>
                                                <form url="/api/clientSms/createOutgoing" right class="mcp-theme-1">
                                                    <input type="hidden" name="uid" value="{{ $patient->uid }}">
                                                    <div class="mb-2">
                                                        <label for="" class="text-sm text-secondary mb-1">Cell
                                                            Number</label>
                                                        <input type="text" class="form-control form-control-sm"
                                                               name="cellNumber" value="{{$patient->cell_number}}">
                                                    </div>
                                                    <div class="mb-2">
                                                        <label for=""
                                                               class="text-sm text-secondary mb-1">Message</label>
                                                        <textarea type="text" class="form-control form-control-sm"
                                                                  name="message"></textarea>
                                                    </div>
                                                    <div class="d-flex align-items-center">
                                                        <button class="btn btn-sm btn-primary mr-2" submit>Send</button>
                                                        <button class="btn btn-sm btn-default mr-2 border" cancel>
                                                            Cancel
                                                        </button>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                        <div>
                                        <span moe relative class="">
                                            <button start show title="SMS check-in link to the patient">Send&nbsp;<i
                                                    class="on-hover-opaque fa fa-paper-plane text-secondary"></i></button>
                                            <form url="/api/client/sendCheckInTokenViaSmsOrEmail" right
                                                  class="mcp-theme-1">
                                                <input type="hidden" name="uid" value="{{ $patient->uid }}">
                                                <p class="small min-width-200px mb-2">Send Check-In link to patient?</p>
                                                <div class="mb-2">
                                                    <label for=""
                                                           class="text-sm text-secondary mb-1">Cell Number</label>
                                                    <input type="text" class="form-control input-sm" name="cellNumber"
                                                           value="{{$patient->cell_number}}">
                                                </div>
                                                <div class="mb-2">
                                                    <label for=""
                                                           class="text-sm text-secondary mb-1">Email address</label>
                                                    <input type="text" class="form-control input-sm" name="emailAddress"
                                                           value="{{$patient->email_address}}">
                                                </div>
                                                <div class="d-flex align-items-center">
                                                    <button class="btn btn-sm btn-primary mr-2" submit>Send</button>
                                                    <button class="btn btn-sm btn-default mr-2 border"
                                                            cancel>Cancel</button>
                                                </div>
                                            </form>
                                        </span>
                                        </div>
                                    </section>
                                    <section class="vbox mt-2 align-self-start ml-1">
                                        <div>
                                            <button class="col-2-button" onclick="return openInRHS('/pro/check-video/{{ $patient->uid }}')">Check Video</button>
                                        </div>
                                        <div>
                                            <button class="col-2-button" onclick="return openInRHS('/pro/meet/{{ $patient->uid }}')">Join Video</button>
                                        </div>
                                        <div class="">
                                            @if($pro->isWorkingOnClient($patient))
                                                {{-- stop work on client --}}
                                                <div moe>
                                                    <form url="/api/proClientWork/KillRunningWorkForSelf"
                                                          class="mcp-theme-1" show>
                                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                        <div>
                                                            <button class="col-2-button" submit><i class="fa fa-stop text-secondary"></i>&nbsp;Work:
                                                                Stop
                                                            </button>
                                                        </div>
                                                    </form>
                                                </div>
                                            @else
                                                {{-- start work on client --}}
                                                <div moe>
                                                    <form url="/api/proClientWork/create" class="mcp-theme-1" show>
                                                        <input type="hidden" name="clientUid" value="{{$patient->uid}}">
                                                        <div>
                                                            <button class="col-2-button" submit><i class="fa fa-play text-secondary"></i>&nbsp;Work:
                                                                Start
                                                            </button>
                                                        </div>
                                                    </form>
                                                </div>
                                            @endif
                                        </div>
                                        <div class="mr-auto">
                                            @if($pro->isWorkingOnClient($patient))
                                                <div class="d-flex align-items-center">
                                                    @if($patient->active_mcp_request_id)
                                                        {{-- kill mcp request for client --}}
                                                        <div moe relative class="">
                                                            <button href="" start show class="col-2-button"><i
                                                                    class="fa fa-times text-danger"></i>&nbsp;MCP Req.
                                                            </button>
                                                            <form url="/api/mcpRequest/kill" class="mcp-theme-1" right>
                                                                <input type="hidden" name="clientUid"
                                                                       value="{{$patient->uid}}">
                                                                <p>Kill the MCP Request for this patient?</p>
                                                                <div>
                                                                    <button submit class="btn btn-sm btn-primary mr-2">
                                                                        Yes
                                                                    </button>
                                                                    <button cancel
                                                                            class="btn btn-sm btn-default border">Cancel
                                                                    </button>
                                                                </div>
                                                            </form>
                                                        </div>
                                                    @else
                                                        {{-- create mcp request for client --}}
                                                        <div moe relative class="">
                                                            <button href="" start show class="col-2-button"><i
                                                                    class="fa fa-plus text-sm text-secondary"></i>&nbsp;MCP
                                                                Req.
                                                            </button>
                                                            <form url="/api/mcpRequest/createAsPro" class="mcp-theme-1"
                                                                  right>
                                                                <p>Create an MCP Request for this patient?</p>
                                                                <div>
                                                                    <button submit class="btn btn-sm btn-primary mr-2">
                                                                        Yes
                                                                    </button>
                                                                    <button cancel
                                                                            class="btn btn-sm btn-default border">Cancel
                                                                    </button>
                                                                </div>
                                                            </form>
                                                        </div>
                                                    @endif
                                                </div>
                                            @endif
                                        </div>
                                    </section>

                                    <ul class="vbox ml-auto mt-2 align-self-start patient-header-address">
                                        <li class="d-flex align-items-start">
                                            <span class="aligned-icon"><i class="fa fa-map-marker-alt"
                                                                          aria-hidden="true"></i></span>
                                            <div class="position-relative">
                                                <?php
                                                $addressParts = [];
                                                if (!!$patient->mailing_address_line1) $addressParts[] = $patient->mailing_address_line1;
                                                if (!!$patient->mailing_address_line2) $addressParts[] = $patient->mailing_address_line2;
                                                $addressParts = implode(", ", $addressParts) . "<br/>";
                                                $addressPart2 = [];
                                                if (!!$patient->mailing_address_city) $addressPart2[] = $patient->mailing_address_city;
                                                if (!!$patient->mailing_address_state) $addressPart2[] = $patient->mailing_address_state;
                                                $addressParts .= implode(", ", $addressPart2);
                                                echo $addressParts;
                                                ?>
                                                {{ $patient->mailing_address_zip ? $patient->mailing_address_zip : '' }}
                                                @if($patient->mailing_address_memo)
                                                    <span
                                                        class="position-relative c-pointer text-center stag-tooltip ml-2">
                                                    <i class="fa fa-info-circle"></i>
                                                    <div
                                                        class="position-absolute bg-white border rounded p-2 stag-tooltip-content">
                                                        <div class="text-left font-weight-bold pb-1">Special Instructions</div>
                                                        <div
                                                            class="text-left font-weight-normal">{{$patient->mailing_address_memo}}</div>
                                                    </div>
                                                </span>
                                                @endif
                                            </div>
                                        </li>
                                        @if($patient->cell_number)
                                            <li>
                                                <span class="aligned-icon"><i class="fa fa-phone-alt"
                                                                              aria-hidden="true"></i></span>
                                                {{$patient->cell_number}}<span
                                                    class="small text-secondary ml-1">{{ $patient->cell_number_memo ? '(' . $patient->cell_number_memo . ')' : '' }}</span>
                                            </li>
                                        @endif
                                        @if($patient->phone_home)
                                            <li>
                                                <span class="aligned-icon"><i class="fa fa-home" aria-hidden="true"></i></span>
                                                {{$patient->phone_home}}
                                            </li>
                                        @endif
                                        <li>
                                            <span class="aligned-icon"><i class="fa fa-envelope" aria-hidden="true"></i></span>
                                            {{$confirmedEmail}}
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div> <!-- z -->
                    </div>
                    {{--<div class="text-container border-bottom d-flex align-items-center mcp-theme-1 px-3">

                        @if($patient->mcp_pro_id !== $pro->id && $patient->active_mcp_request_id)
                            <div moe relative class="ml-2">
                                <a href="" start show class="btn btn-sm btn-success text-white font-weight-bold small">Claim as MCP</a>
                                <form url="/api/mcpRequest/claim" class="mcp-theme-1" right>
                                    <input type="hidden" name="clientUid" value="{{$patient->uid}}">
                                    <p>Claim this patient?</p>
                                    <div>
                                        <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
                                    </div>
                                </form>
                            </div>
                        @endif
                    </div>--}}
                    <div class="card-body">
                        {{--<h1 class="h3">@yield('section-title')</h1>--}}
                        <div class="mcp-theme-1">
                            @yield('inner-content')
                        </div>
                    </div>
                </div>
            </main>
        </div>
    </div>
@endsection
