@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">
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.dashboard', ['patient' => $patient]) }}">Dashboard</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.care-months', ['patient' => $patient]) }}">Care Months</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.notes', ['patient' => $patient]) }}">Notes</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.action-items', ['patient' => $patient]) }}">ERx/Orders</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.allergies', ['patient' => $patient]) }}">Allergies</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.medications', ['patient' => $patient]) }}">Medications</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.dx-and-focus-areas', ['patient' => $patient]) }}">Current Focus Areas</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.care-team', ['patient' => $patient]) }}">Care Team</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.history', ['patient' => $patient]) }}">History</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.sms', ['patient' => $patient]) }}">SMS</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.sms-numbers', ['patient' => $patient]) }}">SMS Numbers</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.documents', ['patient' => $patient]) }}">Documents</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.demographics', ['patient' => $patient]) }}">Contact Info</a>
                        </li>
                        {{--<li class="nav-item">
                            <a class="nav-link" href="/patients/view/{{ $patient->uid }}/intake">Intake</a>
                        </li>--}}
                        <?php /*
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.care-plan', ['patient' => $patient]) }}">Care Plan</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.measurements', ['patient' => $patient]) }}">Measurements</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.labs-and-studies', ['patient' => $patient]) }}">Labs and Studies</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.immunizations', ['patient' => $patient]) }}">Immunizations</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.allergies', ['patient' => $patient]) }}">Allergies</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.flowsheets', ['patient' => $patient]) }}">Flowsheets</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.demographics', ['patient' => $patient]) }}">Demographics</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.account', ['patient' => $patient]) }}">Account</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.care-checklist', ['patient' => $patient]) }}">Care Checklist</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.documents', ['patient' => $patient]) }}">Documents</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.education', ['patient' => $patient]) }}">Education</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.messaging', ['patient' => $patient]) }}">Messaging</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ route('patients.view.duplicate', ['patient' => $patient]) }}">Duplicate</a>
                        </li>
                        */ ?>
                    </ul>
                    <div class="mt-3 mcp-theme-1">
                        @yield('left-nav-content')
                    </div>
                </div>
            </nav>
            <main role="main" class="">
                <div class="card mt-3">
                    <div class=card-header>
                        <?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="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>
                                    {{--<ul class=hbox>
                                        <li><i class="fa fa-phone-alt" aria-hidden="true"></i> {{$confirmedCell}}</li>
                                        <li><i class="fa fa-envelope" aria-hidden="true"></i> {{$confirmedEmail}}</li>
                                        <li><i class="fa fa-map-marker-alt" aria-hidden="true"></i> {{$location}}</li>
                                        <li>
                                            <div moe>
                                                <a start show><i class="fa fa-edit"></i></a>
                                                <form url="/api/client/putContactInfo" class="mcp-theme-1">
                                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                    <div class="mb-2">
                                                        <input type="tel"
                                                               class="form-control form-control-sm"
                                                               name="cellNumber"
                                                               placeholder="Phone Number"
                                                               value="{{ $patient->cell_number }}">
                                                    </div>
                                                    <div class="mb-2">
                                                        <input type="text"
                                                               class="form-control form-control-sm"
                                                               name="email"
                                                               placeholder="Email"
                                                               value="{{ $patient->email_address }}">
                                                    </div>
                                                    <div class="mb-2">
                                                        <input type="text"
                                                               class="form-control form-control-sm"
                                                               name="city"
                                                               placeholder="City"
                                                               value="{{ $patient->home_address_city }}">
                                                    </div>
                                                    <div class="mb-2">
                                                        <input type="text"
                                                               class="form-control form-control-sm"
                                                               name="state"
                                                               placeholder="State"
                                                               value="{{ $patient->home_address_state }}">
                                                    </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>
                                        </li>
                                    </ul>--}}
                                    <div class=separators>
                                        <div>Joined <?=$memberSince?></div>
                                        <div><label>PCP:</label> {{$mcpName}}</div>
                                        <div><label>MA:</label> {{$cmName}}</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>
                                                    <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>
                                </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 ml-4">
                                    <div moe>
                                        <button start show>+ 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())">
                                                    <option value=""> --select-- </option>
                                                    @foreach($noteTemplates as $noteTemplate)
                                                    <option value="{{$noteTemplate->uid}}">{{$noteTemplate->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>+ 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>
                                        <button onclick="return openInRHS('/pro/meet/{{ $patient->uid }}')">Video</button>
                                        <span moe relative class="ml-1">
                                            <a start show title="SMS check-in link to the patient"><i class="on-hover-opaque fa fa-paper-plane"></i></a>
                                            <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>
                            </div>
                        </div></div> <!-- z -->
                    </div>

                    <div class="card-header" style=display:none>
                        @if($patient->is_duplicate)
                            <div class="alert alert-danger">
                                This chart is a duplicate of: __________
                            </div>
                        @endif
                        <div class="d-flex">
                            <div class="">
                                <div class="d-flex">
                                    <div class="d-flex align-items-center">
                                        <div class="font-weight-bold" style="font-size: 1.4em">
                                            {{$patient->name_last}}, {{$patient->name_first}}
                                        </div>
                                        @if(!$patient->was_medicare_validation_successful)
                                            <div moe class="ml-2">
                                                <a href="" start show>
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                                <form url="/api/client/editName">
                                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                    <div class="form-group">
                                                        Prefix: <input type="text" name="namePrefix"
                                                                       value="{{$patient->name_prefix}}"><br>
                                                        First: <input type="text" name="nameFirst"
                                                                      value="{{$patient->name_first}}"><br>
                                                        Middle: <input type="text" name="nameMiddle"
                                                                       value="{{$patient->name_middle}}"><br>
                                                        Last: <input type="text" name="nameLast"
                                                                     value="{{$patient->name_last}}"><br>
                                                        Suffix: <input type="text" name="nameSuffix"
                                                                       value="{{$patient->name_suffix}}"><br>
                                                        Credential: <input type="text" name="nameCredential"
                                                                           value="{{$patient->name_credential}}"><br>
                                                        Nickname: <input type="text" name="nameNickname"
                                                                         value="{{$patient->name_nickname}}"><br>
                                                        Maiden: <input type="text" name="nameMaiden"
                                                                       value="{{$patient->name_maiden}}"><br>
                                                        Previous: <input type="text" name="namePrevious"
                                                                         value="{{$patient->name_previous}}">
                                                    </div>
                                                    <div class="form-group">
                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
                                                        <button class="btn btn-secondary btn-sm" cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </div>
                                        @endif
                                        <span class="pl-2">
                                            {{$patient->dob}}
                                            {{$patient->age_in_years}} y.o. {{$patient->sex}}
                                        </span>
                                        @if(!$patient->was_medicare_validation_successful)
                                            <div moe class="ml-2">
                                                <a href="" start show>
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                                <form url="/api/client/editDob">
                                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                    <div class="form-group">
                                                        <input type="date" class="" name="dob"
                                                               value="{{$patient->dob}}">
                                                    </div>
                                                    <div class="form-group">
                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
                                                        <button class="btn btn-secondary btn-sm" cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </div>
                                        @endif
                                    </div>
                                    <div class="align-items-center d-flex">
                                        <i class="badge badge-info ml-3">
                                            #{{$patient->chart_number}}
                                        </i>
                                    </div>
                                    <div class="pl-3">
                                        <strong>PCP:</strong>
                                        @if($patient->mcp)
                                            {{$patient->mcp->name_display}}...
                                            @if($patient->has_mcp_done_onboarding_visit == 'YES')
                                                <strong>First E&M
                                                    Visit:</strong> {{$patient->mcp_onboarding_visit_date}}...
                                                <strong>Last E&M Visit:</strong>
                                                {$patient->most_recent_mcp_em_visit_date}...
                                                <strong>Next E&M Visit:</strong> {$patient->next_mcp_em_visit_date}
                                            @else
                                                <span class="alert alert-success text-sm p-1">
                                                    <i class="fa fa-exclamation-circle" aria-hidden="true"></i>
                                                    Patient has not been seen yet!
                                                </span>
                                            @endif
                                        @else
                                            <div moe>
                                                none!
                                                <a href="" start show>
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                                <form url="/api/client/putMcp">
                                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                    <div class="form-group">
                                                        <select name="mcpProUid" class="form-control">
                                                            <option value="">-- select mcp --</option>
                                                            @foreach ($pros as $iPro)
                                                                <option
                                                                    value="{{$iPro->uid}}">{{$iPro->name_display}}</option>
                                                            @endforeach
                                                        </select>
                                                    </div>
                                                    <div class="form-group">
                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
                                                        <button class="btn btn-secondary btn-sm" cancel>Cancel</button>
                                                    </div>
                                                </form>
                                            </div>
                                        @endif
                                    </div>
                                </div>
                                <div class="d-flex">
                                    <div>
                                        <strong>MCN:</strong>
                                        @if($patient->mcn)
                                            @if($patient->was_medicare_validation_successful)
                                                <span
                                                    class="badge badge-{{$patient->is_part_b_primary == 'YES' ? 'success' : 'danger'}}">
                                                    Valid #,
                                                    @if($patient->is_part_b_primary == 'YES')
                                                        Medicare Part B <i class="fa fa-check"></i>
                                                    @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
                                                <span class="badge badge-warning">
                                                    {{$patient->mcn}}
                                                    INVALID! <i class="fa fa-times"></i>
                                                </span>
                                            @endif
                                        @else
                                            None provided. <i class="fa fa-times"></i>
                                        @endif
                                        @if(!$patient->was_medicare_validation_successful)
                                            <div moe>
                                                <a href="" start show><i class="fas fa-edit"></i></a>
                                                <form url="/api/client/putMcn" class="mcp-theme-1">
                                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
                                                    <div class="form-group">
                                                        <input type="text" class="form-control form-control-sm" name="mcn" value="{{$patient->mcn}}">
                                                    </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 class="d-flex">
                                        <div class="pl-3">
                                            <strong>MA:</strong>
                                            @if($patient->cm)
                                                {{$patient->cm->name_display}}
                                            @else
                                                <div>
                                                    none!
                                                </div>
                                            @endif
                                        </div>
                                    </div>
                                </div>
                                <div class="d-flex">
                                    <div>
                                        <strong>
                                            Focus areas:
                                        </strong>
                                        T2DM, CAD, HTN, Weight Loss
                                    </div>
                                    <div class="pl-4">
                                        <strong>Ht:</strong> ___ in. <strong>Wt:</strong> ___ lbs. <strong>BMI:</strong>
                                        ___
                                    </div>
                                </div>
                                <div>
                                    <strong>
                                        Allergies:
                                    </strong>
                                    ...
                                    ...
                                    ...
                                </div>
                            </div>
                            <div class="text-right flex-fill">
                                <div moe>
                                    <a start show class="btn btn-primary btn-sm">
                                        <i class="fa fa-plus-circle"></i>
                                        Note
                                    </a>
                                    <form url="/api/note/create" right>
                                        <input type="hidden" name="clientUid" value="{{$patient->uid}}">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label for="" class="text-sm text-secondary mb-1">HCP Pro</label>
                                                    <select name="hcpProUid" class="form-control">
                                                        <option value="">-- select hcp pro --</option>
                                                        @foreach ($pros as $iPro)
                                                            <option
                                                                value="{{$iPro->uid}}">{{$iPro->name_display}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>
                                                {{--<div class="form-group">
                                                    <label for="" class="control-label">Ally Pro</label>
                                                    <select name="allyProUid" class="form-control">
                                                        <option value="">-- select ally pro --</option>
                                                        @foreach ($pros as $iPro)
                                                            <option
                                                                value="{{$iPro->uid}}">{{$iPro->name_display}}</option>
                                                        @endforeach
                                                    </select>
                                                </div>--}}
                                                <div class="form-group">
                                                    <label for="" class="control-label text-left">Title</label>
                                                    <input type="text" name="title" class="form-control">
                                                </div>
                                                <div class="form-group">
                                                    <label for="" class="control-label text-left">Effective date</label>
                                                    <input type="date" name="effectiveDateEST" class="form-control">
                                                </div>

                                                <div class="form-group">
                                                    <label for="" class="control-label text-left">Effective time</label>
                                                    <input type="time" name="effectiveTime" class="form-control">
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label for="" class="control-label">reason1</label>
                                                    <input type="text" name="reason1" class="form-control">
                                                </div>

                                                <div class="form-group">
                                                    <label for="" class="control-label">reason2</label>
                                                    <input type="text" name="reason2" class="form-control">
                                                </div>

                                                <div class="form-group">
                                                    <label for="" class="control-label">reason3</label>
                                                    <input type="text" name="reason3" class="form-control">
                                                </div>

                                                <div class="form-group">
                                                    <label for="" class="control-label">reason3Plus</label>
                                                    <input type="text" name="reason3Plus" class="form-control">
                                                </div>

                                                <div class="form-group">
                                                    <label for="" class="control-label">serviceLocation</label>
                                                    <input type="text" name="serviceLocation" class="form-control">
                                                </div>

                                                <div class="form-group">
                                                    <label for="" class="control-label">category</label>
                                                    <input type="text" name="category" class="form-control">
                                                </div>
                                            </div>
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <button class="btn btn-primary" submit>Submit</button>
                                                    <button class="btn btn-danger" cancel>Cancel</button>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>

                                <br>
                                <button class="btn btn-primary btn-sm mt-2">
                                    <i class="fa fa-book"></i>
                                    Education
                                </button>
                            </div>
                        </div>
                        {{-- go to patient's call page --}}
                        <div class="p-3 border small mt-3 bg-white">
                            <div class="mr-3 my-1">Online:
                                <span class="font-weight-bold">
                                        <?= $patient->is_online ? '<span class="text-success">YES</span>' : '<span class="text-secondary">NO</span>' ?>
                                    </span>
                            </div>
                            <div class="mr-3 my-1">Video:
                                <span class="font-weight-bold">
                                        <?= $patient->is_client_video_turned_on ? '<span class="text-success">ON</span>' : '<span class="text-secondary">OFF</span>' ?>
                                    </span>
                                @if($patient->is_online && $patient->is_client_video_turned_on && count($patient->prosInMeetingWith()))
                                    <div class="my-1 font-weight-bold">Currently talking to:</div>
                                    @foreach($patient->prosInMeetingWith() as $inCallPro)
                                        <div class="d-block my-1">
                                            <i class="fa fa-chevron-right mr-1"></i>
                                            <a href="/pros/view/{{ $inCallPro->uid }}/SUB_dashboard"
                                               class="text-primary">
                                                {{ $inCallPro->name_display }}
                                            </a>
                                        </div>
                                    @endforeach
                                @endif
                            </div>
                            <div>
                                <a href="#"
                                   class="btn btn-sm btn-primary mt-2 font-weight-bold px-3"
                                   onclick="return openInRHS('/pro/meet/{{ $patient->uid }}')">
                                    <i class="fa fa-phone mr-1"></i>
                                    Go to the client's meeting page
                                </a>
                            </div>
                        </div>
                    </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
