<div class="d-flex align-items-stretch m-0 h-100">
    {{--<div class="overflow-auto border-right h-100 rpm-matrix-left-column">
        @include('app.stat-tree.summary', ['slug' => 'rm-tree-' . $mode, 'showForPro' => $pro, 'noDropVisualize' => true, 'stParams' => ['start_date' => $rcmStartDate]])
    </div>--}}
    <div class="flex-grow-1 px-0 overflow-auto h-100 rpm-matrix-right-column">
        <?php $trIndex = 0; ?>
        @if(!request()->input('not-enrolled'))
            @foreach ($patients as $iPatient)
                <script>
                    addMCHook(
                        'refresh-rpm-row-{{$trIndex}}',
                        function () {
                            refreshRpmRow({{$trIndex}});
                        }
                    );
                </script>
                <?php $trIndex++; ?>
            @endforeach
        @endif
        <table class="table table-sm table-striped table-hover p-0 m-0 min-width-1100px" id="table-rm-matrix">
            <thead class="bg-light">
            <tr>
                <th class="border-0 pl-2">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'Name', 'key' => 'client_name'])</th>
                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'DOB', 'key' => 'dob'])</th>
                <th class="border-0 text-secondary">Cell. BP?</th>
                <th class="border-0 text-secondary">Cell. Scale?</th>
                <th class="border-0 text-secondary">Latest BP</th>
                <th class="border-0 text-secondary">Latest Wt</th>
                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'Days Since Last Visit', 'key' => 'days_between_most_recent_mcp_note_date_and_end_of_care_month'])</th>
                @if($mode === 'mcp' || $mode === 'rmm')
                    @if($strategy === 'X16_DAYS_20_MINS_ON_OWN_MCP_COM_DURING_CM')
                        <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'Interacted?', 'key' => 'has_mcp_interacted_with_client_about_rm'])</th>
                    @endif
                    <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#Meas. Days', 'key' => 'number_of_days_with_remote_measurements'])</th>
                    @if($mode === 'mcp')
                        <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#MCP Mins.', 'key' => 'rm_total_time_in_seconds_by_mcp'])</th>
                    @else
                        <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#RMM Mins.', 'key' => 'rm_total_time_in_seconds_by_rmm_pro'])</th>
                    @endif
                @elseif($mode === 'rme')
                    <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#Meas. Days', 'key' => 'number_of_days_with_remote_measurements'])</th>
                    <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => '#RME Mins.', 'key' => 'rm_total_time_in_seconds_by_rme_pro'])</th>
                @endif
                @if(!request()->input('not-enrolled'))
                    {{--
                    @if(!request()->input('f_billable') || request()->input('f_billable') === 'all')
                        @if($mode === 'mcp')
                            <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'Billable', 'key' => 'mcp_rm_generic_bill_id'])</th>
                        @elseif($mode === 'rmm')
                            <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.rpm-matrix-" . $mode), 'label' => 'Billable', 'key' => 'rmm_rm_generic_bill_id'])</th>
                        @endif
                    @else
                        <th class="border-0 text-secondary">Billable</th>
                    @endif
                    --}}
                    <th class="border-0 text-secondary">Billable</th>
                @endif
            </tr>
            </thead>
            <tbody>
            <?php $trIndex = 0; ?>
            @foreach ($patients as $iPatient)
                <?php

                $daysDiff = -1;
                if ($iPatient->most_recent_completed_mcp_note_date) {
                    $careMonthLastDay = date_add(date_create($rcmStartDate), date_interval_create_from_date_string("1 month"));
                    $careMonthLastDay = date_sub($careMonthLastDay, date_interval_create_from_date_string("1 day"));
                    $daysDiff = date_diff($careMonthLastDay, date_create($iPatient->most_recent_completed_mcp_note_date))->days;
                }
                $lastVisitWithinDays = ($iPatient->days_between_most_recent_mcp_note_date_and_end_of_care_month  <= config('app.maxDaysSinceLastVisit'));

                ?>
                @include('app.practice-management.remote-monitoring-row-markup-by-pro-type')
                <?php $trIndex++; ?>
            @endforeach
            </tbody>
        </table>
    </div>
</div>