Эх сурвалжийг харах

Admin dashboard counts fix

Vijayakrishnan 3 жил өмнө
parent
commit
1cf881700b

+ 43 - 0
app/Models/Pro.php

@@ -371,6 +371,15 @@ class Pro extends Model
         return $favorites;
         return $favorites;
     }
     }
 
 
+    function get_patients_count_as_admin() {
+        $query = Client::whereNull('shadow_pro_id');
+        return $query->where('is_active', true)
+            ->where(function ($q) {
+                $q->whereNull('client_engagement_status_category')
+                    ->orWhere('client_engagement_status_category', '<>', 'DUMMY');
+            })->count();
+    }
+
     function get_patients_count_as_mcp() {
     function get_patients_count_as_mcp() {
         $query = Client::whereNull('shadow_pro_id');
         $query = Client::whereNull('shadow_pro_id');
         return $query->where('mcp_pro_id', $this->id)
         return $query->where('mcp_pro_id', $this->id)
@@ -387,6 +396,12 @@ class Pro extends Model
             ->count();
             ->count();
     }
     }
 
 
+    function get_new_patients_awaiting_visit_count_as_admin() {
+        $query = Client::whereNull('shadow_pro_id');
+        return $query->where('has_mcp_done_onboarding_visit', '!=', 'YES')
+            ->count();
+    }
+
     function get_notes_pending_signature_count_as_mcp() {
     function get_notes_pending_signature_count_as_mcp() {
         return Note::where('hcp_pro_id', $this->id)
         return Note::where('hcp_pro_id', $this->id)
             ->where('is_cancelled', '<>', true)
             ->where('is_cancelled', '<>', true)
@@ -395,6 +410,13 @@ class Pro extends Model
             ->count();
             ->count();
     }
     }
 
 
+    function get_notes_pending_signature_count_as_admin() {
+        return Note::where('is_cancelled', '<>', true)
+            ->where('is_core_note', '<>', true)
+            ->where('is_signed_by_hcp', '<>', true)
+            ->count();
+    }
+
     function get_notes_pending_summary_suggestion_as_mcp_query(){
     function get_notes_pending_summary_suggestion_as_mcp_query(){
         $segmentsWithProposedSummarySuggestion = Segment::whereHas('proposedSegmentSummarySuggestion', function($sugQuery){
         $segmentsWithProposedSummarySuggestion = Segment::whereHas('proposedSegmentSummarySuggestion', function($sugQuery){
             return $sugQuery->where('status', '=', 'PENDING');
             return $sugQuery->where('status', '=', 'PENDING');
@@ -493,6 +515,12 @@ class Pro extends Model
             ->count();
             ->count();
     }
     }
 
 
+    function get_notes_pending_billing_count_as_admin() {
+        return Note::where('is_cancelled', '<>', true)
+            ->where('is_signed_by_hcp', true)
+            ->where('is_billing_marked_done', '<>', true)
+            ->count();
+    }
 
 
     function get_measurements_awaiting_review_count_as_mcp() {
     function get_measurements_awaiting_review_count_as_mcp() {
         $result = DB::select(DB::raw("
         $result = DB::select(DB::raw("
@@ -529,6 +557,12 @@ WHERE mcp_pro_id = :pro_id
             ->count();
             ->count();
     }
     }
 
 
+    function get_incoming_reports_pending_signature_count_as_admin() {
+        return IncomingReport::where('has_hcp_pro_signed', '<>', true)
+            ->where('is_entry_error', '<>', true)
+            ->count();
+    }
+
     function get_patients_without_appointment_query() {
     function get_patients_without_appointment_query() {
         return Client::where('mcp_pro_id', $this->id)
         return Client::where('mcp_pro_id', $this->id)
                     ->whereNull('today_mcp_appointment_date')
                     ->whereNull('today_mcp_appointment_date')
@@ -551,6 +585,15 @@ WHERE mcp_pro_id = :pro_id
         return $this->get_patients_without_appointment_query()->count();
         return $this->get_patients_without_appointment_query()->count();
     }
     }
 
 
+    function get_patients_without_appointment_count_as_admin() {
+        return Client::whereNull('shadow_pro_id')
+            ->whereNull('today_mcp_appointment_date')
+            ->where(function($q){
+                $q->whereNull('next_mcp_appointment_id')
+                    ->orWhere('next_mcp_appointment_date', '<=', DB::raw('NOW()::DATE'));
+            })->count();
+    }
+
     function get_patients_overdue_for_visit_query() {
     function get_patients_overdue_for_visit_query() {
         return Client::where('mcp_pro_id', $this->id)
         return Client::where('mcp_pro_id', $this->id)
                     ->where(function($q){
                     ->where(function($q){

+ 6 - 6
resources/views/app/dashboard-admin.blade.php

@@ -25,15 +25,15 @@
                             <table class="table mb-0 dashboard-stats-table">
                             <table class="table mb-0 dashboard-stats-table">
                                 <tbody>
                                 <tbody>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_patients_count_as_admin()}}</th>
                                     <th class="pl-2">Patients</th>
                                     <th class="pl-2">Patients</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_admin()}}</th>
                                     <th class="pl-2">New Patients Awaiting Visit</th>
                                     <th class="pl-2">New Patients Awaiting Visit</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_admin()}}</th>
                                     <th class="pl-2">Notes Pending Signature</th>
                                     <th class="pl-2">Notes Pending Signature</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
@@ -61,16 +61,16 @@
                                     </th>
                                     </th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_notes_pending_billing_count_as_admin()}}</th>
                                     <th class="pl-2">Notes Pending Billing</th>
                                     <th class="pl-2">Notes Pending Billing</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_incoming_reports_pending_signature_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_incoming_reports_pending_signature_count_as_admin()}}</th>
                                     <th class="pl-2">Reports Pending Signature</th>
                                     <th class="pl-2">Reports Pending Signature</th>
                                 </tr>
                                 </tr>
 
 
                                 <tr>
                                 <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_mcp()}}</th>
+                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_admin()}}</th>
                                     <th class="pl-2">Patients w/o Appointments</th>
                                     <th class="pl-2">Patients w/o Appointments</th>
                                 </tr>
                                 </tr>
                                 <tr>
                                 <tr>