Browse Source

Patient > care months list: perf. optimization

Vijayakrishnan Krishnan 2 days ago
parent
commit
0be91e8ae9

+ 38 - 2
app/Http/Controllers/PatientController.php

@@ -420,8 +420,44 @@ class PatientController extends Controller
 
     public function careMonths(Request $request, Client $patient )
     {
-        $careMonths = CareMonth::where('client_id', $patient->id)->orderBy('start_date', 'desc')->get();
-        $notes = Note::where('is_cancelled', false)->get();
+        if($request->input('ql')) DB::enableQueryLog();
+
+        $careMonths = CareMonth
+            ::select(
+                'id',
+                'uid',
+                'start_date',
+                'uid',
+                'was_rm_setup_performed',
+                'number_of_days_with_remote_measurements',
+                'rm_total_time_in_seconds',
+                'rm_total_time_in_seconds_by_mcp',
+                'rm_total_time_in_seconds_by_rme_pro',
+                'rm_total_time_in_seconds_by_rmm_pro',
+                'mcp_pro_id',
+                'rm_bill_id',
+                'cm_pro_id',
+                'rmm_pro_id',
+                'rme_pro_id',
+                'number_of_days_with_remote_measurements',
+                'rm_total_time_in_seconds_by_mcp',
+                'has_mcp_interacted_with_client_about_rm'
+            )
+            ->where('client_id', $patient->id)
+            ->orderBy('start_date', 'desc')->get();
+
+        $notes = [];
+
+        if($patient->has_mcp_done_onboarding_visit !== 'YES') {
+            $notes = Note
+                ::select('uid', 'title', 'effective_dateest', 'hcp_pro_id')
+                ->where('client_id', $patient->id)
+                ->where('is_cancelled', false)
+                ->get();
+        }
+
+        if($request->input('ql')) dd(DB::getQueryLog());
+
         return view('app.patient.care-months', compact('patient', 'careMonths', 'notes'));
     }
 

+ 2 - 2
resources/views/app/patient/care-months.blade.php

@@ -135,10 +135,10 @@
                             if($careMonth->mcp && $pro->id === $careMonth->mcp->id) {
                                 $minsBilled = $careMonth->rm_total_time_in_seconds_by_mcp;
                             }
-                            elseif($careMonth->rmm && $pro->id === $careMonth->rmm->id) {
+                            elseif($careMonth->rmmPro && $pro->id === $careMonth->rmmPro->id) {
                                 $minsBilled = $careMonth->rm_total_time_in_seconds_by_rmm_pro;
                             }
-                            elseif($careMonth->rme && $pro->id === $careMonth->rme->id) {
+                            elseif($careMonth->rmePro && $pro->id === $careMonth->rmePro->id) {
                                 $minsBilled = $careMonth->rm_total_time_in_seconds_by_rme_pro;
                             }elseif($pro->pro_type == 'ADMIN') {
                                 $minsBilled = $careMonth->rm_total_time_in_seconds;