Răsfoiți Sursa

RPM UI (wip)

Vijayakrishnan 3 ani în urmă
părinte
comite
024e780a5f

+ 32 - 59
app/Http/Controllers/PracticeManagementController.php

@@ -981,50 +981,9 @@ class PracticeManagementController extends Controller
         $careMonthStart = date($ym . '-01');
 
         $rc = $request->input('rc') ?: 1;
-        $rc2 = $request->input('rc2') ?: 1;
-        $conditions = [];
+        $rc2 = $request->input('rc2') ?: 2;
 
-        $c_isMCP = "client.mcp_pro_id = {$performer->pro->id}";
-        $c_enrolledInRPM = "client.is_enrolled_in_rm = 'YES'";
-        $c_hasDevice = "(SELECT COUNT(client_bdt_device.id) FROM client_bdt_device JOIN bdt_device bd on client_bdt_device.device_id = bd.id WHERE client_bdt_device.client_id = client.id) > 0";
-        $c_lastVisitWithin90Days = "DATE_PART('day', client.most_recent_completed_mcp_note_date::timestamp - care_month.start_date::timestamp) <= 90";
-        $c_spokenToThisMonth = "care_month.has_anyone_interacted_with_client_about_rm_outside_note = TRUE";
-        $c_hasUnstamped = "care_month.rm_num_measurements_not_stamped_by_mcp > 0";
-        $c_hasNoUnstamped = "care_month.rm_num_measurements_not_stamped_by_mcp = 0";
-        $c_lt16MeasurementDays = "care_month.number_of_days_with_remote_measurements < 16";
-        $c_gte16MeasurementDays = "care_month.number_of_days_with_remote_measurements >= 16";
-        $c_subscribedToSMS = "client.send_sms_on_bdt_measurement = TRUE";
-        $c_deviceUsed = "(client.most_recent_cellular_bp_measurement_at IS NOT NULL OR most_recent_cellular_weight_measurement_at IS NOT NULL)";
-
-        switch ($rc) {
-            case 1:
-                $conditions = [$c_isMCP];
-                break;
-            case 2:
-                $conditions = [$c_isMCP, $c_enrolledInRPM];
-                break;
-            case 3:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice];
-                break;
-            case 4:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days];
-                break;
-            case 5:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth];
-                break;
-            case 6:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth, ($rc2 == 1 ? $c_hasUnstamped : $c_hasNoUnstamped)];
-                break;
-            case 7:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth, ($rc2 == 1 ? $c_lt16MeasurementDays : $c_gte16MeasurementDays)];
-                break;
-            case 8:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_subscribedToSMS];
-                break;
-            case 9:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_deviceUsed];
-                break;
-        }
+        $conditions = $this->rpmConditions($performer, $rc, $rc2);
 
         $patients = DB::select(
             DB::raw(
@@ -1081,12 +1040,34 @@ ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, cli
 
         $rc = $request->input('rc') ?: 1;
         $rc2 = $request->input('rc2') ?: 1;
+
+        $conditions = $this->rpmConditions($performer, $rc, $rc2);
+
+        $count = DB::select(
+            DB::raw(
+                "
+SELECT count(client.id)
+FROM care_month join client on care_month.client_id = client.id
+WHERE
+      client.mcp_pro_id = {$performer->pro->id}
+      AND 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) : '')
+            )
+        );
+
+        return $count[0]->count;
+    }
+
+    private function rpmConditions($performer, $rc, $rc2) {
         $conditions = [];
 
         $c_isMCP = "client.mcp_pro_id = {$performer->pro->id}";
         $c_enrolledInRPM = "client.is_enrolled_in_rm = 'YES'";
         $c_hasDevice = "(SELECT COUNT(client_bdt_device.id) FROM client_bdt_device JOIN bdt_device bd on client_bdt_device.device_id = bd.id WHERE client_bdt_device.client_id = client.id) > 0";
+        $c_lastVisitBefore90Days = "DATE_PART('day', client.most_recent_completed_mcp_note_date::timestamp - care_month.start_date::timestamp) > 90";
         $c_lastVisitWithin90Days = "DATE_PART('day', client.most_recent_completed_mcp_note_date::timestamp - care_month.start_date::timestamp) <= 90";
+        $c_notSpokenToThisMonth = "(care_month.has_anyone_interacted_with_client_about_rm_outside_note IS NULL OR care_month.has_anyone_interacted_with_client_about_rm_outside_note = FALSE)";
         $c_spokenToThisMonth = "care_month.has_anyone_interacted_with_client_about_rm_outside_note = TRUE";
         $c_hasUnstamped = "care_month.rm_num_measurements_not_stamped_by_mcp > 0";
         $c_hasNoUnstamped = "care_month.rm_num_measurements_not_stamped_by_mcp = 0";
@@ -1094,6 +1075,8 @@ ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, cli
         $c_gte16MeasurementDays = "care_month.number_of_days_with_remote_measurements >= 16";
         $c_subscribedToSMS = "client.send_sms_on_bdt_measurement = TRUE";
         $c_deviceUsed = "(client.most_recent_cellular_bp_measurement_at IS NOT NULL OR most_recent_cellular_weight_measurement_at IS NOT NULL)";
+        $c_lt20BillingMinutes = "care_month.rm_total_time_in_seconds_by_mcp < 1200";
+        $c_gte20BillingMinutes = "care_month.rm_total_time_in_seconds_by_mcp >= 1200";
 
         switch ($rc) {
             case 1:
@@ -1106,10 +1089,10 @@ ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, cli
                 $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice];
                 break;
             case 4:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days];
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, ($rc2 == 1 ? $c_lastVisitBefore90Days : $c_lastVisitWithin90Days)];
                 break;
             case 5:
-                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth];
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, ($rc2 == 1 ? $c_notSpokenToThisMonth : $c_spokenToThisMonth)];
                 break;
             case 6:
                 $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth, ($rc2 == 1 ? $c_hasUnstamped : $c_hasNoUnstamped)];
@@ -1117,6 +1100,9 @@ ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, cli
             case 7:
                 $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth, ($rc2 == 1 ? $c_lt16MeasurementDays : $c_gte16MeasurementDays)];
                 break;
+            case 10:
+                $conditions = [$c_isMCP, $c_enrolledInRPM, $c_hasDevice, $c_lastVisitWithin90Days, $c_spokenToThisMonth, $c_gte16MeasurementDays, ($rc2 == 1 ? $c_lt20BillingMinutes : $c_gte20BillingMinutes)];
+                break;
             case 8:
                 $conditions = [$c_isMCP, $c_enrolledInRPM, $c_subscribedToSMS];
                 break;
@@ -1125,20 +1111,7 @@ ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, cli
                 break;
         }
 
-        $count = DB::select(
-            DB::raw(
-                "
-SELECT count(client.id)
-FROM care_month join client on care_month.client_id = client.id
-WHERE
-      client.mcp_pro_id = {$performer->pro->id}
-      AND 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) : '')
-            )
-        );
-
-        return $count[0]->count;
+        return $conditions;
     }
 
     public function remoteMonitoringMeasurements(Request $request, CareMonth $careMonth) {

+ 12 - 4
resources/views/app/practice-management/remote-monitoring-tree.blade.php

@@ -36,15 +36,23 @@ if(!@$rc) {
                                         <div class="condition-children">
                                             <div class="condition">
                                                 <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=6"
-                                                        {!! $rc == 6 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with unstamped meas.?
-                                                    <span class="rm-count ml-1" data-rc="6" data-rc-2="1">(0)</span>
+                                                        {!! $rc == 6 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with no unstamped meas.?
+                                                    <span class="rm-count ml-1" data-rc="6">(0)</span>
                                                 </a>
                                             </div>
                                             <div class="condition">
                                                 <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=7"
-                                                        {!! $rc == 7 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many yet to hit 16 days?
-                                                    <span class="rm-count ml-1" data-rc="7" data-rc2="1">(0)</span>
+                                                        {!! $rc == 7 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with 16 or more meas. days?
+                                                    <span class="rm-count ml-1" data-rc="7">(0)</span>
                                                 </a>
+                                                <div class="condition-children">
+                                                    <div class="condition">
+                                                        <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=10"
+                                                                {!! $rc == 10 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with 20 or more billing mins.?
+                                                            <span class="rm-count ml-1" data-rc="10">(0)</span>
+                                                        </a>
+                                                    </div>
+                                                </div>
                                             </div>
                                         </div>
                                     </div>

+ 21 - 3
resources/views/app/practice-management/remote-monitoring.blade.php

@@ -47,18 +47,36 @@
                         @include('app.practice-management.remote-monitoring-tree')
                     </div>
                     <div class="col-8 border-left p-0">
-                        @if($rc == 6)
-                            <?php $rc2 = request()->input('rc2') ? request()->input('rc2') : 1; ?>
+                        @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')}}?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 I have not seen in over 90 days</a>
+                                <a href="{{route('practice-management.remote-monitoring')}}?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 I have 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')}}?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 I have not spoken to this month</a>
+                                <a href="{{route('practice-management.remote-monitoring')}}?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 I have 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')}}?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')}}?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') : 1; ?>
+                            <?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')}}?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')}}?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')}}?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')}}?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">
                             <thead class="bg-light">