Przeglądaj źródła

Admin rom matrix

Vijayakrishnan 3 lat temu
rodzic
commit
1ed5da3b79

+ 44 - 14
app/Http/Controllers/PracticeManagementController.php

@@ -1258,33 +1258,52 @@ WHERE
 
     public function remoteMonitoringAdmin(Request $request) {
 
+        $performer = $this->performer();
+
+        // abort_if($performer->pro->pro_type !== 'ADMIN' && !$performer->pro->can_view_rm_matrix, 403);
+
         $ym = ($request->input('y') ?: 'Y') . '-' . ($request->input('m') ?: 'm');
         $careMonthStart = date($ym . '-01');
 
         $rc = $request->input('rc') ?: 1;
         $rc2 = $request->input('rc2') ?: 2;
 
-        $conditions = $this->rpmConditionsAdmin($this->performer(), $rc, $rc2);
+        $conditions = [];// $this->rpmConditions($performer, $rc, $rc2);
 
-        $patients = DB::select(
-            DB::raw(
-                "
-SELECT client.name_first, 
-       client.name_last, 
+        $sortBy = $request->input('sort_by') ?: 'name_first';
+        $sortDir = $request->input('sort_dir') ?: 'ASC';
+        $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST";
+
+        $query = "
+SELECT client.name_first, client.name_last,
+       (client.name_first || ' ' || client.name_last) as client_name,
+       (mcp_pro.name_first || ' ' || mcp_pro.name_last) as mcp_pro_name,
+       (rmm_pro.name_first || ' ' || rmm_pro.name_last) as rmm_pro_name,
        client.uid as client_uid, 
        client.dob,
        client.is_enrolled_in_rm,
        client.most_recent_completed_mcp_note_date,
+       client.most_recent_completed_mcp_note_id,
+       mrmnote.effective_dateest::date as most_recent_completed_mcp_note_date_cm,
+       mrmnote.id as most_recent_completed_mcp_note_id_cm,
+       mrmnote.uid as most_recent_completed_mcp_note_uid_cm,
+       client.cell_number,
+       client.is_assigned_cellular_bp_device,
+       client.is_assigned_cellular_weight_scale_device,
        care_month.uid as care_month_uid,
        care_month.id as care_month_id,
        care_month.start_date,
        care_month.rm_total_time_in_seconds_by_mcp,
+       care_month.rm_total_time_in_seconds_by_rmm_pro,
        care_month.number_of_days_with_remote_measurements,
-       care_month.has_anyone_interacted_with_client_about_rm_outside_note,
+       care_month.has_anyone_interacted_with_client_about_rm,
+       care_month.has_mcp_interacted_with_client_about_rm,
        care_month.rm_num_measurements_not_stamped_by_mcp,
        care_month.rm_num_measurements_not_stamped_by_non_hcp,
        care_month.rm_num_measurements_not_stamped_by_rmm,
        care_month.rm_num_measurements_not_stamped_by_rme,
+       care_month.mcp_pro_id as care_month_mcp_pro_id,
+       care_month.rmm_pro_id as care_month_rmm_pro_id,
        client.mcp_pro_id,
        client.default_na_pro_id,
        client.rmm_pro_id,
@@ -1295,16 +1314,27 @@ SELECT client.name_first,
        client.most_recent_cellular_bp_measurement_at,      
        client.most_recent_cellular_weight_value,
        client.most_recent_cellular_weight_measurement_at
-FROM care_month join client on care_month.client_id = client.id
+FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
+     left join note mrmnote on mrmnote.id = (
+        select max(n.id) from note n 
+        where 
+              n.client_id = client.id AND 
+              n.is_cancelled = FALSE AND
+              (n.is_signed_by_hcp IS NOT NULL AND n.is_signed_by_hcp = TRUE) AND
+              n.effective_dateest::date >= care_month.start_date::date AND 
+              n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
+     )
+    left join pro mcp_pro on care_month.mcp_pro_id = mcp_pro.id
+    left join pro rmm_pro on care_month.rmm_pro_id = rmm_pro.id
 WHERE
-      client.shadow_pro_id is null AND client.is_enrolled_in_rm = 'YES'
-      AND EXTRACT(MONTH from care_month.start_date) = " . ($request->input('m') ?: 'EXTRACT(MONTH from now())') . "
+      EXTRACT(MONTH from care_month.start_date) = " . ($request->input('m') ?: 'EXTRACT(MONTH from now())') . "
       AND EXTRACT(YEAR from care_month.start_date) = " . ($request->input('y') ?: 'EXTRACT(YEAR from now())') . "
       " . (count($conditions) > 0 ? 'AND ' . implode(" AND ", $conditions) : '') . "
-ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, client.name_first, client.name_last
-"
-            )
-        );
+      $orderBy
+      LIMIT 20
+";
+
+        $patients = DB::select($query);
 
         $timestamp = strtotime(date('Y-m-d'));
         $daysRemaining = (int)date('t', $timestamp) - (int)date('j', $timestamp);

+ 141 - 0
resources/views/app/practice-management/remote-monitoring-admin-row-markup.blade.php

@@ -0,0 +1,141 @@
+<tr data-client-uid="{{$iPatient->client_uid}}" data-care-month-uid="{{$iPatient->care_month_uid}}">
+    <td class="pl-2">
+        <a href="/patients/view/{{ $iPatient->client_uid }}/care-months/view/{{$iPatient->care_month_uid}}" class="text-nowrap"
+           native target="_blank"
+           open-in-stag-popup
+           update-parent="refresh-rpm-row-{{$trIndex}}"
+           popup-style="tall overflow-visible"
+           mc-initer="care-month-dashboard-{{$iPatient->client_uid}}"
+           title="{{$iPatient->client_name}}"
+        ><span class="sort-data">{{ $iPatient->client_name }}</span></a>
+    </td>
+
+    <td>{{friendly_date($iPatient->dob)}}</td>
+    <td>{!! $iPatient->is_enrolled_in_rm === 'YES' ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>{!! $iPatient->is_assigned_cellular_bp_device ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>{!! $iPatient->is_assigned_cellular_weight_scale_device ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>
+        <div class="text-nowrap">
+            <span class="sort-data">{{$iPatient->most_recent_cellular_bp_sbp_mm_hg ?: '-'}}</span>/{{$iPatient->most_recent_cellular_bp_dbp_mm_hg ?: '-'}}
+            @if($iPatient->most_recent_cellular_bp_measurement_at)
+                <span class="text-sm text-secondary text-nowrap ml-1"
+                      title="{{friendly_date_time($iPatient->most_recent_cellular_bp_measurement_at)}}">({{friendly_date($iPatient->most_recent_cellular_bp_measurement_at)}})</span>
+            @endif
+        </div>
+    </td>
+    <td>
+        <div class="text-nowrap">
+            <span class="sort-data">{{$iPatient->most_recent_cellular_weight_value ? round($iPatient->most_recent_cellular_weight_value, 1) : '-'}}</span>
+            @if($iPatient->most_recent_cellular_weight_measurement_at)
+                <span class="text-sm text-secondary text-nowrap ml-1"
+                      title="{{friendly_date_time($iPatient->most_recent_cellular_weight_measurement_at)}}">({{friendly_date($iPatient->most_recent_cellular_weight_measurement_at)}})</span>
+            @endif
+        </div>
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            @if($iPatient->most_recent_completed_mcp_note_uid_cm)
+                <a href = "/patients/view/{{$iPatient->client_uid}}/notes/view/{{$iPatient->most_recent_completed_mcp_note_uid_cm}}">
+                    <span class="sort-data">{{$iPatient->most_recent_completed_mcp_note_date_cm ? friendly_date($iPatient->most_recent_completed_mcp_note_date_cm) : '-'}}</span>
+                </a>
+            @else
+                <span class="sort-data">-</span>
+            @endif
+        </div>
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$lastVisitWithin90Days ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+            <span class="sort-data">{{$daysDiff !== -1 ? $daysDiff : '-'}}</span>
+        </div>
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$iPatient->has_mcp_interacted_with_client_about_rm ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+            <span>{{$iPatient->has_mcp_interacted_with_client_about_rm ? 'Yes' : 'No'}}</span>
+        </div>
+        {{--@if(!$iPatient->has_mcp_interacted_with_client_about_rm)
+            <div class="text-sm font-italic text-secondary">{{$performerRole === 'MCP' ? 'Not' : "MCP hasn't"}} interacted this month!</div>
+        @endif--}}
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$iPatient->number_of_days_with_remote_measurements >= 16 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+            <span class="sort-data">{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</span>
+        </div>
+        {{--@if($iPatient->number_of_days_with_remote_measurements < 16)
+            <div class="text-sm font-italic text-secondary">Meas. days < 16</div>
+        @endif--}}
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <span class="sort-data">{{$iPatient->rm_num_measurements_not_stamped_by_mcp}}</span>
+        </div>
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_mcp >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+            <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_mcp / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_mcp % 60)}}s</span>
+            <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_mcp}}</span>
+        </div>
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_rmm_pro >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+            <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_rmm_pro / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_rmm_pro % 60)}}s</span>
+            <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_rmm_pro}}</span>
+        </div>
+    </td>
+    <td>{{$iPatient->mcp_pro_name}}</td>
+    <td>{{$iPatient->rmm_pro_name}}</td>
+    <td>
+        @if($lastVisitWithin90Days && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_mcp >= 1200)
+            <span class="text-success font-weight-bold">
+                <i class="fa fa-check"></i>
+                Yes
+            </span>
+        @else
+            <span class="text-danger font-weight-normal">
+                Not yet
+            </span>
+        @endif
+    </td>
+    <td>
+        @if($lastVisitWithin90Days && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_rmm_pro >= 1200)
+            <span class="text-success font-weight-bold">
+                <i class="fa fa-check"></i>
+                Yes
+            </span>
+        @else
+            <span class="text-danger font-weight-normal">
+                Not yet
+            </span>
+        @endif
+    </td>
+    <td>
+        @if($iPatient->number_of_days_with_remote_measurements >= 16 && $lastVisitWithin90Days)
+            <span class="text-success font-weight-bold">
+                <i class="fa fa-check"></i>
+                Yes
+            </span>
+        @else
+            <span class="text-danger font-weight-normal">
+                Not yet
+            </span>
+        @endif
+    </td>
+    <td>
+        @if($iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->has_anyone_interacted_with_client_about_rm &&
+            $lastVisitWithin90Days &&
+            ($iPatient->rm_total_time_in_seconds_by_mcp + $iPatient->rm_total_time_in_seconds_by_rmm_pro) >= 1200)
+            <span class="text-success font-weight-bold">
+                <i class="fa fa-check"></i>
+                Yes
+            </span>
+        @else
+            <span class="text-danger font-weight-normal">
+                Not yet
+            </span>
+        @endif
+    </td>
+</tr>

+ 157 - 104
resources/views/app/practice-management/remote-monitoring-admin.blade.php

@@ -1,41 +1,65 @@
 @extends ('layouts/template')
 
 @section('content')
-
-    <div class="p-3 mcp-theme-1" id="admin-remote-monitoring">
+    <style>
+        #admin-table-rm-matrix_wrapper {
+            padding-top: 10px;
+        }
+    </style>
+    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
+    <script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
+    <style>
+        #table-rm-matrix_length, #table-rm-matrix_info {
+            padding-left: 0.5rem;
+        }
+        #table-rm-matrix_filter {
+            padding-right: 0.5rem;
+        }
+        #table-rm-matrix_paginate {
+            padding: 0.5rem;
+        }
+    </style>
+    <div class="p-3 mcp-theme-1" id="practice-remote-monitoring" v-cloak>
 
         <div class="card">
 
-            <div class="card-header px-2 py-2 d-flex align-items-center">
+            <div class="card-header px-2 py-2 d-flex align-items-baseline">
                 <span class="mr-4">
                     <span class="font-size-14">Remote Monitoring</span>
                     <i class="fas fa-arrow-right text-sm mx-1"></i>
                     <b class="font-size-14">{{friendly_month(date((request()->input('y') ?: 'Y') . '-' . (request()->input('m') ?: 'm') . '-d'))}}</b>
                 </span>
-                <form class="ml-auto d-inline-flex flex-nowrap align-items-center" action="" method="GET">
+                <?php
 
+                $mStr = request()->input('m') ? request()->input('m') : date('m');
+                $yStr = request()->input('y') ? request()->input('y') : date('Y');
+                $rcmStartDate = $yStr . '-' . $mStr . '-' . '01';
+                $m = +$mStr;
+                $y = +$yStr;
+                ?>
+                <form class="ml-auto d-inline-flex flex-nowrap align-items-center" action="" method="GET">
                     <span class="mr-2">Month</span>
                     <select class="form-control form-control-sm min-width-unset width-100px mr-3" name="m"
-                            onchange="fastLoad('{{route('practice-management.remote-monitoring-admin')}}?' + $(this).closest('form').serialize())">
-                        <option value="01" {{request()->input('m') === '01' ? 'selected' : ''}}>Jan</option>
-                        <option value="02" {{request()->input('m') === '02' ? 'selected' : ''}}>Feb</option>
-                        <option value="03" {{request()->input('m') === '03' ? 'selected' : ''}}>Mar</option>
-                        <option value="04" {{request()->input('m') === '04' ? 'selected' : ''}}>Apr</option>
-                        <option value="05" {{request()->input('m') === '05' ? 'selected' : ''}}>May</option>
-                        <option value="06" {{request()->input('m') === '06' ? 'selected' : ''}}>Jun</option>
-                        <option value="07" {{request()->input('m') === '07' ? 'selected' : ''}}>Jul</option>
-                        <option value="08" {{request()->input('m') === '08' ? 'selected' : ''}}>Aug</option>
-                        <option value="09" {{request()->input('m') === '09' ? 'selected' : ''}}>Sep</option>
-                        <option value="10" {{request()->input('m') === '10' ? 'selected' : ''}}>Oct</option>
-                        <option value="11" {{request()->input('m') === '11' ? 'selected' : ''}}>Nov</option>
-                        <option value="12" {{request()->input('m') === '12' ? 'selected' : ''}}>Dec</option>
+                            onchange="fastLoad('{{route('practice-management.remote-monitoring')}}?' + $(this).closest('form').serialize())">
+                        <option value="01" {{$m === 1 ? 'selected' : ''}}>Jan</option>
+                        <option value="02" {{$m === 2 ? 'selected' : ''}}>Feb</option>
+                        <option value="03" {{$m === 3 ? 'selected' : ''}}>Mar</option>
+                        <option value="04" {{$m === 4 ? 'selected' : ''}}>Apr</option>
+                        <option value="05" {{$m === 5 ? 'selected' : ''}}>May</option>
+                        <option value="06" {{$m === 6 ? 'selected' : ''}}>Jun</option>
+                        <option value="07" {{$m === 7 ? 'selected' : ''}}>Jul</option>
+                        <option value="08" {{$m === 8 ? 'selected' : ''}}>Aug</option>
+                        <option value="09" {{$m === 9 ? 'selected' : ''}}>Sep</option>
+                        <option value="10" {{$m === 10 ? 'selected' : ''}}>Oct</option>
+                        <option value="11" {{$m === 11 ? 'selected' : ''}}>Nov</option>
+                        <option value="12" {{$m === 12 ? 'selected' : ''}}>Dec</option>
                     </select>
                     <span class="mr-2">Year</span>
                     <select class="form-control form-control-sm min-width-unset width-100px" name="y"
-                            onchange="fastLoad('{{route('practice-management.remote-monitoring-admin')}}?' + $(this).closest('form').serialize())">
-                        <option value="2020" {{request()->input('y') === '2020' ? 'selected' : ''}}>2020</option>
-                        <option value="2021" {{request()->input('y') === '2021' ? 'selected' : ''}}>2021</option>
-                        <option value="2022" {{request()->input('y') === '2022' ? 'selected' : ''}}>2022</option>
+                            onchange="fastLoad('{{route('practice-management.remote-monitoring')}}?' + $(this).closest('form').serialize())">
+                        <option value="2020" {{$y === 2020 ? 'selected' : ''}}>2020</option>
+                        <option value="2021" {{$y === 2021 ? 'selected' : ''}}>2021</option>
+                        <option value="2022" {{$y === 2022 ? 'selected' : ''}}>2022</option>
                     </select>
                 </form>
             </div>
@@ -44,94 +68,69 @@
 
             <div class="card-body p-0">
                 <div class="d-flex align-items-start m-0">
-                    <div class="p-0">
-                        @include('app.practice-management.remote-monitoring-admin-tree')
-                    </div>
-                    <div class="flex-grow-1 border-left p-0">
-                        @if($rc == 4)
-                            <?php $rc2 = request()->input('rc2') ? request()->input('rc2') : 2; ?>
-                            <div class="d-flex align-items-baseline p-2 border-bottom">
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=4&rc2=1" class="border p-2 mr-2 {{$rc2 == 1 ? 'bg-aliceblue font-weight-bold' : ''}}" >Patients not seen in over 90 days</a>
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=4&rc2=2" class="border p-2 mr-2 {{$rc2 == 2 ? 'bg-aliceblue font-weight-bold' : ''}}" >Patients seen w/in last 90 days</a>
-                            </div>
-                        @elseif($rc == 5)
-                            <?php $rc2 = request()->input('rc2') ? request()->input('rc2') : 2; ?>
-                            <div class="d-flex align-items-baseline p-2 border-bottom">
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=5&rc2=1" class="border p-2 mr-2 {{$rc2 == 1 ? 'bg-aliceblue font-weight-bold' : ''}}" >Patients not spoken to this month</a>
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=5&rc2=2" class="border p-2 mr-2 {{$rc2 == 2 ? 'bg-aliceblue font-weight-bold' : ''}}" >Patients spoken to this month</a>
-                            </div>
-                        @elseif($rc == 6)
-                            <?php $rc2 = request()->input('rc2') ? request()->input('rc2') : 2; ?>
-                            <div class="d-flex align-items-baseline p-2 border-bottom">
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=6&rc2=1" class="border p-2 mr-2 {{$rc2 == 1 ? 'bg-aliceblue font-weight-bold' : ''}}" >Unstamped Measurements > 0</a>
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=6&rc2=2" class="border p-2 mr-2 {{$rc2 == 2 ? 'bg-aliceblue font-weight-bold' : ''}}" >All Measurements Stamped</a>
-                            </div>
-                        @elseif($rc == 7)
-                            <?php $rc2 = request()->input('rc2') ? request()->input('rc2') : 2; ?>
-                            <div class="d-flex align-items-baseline p-2 border-bottom">
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=7&rc2=1" class="border p-2 mr-2 {{$rc2 == 1 ? 'bg-aliceblue font-weight-bold' : ''}}" >Measurement Days < 16</a>
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=7&rc2=2" class="border p-2 mr-2 {{$rc2 == 2 ? 'bg-aliceblue font-weight-bold' : ''}}" >Measurement Days >= 16</a>
-                            </div>
-                        @elseif($rc == 10)
-                            <?php $rc2 = request()->input('rc2') ? request()->input('rc2') : 2; ?>
-                            <div class="d-flex align-items-baseline p-2 border-bottom">
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=10&rc2=1" class="border p-2 mr-2 {{$rc2 == 1 ? 'bg-aliceblue font-weight-bold' : ''}}" >Billing Minutes < 20</a>
-                                <a href="{{route('practice-management.remote-monitoring-admin')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=10&rc2=2" class="border p-2 mr-2 {{$rc2 == 2 ? 'bg-aliceblue font-weight-bold' : ''}}" >Billing Minutes >= 20</a>
-                            </div>
-                        @endif
-                        <table class="table table-sm table-striped table-hover p-0 m-0 foo-bar-t" id="admin-table-rm-matrix">
+                    <div class="flex-grow-1 px-0 pt-2">
+                        <?php $trIndex = 0; ?>
+                        @foreach ($patients as $iPatient)
+                            <script>
+                                addMCHook(
+                                    'refresh-rpm-row-{{$trIndex}}',
+                                    function () {
+                                        refreshRpmRow({{$trIndex}});
+                                    }
+                                );
+                            </script>
+                            <?php $trIndex++; ?>
+                        @endforeach
+                        <table class="table table-sm table-striped table-hover p-0 m-0 border-top" id="table-rm-matrix">
                             <thead class="bg-light">
-                            <tr>
-                                <th class="border-0">Patient</th>
-                                <th class="border-0">MCP</th>
+                            <tr stag-title="Click to sort. Shift+Click to multi-sort.">
+                                <th class="border-0 pl-2">Name</th>
                                 <th class="border-0">DOB</th>
-                                <th class="border-0">Enrolled in RPM?</th>
-                                <th class="border-0">Cellular BP?</th>
-                                <th class="border-0">Cellular Scale?</th>
-                                <th class="border-0">Latest BP</th>
-                                <th class="border-0">Latest Weight</th>
-                                <th class="border-0">Latest Visit</th>
-                                <th class="border-0">RPM Interaction This Month?</th>
-                                <th class="border-0">Measurements Pending Stamp</th>
-                                <th class="border-0"># Meas. Days This Month</th>
-                                <th class="border-0"># RPM Minutes</th>
-
+                                <th class="border-0">RPM?</th>
+                                <th class="border-0">Cell. BP?</th>
+                                <th class="border-0">Cell. Scale?</th>
+                                <th class="border-0">Last BP</th>
+                                <th class="border-0">Last Wt</th>
+                                <th class="border-0">Last Visit</th>
+                                <th class="border-0">Days Since<br>Last Visit</th>
+                                <th class="border-0">Interacted?</th>
+                                <th class="border-0">#Meas. Days</th>
+                                <th class="border-0">#Unstamped</th>
+                                <th class="border-0">MCP Mins.</th>
+                                <th class="border-0">RMM Mins.</th>
+                                <th class="border-0">MCP</th>
+                                <th class="border-0">RMM</th>
+                                <th class="border-0">MCP Billable</th>
+                                <th class="border-0">RMM Billable</th>
+                                <th class="border-0">454</th>
+                                <th class="border-0">457</th>
                             </tr>
                             </thead>
                             <tbody>
+                            <?php $trIndex = 0; ?>
                             @foreach ($patients as $iPatient)
-                                <?php $oPatient = \App\Models\Client::where('uid', $iPatient->client_uid)->first(); ?>
-                                <tr>
-                                    <td class="">
-                                        <a href="/patients/view/{{ $iPatient->client_uid }}" class="text-nowrap">{{ $oPatient->displayName() }}</a>
-                                    </td>
-                                    <td class="">
-                                        {{$oPatient->mcp ? $oPatient->mcp->displayName() : '-'}}
-                                    </td>
+                                <?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;
+                                }
+                                $lastVisitWithin90Days = ($daysDiff !== -1 && $daysDiff <= 90);
 
-                                    <td>{{friendly_date($iPatient->dob)}}</td>
-                                    <td>{{ucwords(strtolower($iPatient->is_enrolled_in_rm ?: ''))}}</td>
-                                    <td>{{$oPatient->hasBPDevice() ? 'Yes' : 'No'}}</td>
-                                    <td>{{$oPatient->hasBPDevice() ? 'Yes' : 'No'}}</td>
-                                    <td>
-                                        {{$iPatient->most_recent_cellular_bp_sbp_mm_hg ?: '-'}}/{{$iPatient->most_recent_cellular_bp_dbp_mm_hg ?: '-'}}
-                                        @if($iPatient->most_recent_cellular_bp_measurement_at)
-                                            <div class="text-sm text-secondary text-nowrap">{{friendly_date_time($iPatient->most_recent_cellular_bp_measurement_at)}}</div>
-                                        @endif
-                                    </td>
-                                    <td>
-                                        {{$iPatient->most_recent_cellular_weight_value ? round($iPatient->most_recent_cellular_weight_value, 1) : '-'}}
-                                        @if($iPatient->most_recent_cellular_weight_measurement_at)
-                                            <div class="text-sm text-secondary text-nowrap">{{friendly_date_time($iPatient->most_recent_cellular_weight_measurement_at)}}</div>
-                                        @endif
-                                    </td>
-                                    <td>{{$iPatient->most_recent_completed_mcp_note_date ? friendly_date($iPatient->most_recent_completed_mcp_note_date) : '-'}}</td>
-                                    <td>{{$iPatient->has_anyone_interacted_with_client_about_rm_outside_note ? 'Yes' : 'No'}}</td>
-                                    <td>{{$iPatient->rm_num_measurements_not_stamped_by_mcp}}</td>
-                                    <td>{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</td>
-                                    <td>{{floor($iPatient->rm_total_time_in_seconds_by_mcp / 60)}}</td>
+                                $performerRole = false;
+                                if ($pro->pro_type === 'ADMIN') {
+                                    $performerRole = 'ADMIN';
+                                } else if ($iPatient->care_month_mcp_pro_id === $pro->id) {
+                                    $performerRole = 'MCP';
+                                } else if ($iPatient->care_month_rmm_pro_id === $pro->id) {
+                                    $performerRole = 'RMM';
+                                }
 
-                                </tr>
+                                ?>
+                                @include('app.practice-management.remote-monitoring-admin-row-markup')
+                                <?php $trIndex++; ?>
                             @endforeach
                             </tbody>
                         </table>
@@ -142,12 +141,66 @@
     </div>
     <script>
         (function() {
+            let dataTableInst = null;
+            window.refreshRpmRow = function(_index) {
+                let tr = $('#table-rm-matrix tbody tr:eq(' + _index + ')');
+                if(!tr.length) return;
+                let clientUid = tr.attr('data-client-uid'), careMonthUid = tr.attr('data-care-month-uid');
+                $.get('/rpm-matrix-row?m={{$mStr}}&y={{$yStr}}&clientUid=' + clientUid + '&careMonthUid=' + careMonthUid + '&trIndex=' + _index, _data => {
+                    let row = $(_data);
+                    row.find('>td').each(function(_columnIndex) {
+                        dataTableInst.cell(_index, _columnIndex).data(this.innerHTML); //.draw();
+                    });
+                    $('#practice-remote-monitoring [moe][initialized]').removeAttr('initialized');
+                    initMoes();
+                    tr.addClass('post-refresh-highlight');
+                    setTimeout(function() {
+                        tr.removeClass('post-refresh-highlight');
+                    }, 1000);
+                });
+            }
             function init() {
-                $('#admin-table-rm-matrix').DataTable({
-                    "pageLength": 100
+                dataTableInst = $('#table-rm-matrix').DataTable({
+                    paging: false,
+                    columnDefs: [
+                        {
+                            targets: 0,
+                            type: 'string',
+                            render: function (data, type, row, meta) {
+                                if(type === 'sort') {
+                                    return $(data).find('.sort-data').first().text();
+                                }
+                                return data;
+                            },
+                        },
+                        {targets: 1, type: 'date'},
+                        {
+                            targets: 7,
+                            type: 'date',
+                            render: function (data, type, row, meta) {
+                                if(type === 'sort') {
+                                    return $(data).find('.sort-data').first().text();
+                                }
+                                return data;
+                            },
+                        },
+                        {
+                            targets: [5, 6, 8, 10, 11, 12],
+                            type: 'num',
+                            render: function (data, type, row, meta) {
+                                if(type === 'sort') {
+                                    return +($(data).find('.sort-data').first().text());
+                                }
+                                return data;
+                            },
+                        },
+                    ]
                 });
+                $('#practice-remote-monitoring').removeAttr('v-cloak');
+                $('#practice-remote-monitoring [moe][initialized]').removeAttr('initialized');
+                initMoes();
             }
-            addMCInitializer('admin-remote-monitoring', init, '#admin-remote-monitoring');
+            addMCInitializer('practice-remote-monitoring', init, '#practice-remote-monitoring');
         }).call(window);
     </script>
 @endsection