@extends ('layouts/template')

@section('content')

    <div class="p-3 mcp-theme-1">
    <div class="card">

        <div class="card-header px-3 py-2 d-flex align-items-center">
            <strong class="mr-4">
                <i class="fas fa-user-injured"></i>
                Patients
            </strong>
            <select class="ml-auto max-width-300px form-control form-control-sm" onchange="fastLoad('/patients/' + this.value, true, false, false)">
                <option value="" {{ $filter === '' ? 'selected' : '' }}>All patients</option>
                <option value="not-yet-seen" {{ $filter === 'not-yet-seen' ? 'selected' : '' }}>Patients I have not seen yet</option>
            </select>
        </div>
        <div class="card-body p-0">
            <table class="table table-condensed p-0 m-0">
                <thead class="bg-light">
                <tr>
                    <th class="px-3 border-0">#</th>
                    <th class="border-0">Name</th>
                    <th class="border-0">DOB</th>
                    <th class="border-0">Sex</th>
                    <th class="border-0">MCN</th>
                    <th class="border-0">PCP</th>
                    <th class="border-0">Assistant</th>
                    <th class="border-0">Next E&M</th>
                </tr>
                </thead>
                <tbody>
                @foreach($patients as $patient)
                    <tr>
                        <td class="px-3">
                            <a href="{{route('patients.view.dashboard', $patient)}}">
                                {{$patient->chart_number}}
                            </a>
                        </td>
                        <td>
                            {{$patient->displayName()}}
                            @if($patient->has_mcp_done_onboarding_visit !== 'YES')
                            <span title="MCP Onboarding Visit Pending"><i class="fa fa-exclamation-triangle"></i></span>
                            @endif
                        </td>
                        <td>{{ friendly_date_time($patient->dob, false) }}</td>
                        <td>{{ $patient->sex === 'M' ? 'Male' : 'Female' }}</td>
                        <td>
                            @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)
                                <div>Valid Medicare Number</div>
                                    <div class="text-secondary">Not Medicare Part B</div>
                                    @if($patient->is_medicare_advantage == 'YES')
                                        <div class="text-secondary">Medicare Advantage: <b>{{$patient->medicare_advantage_plan}}</b></div>
                                    @endif
                            @else
                                @if($patient->mcn)
                                    <div>Invalid MCN</div>
                                @else
                                    <div>No Info Provided</div>
                                @endif
                            @endif
                        </td>
                        <td>
                            {{ $patient->mcp ? $patient->mcp->displayName() : '-' }}
                        </td>
                        <td>
                            {{ $patient->cm ? $patient->cm->displayName() : '-' }}
                        </td>
                        <td>
                            {{$patient->next_appointment ? friendly_date_time($patient->next_appointment, false) : '-'}}
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
    </div>

@endsection
