@extends ('layouts/template')

@section('content')
    <style>
        td, th {
            text-align: center !important;
        }
    </style>
    <div class="p-3 mcp-theme-1">
        <div class="card border-left-0 border-right-0 border-bottom-0">
            <div class="card-header border-left border-right border-bottom-0 py-1 px-2 d-flex align-items-center">
                <strong class="mr-4">
                    <i class="fas fa-chart-bar"></i>
                    RPM Matrix
                </strong>
            </div>

            <div class="card-body p-0">
                <table class="table table-bordered table-sm table-striped p-0 m-0">
                    <thead class="bg-light">
                        <tr>
                            <th class="border-0">Chart #</th>
                            <th class="border-0">Name</th>
                            <th class="border-0">DOB</th>
                            @if($pro->pro_type == 'ADMIN')
                            <th class="border-0">MCP</th>
                            @endif
                            <th class="border-0">BP</th>
                            <th class="border-0"> <i class="fa fa-heartbeat"></i> </th>
                            <th class="border-0">Pulse</th>
                            <th class="border-0">BP/Pulse Timestamp</th>
                            <th class="border-0">BP <i class="fa fa-car-battery"></i></th>
                            <th class="border-0">BP <i class="fa fa-broadcast-tower"></i></th>
                            <th class="border-0">Weight</th>
                            <th class="border-0">Weight Timestamp</th>
                            <th class="border-0">Scale <i class="fa fa-battery"></i></th>
                            <th class="border-0">Scale <i class="fa fa-broadcast-tower"></i></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($clients as $client)
                            <tr>
                                <td>
                                    <a native target="_blank" href="{{route('patients.view.dashboard', $client)}}">
                                        {{$client->chart_number}}
                                    </a>
                                </td>
                                <td>
                                    <a native target="_blank" href="{{route('patients.view.dashboard', $client)}}">
                                        {{$client->name_last}}, {{$client->name_first}}
                                    </a>
                                </td>
                                <td>{{ $client->dob }}</td>
                                @if($pro->pro_type == 'ADMIN')
                                <td>{{ $client->mcp->name_display ?? '--' }}</td>
                                @endif
                                <td>
                                    @if($client->most_recent_cellular_bp_measurement_at)
                                        {{ $client->most_recent_cellular_bp_sbp_mm_hg }} / {{ $client->most_recent_cellular_bp_dbp_mm_hg }}
                                    @endif
                                </td>
                                <td><?= $client->most_recent_cellular_bp_value_irregular ? '<i class="fa fa-heartbeat"></i>' : '' ?></td>
                                <td>{{ $client->most_recent_cellular_bp_value_pulse }}</td>
                                <td>{{ friendlier_date_time($client->most_recent_cellular_bp_measurement_at) }}</td>
                                <td>{{ $client->most_recent_cellular_bp_battery_voltage }}</td>
                                <td>{{ $client->most_recent_cellular_bp_signal_strength }}</td>
                                <td>{{ $client->most_recent_cellular_weight_value ? round($client->most_recent_cellular_weight_value, 2) : '--' }}</td>
                                <td>{{ friendlier_date_time($client->most_recent_cellular_weight_measurement_at) }}</td>
                                <td>{{ $client->most_recent_cellular_weight_battery_voltage }}</td>
                                <td>{{ $client->most_recent_cellular_weight_signal_strength }}</td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
        <div class="mt-2">
            {{$clients->links()}}
        </div>
    </div>
@endsection
