@extends(request()->input('popupmode') ? 'layouts.empty' : 'layouts.template')

@section('content')
    <div class="p-3 mcp-theme-1">
        <div class="card border-top-0">

            <div class="card-header px-3 py-2 border-bottom-0 hide-inside-popup">
                <strong class="mr-4">
                    <i class="fas fa-user"></i>
                    New Patients Awaiting Visit
                </strong>
            </div>

            <div class="card-body p-0 pb-0">
                <table class="table table-sm table-striped border-top mb-0">
                    <thead class="bg-light">
                    <tr>
                        <th class="border-0"> #</th>
                        <th class="border-0">Name</th>
                        <th class="border-0">DOB</th>
                        <th class="border-0">Gender</th>
                        <th class="border-0">BMI</th>
                        <th class="border-0">Insurance</th>
                        <th class="border-0">Last Visit</th>
                        <th class="border-0">Next Appt.</th>
                        <th class="border-0">Status</th>
                        <th class="border-0">RPM</th>
                        <th class="border-0 d-none">Last Weight-In</th>
                        <th class="border-0 d-none">Last BP</th>
                        <th class="border-0">Assigned On</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($records as $row)
                        <tr>
                            <td>
                                <a target="_blank" native href="{{route('patients.view.dashboard', $row)}}">
                                    {{$row->chart_number}}
                                </a>
                            </td>
                            <td>{{implode(' ', [$row->name_first, $row->name_last])}}</td>
                            <td>{{friendly_date($row->dob)}}</td>
                            <td>{{$row->sex}}</td>
                            <td>{{$row->usual_bmi}}</td>
                            <td>
                                @include('app.patient.coverage_column_renderer', ['patient'=>$row])
                            </td>
                            <td>{{$row->lastMcpAppointment() ? @$row->lastMcpAppointment()->start_date : '-'}}</td>
                            <td>{{$row->nextMcpAppointment() ? @$row->nextMcpAppointment()->start_date : '-'}}</td>
                            <td>{{$row->nextMcpAppointment() ? @$row->nextMcpAppointment()->status : '-'}}</td>
                            <td>{{$row->currentCareMonth() && $row->currentCareMonth()->is_client_enrolled_in_rm ? 'Yes' : 'No'}}</td>
                            <td class="d-none">
                                <?php $m = $row->lastMeasurementOfType('Wt. (lbs.)'); ?>
                                {{$m && $m->value ? round($m->value, 2) : '-'}}
                            </td>
                            <td class="d-none">
                                <?php $m = $row->lastMeasurementOfType('BP'); ?>
                                {{$m && $m->value ? $m->value : '-'}}
                            </td>
                            <td>{{$row->getMcpAssignedOn()}}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
