Browse Source

added dna dashboard

Josh 3 years ago
parent
commit
1066f794ae

+ 62 - 0
app/Http/Controllers/DnaController.php

@@ -206,4 +206,66 @@ class DnaController extends Controller
         return view('app.dna.supply_orders_pending_signature', $data);
         return view('app.dna.supply_orders_pending_signature', $data);
     }
     }
 
 
+    //From the new spec 
+    public function patientsCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->patientsRecordsAsDna();
+        return view('app.dna.patients_count_as_dna', $records);
+    }
+    
+    public function patientsAwaitingMcpVisitCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->patientsAwaitingMcpVisitRecordsAsDna();
+        return view('app.dna.patients_awaiting_mcp_visit_count_as_dna', $records);
+    }
+    
+    public function patientsWithoutAppointmentCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->patientsWithoutAppointmentRecordsAsDna();
+        return view('app.dna.patients_without_appointment_count_as_dna', $records);
+    }
+    
+    public function encountersPendingMyReviewCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->encountersPendingMyReviewRecordsAsDna();
+        return view('app.dna.encounters_pending_my_review_count_as_dna', $records);
+    }
+    
+    public function encountersInProgressCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->encountersInProgressRecordsAsDna();
+        return view('app.dna.encounters_in_progress_count_as_dna', $records);
+    }
+    
+    public function appointmentsPendingConfirmationCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->appointmentsPendingConfirmationRecordsAsDna();
+        return view('app.dna.appointments_pending_confirmation_count_as_dna', $records);
+    }
+    
+    public function cancelledAppointmentsPendingAckCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->cancelledAppointmentsPendingAckRecordsAsDna();
+        return view('app.dna.cancelled_appointments_pending_ack_count_as_dna', $records);
+    }
+    
+    public function reportsPendingAckCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->reportsPendingAckRecordsAsDna();
+        return view('app.dna.reports_pending_ack_count_as_dna', $records);
+    }
+    
+    public function supplyOrdersPendingMyAckCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->supplyOrdersPendingMyAckRecordsAsDna();
+        return view('app.dna.supply_orders_pending_my_ack_count_as_dna', $records);
+    }
+    
+    public function supplyOrdersPendingHcpApprovalCountAsDna(){
+        $pro = $this->performer->pro; 
+        $records = $pro->supplyOrdersPendingHcpApprovalRecordsAsDna();
+        return view('app.dna.supply_orders_pending_hcp_approval_count_as_dna', $records);
+    }
+    
+
 }
 }

+ 151 - 0
app/Models/Pro.php

@@ -858,4 +858,155 @@ WHERE mcp_pro_id = :pro_id
         return 0;
         return 0;
     }
     }
 
 
+    //DNA_DASHBOARD
+    
+    //queries
+    private function patientsQueryAsDna(){
+        // WHERE na_pro_id = :me.id
+        return Client::where('default_na_pro_id', $this->id);
+    }
+
+    private function patientsAwaitingMcpVisitQueryAsDna(){
+        // WHERE has_mcp_done_onboarding_visit <> 'YES'
+        return Client::where('default_na_pro_id', $this->id)->where('has_mcp_done_onboarding_visit', '<>', 'YES');
+    }
+
+    private function patientsWithoutAppointmentQueryAsDna(){
+        // WHERE today_mcp_appointment_date IS NULL AND next_mcp_appointment_date IS NULL
+        return Client::where('default_na_pro_id', $this->id)
+                        ->whereNull('today_mcp_appointment_date')
+                        ->whereNull('next_mcp_appointment_date');
+    }
+    
+    private function encountersPendingMyReviewQueryAsDna(){
+        // WHERE ally_pro_id = me.id AND is_cancelled IS NOT TRUE AND is_signed_by_hcp IS TRUE AND is_signed_by_ally IS NOT TRUE;
+        return Note::where('ally_pro_id', $this->id)
+            ->where('is_cancelled', '<>', true)
+            ->where('is_signed_by_hcp', true)
+            ->where('is_signed_by_ally','<>', true);
+    }
+
+    private function encountersInProgressQueryAsDna(){
+        // SELECT * FROM note WHERE ally_pro_id = me.id AND is_cancelled IS NOT TRUE AND is_signed_by_hcp IS NOT TRUE ORDER BY effective_dateest DESC, created_at DESC;
+        return Note::where('ally_pro_id', $this->id)
+                        ->where('is_cancelled', '<>', true)
+                        ->where('is_signed_by_hcp', '<>', true);
+    }
+
+    private function appointmentsPendingConfirmationQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND status = 'PENDING'
+        $myId = $this->id;
+        return Appointment::whereHas('client', function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('status', 'PENDING');
+    }
+    
+    private function cancelledAppointmentsPendingAckQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND status = 'CANCELLED' AND is_status_acknowledgement_from_default_na_pending IS TRUE;
+        $myId = $this->id;
+        return Appointment::whereHas('client', function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('status', 'CANCELLED')
+            ->where('is_status_acknowledgement_from_default_na_pending', true);
+    }
+    
+    private function reportsPendingAckQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS FALSE AND is_entry_error
+        $myId = $this->id;
+        return IncomingReport::whereHas('client',function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('has_na_pro_signed', '<>', true)
+            ->where('is_entry_error','<>', true);
+    }
+    
+    private function supplyOrdersPendingMyAckQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS FALSE AND is_signed_by_pro IS TRUE AND is_cancelled IS NOT TRUE;
+        $myId = $this->id;
+        return SupplyOrder::whereHas('client',function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('has_na_pro_signed', '<>', true)
+            ->where('is_signed_by_pro', true)
+            ->where('is_cancelled', '<>', true);
+    }
+
+    private function supplyOrdersPendingHcpApprovalQueryAsDna(){
+        // WHERE client_id IN (SELECT id FROM client WHERE default_na_pro_id = :me.id) AND has_na_pro_signed IS TRUE AND is_signed_by_pro IS NOT TRUE AND is_cancelled IS NOT TRUE;
+        $myId = $this->id;
+        return SupplyOrder::whereHas('client',function($clientQuery) use ($myId) {
+            return $clientQuery->where('default_na_pro_id', $myId);
+        })->where('has_na_pro_signed', true)
+            ->where('is_signed_by_pro','<>', true)
+            ->where('is_cancelled', '<>', true);
+    }
+
+    //counts
+    public function patientsCountAsDna(){
+        return $this->patientsQueryAsDna()->count();
+    }
+    public function patientsAwaitingMcpVisitCountAsDna(){
+        return $this->patientsAwaitingMcpVisitQueryAsDna()->count();
+    }
+    public function patientsWithoutAppointmentCountAsDna(){
+        return $this->patientsWithoutAppointmentQueryAsDna()->count();
+    }
+    public function encountersPendingMyReviewCountAsDna(){
+        return $this->encountersPendingMyReviewQueryAsDna()->count();
+    }
+    public function encountersInProgressCountAsDna(){
+        return $this->encountersInProgressQueryAsDna()->count();
+    }
+    public function appointmentsPendingConfirmationCountAsDna(){
+        return $this->appointmentsPendingConfirmationQueryAsDna()->count();
+    }
+    public function cancelledAppointmentsPendingAckCountAsDna(){
+        return $this->cancelledAppointmentsPendingAckQueryAsDna()->count();
+    }
+    public function reportsPendingAckCountAsDna(){
+        return $this->reportsPendingAckQueryAsDna()->count();
+    }
+    public function supplyOrdersPendingMyAckCountAsDna(){
+        return $this->supplyOrdersPendingMyAckQueryAsDna()->count();
+    }
+    public function supplyOrdersPendingHcpApprovalCountAsDna(){
+        return $this->supplyOrdersPendingHcpApprovalQueryAsDna()->count();
+    }
+
+    //records
+    private $DNA_RESULTS_PAGE_SIZE = 50;
+
+    public function patientsRecordsAsDna(){
+        return $this->patientsQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function patientsAwaitingMcpVisitRecordsAsDna(){
+        return $this->patientsAwaitingMcpVisitQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function patientsWithoutAppointmentRecordsAsDna(){
+        return $this->patientsWithoutAppointmentQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function encountersPendingMyReviewRecordsAsDna(){
+        return $this->encountersPendingMyReviewQueryAsDna()
+                ->orderBy('effective_dateest', 'desc')
+                ->orderBy('created_at', 'desc')
+                ->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function encountersInProgressRecordsAsDna(){
+        return $this->encountersInProgressQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function appointmentsPendingConfirmationRecordsAsDna(){
+        return $this->appointmentsPendingConfirmationQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function cancelledAppointmentsPendingAckRecordsAsDna(){
+        return $this->cancelledAppointmentsPendingAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function reportsPendingAckRecordsAsDna(){
+        return $this->reportsPendingAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function supplyOrdersPendingMyAckRecordsAsDna(){
+        return $this->supplyOrdersPendingMyAckQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+    public function supplyOrdersPendingHcpApprovalRecordsAsDna(){
+        return $this->supplyOrdersPendingHcpApprovalQueryAsDna()->paginate($this->DNA_RESULTS_PAGE_SIZE);
+    }
+
+
 }
 }

+ 60 - 69
resources/views/app/dashboard-dna.blade.php

@@ -33,75 +33,66 @@
                         <div class="card-body p-0">
                         <div class="card-body p-0">
                             <table class="table table-sm mb-0 dashboard-stats-table">
                             <table class="table table-sm mb-0 dashboard-stats-table">
                                 <tbody>
                                 <tbody>
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.patients') }}">Patients</a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_new_patients_awaiting_visit_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.new_patients_awaiting_visit') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="New Patients Awaiting Visit">
-                                            New Patients Awaiting Visit
-                                        </a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_notes_pending_signature_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.notes_pending_signature') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="Notes Pending Signature">
-                                            Notes Pending Signature
-                                        </a>
-                                    </th>
-                                </tr>
-
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_without_appointment_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.patients_without_appointments') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="Patients w/o Appointments">
-                                            Patients w/o Appointments
-                                        </a>
-                                    </th>
-                                </tr>
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_patients_overdue_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.patients_overdue_for_visit') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="Patients Overdue for Visit">
-                                            Patients Overdue for Visit
-                                        </a>
-                                    </th>
-                                </tr>
-
-                                <tr>
-                                    <th class="px-2 text-center">{{$pro->get_cancelled_bills_awaiting_review_count_as_dna()}}</th>
-                                    <th class="pl-2">
-                                        <a href="{{ route('dna.cancelled_bills_pending_review') }}"
-                                           native target="_blank"
-                                           open-in-stag-popup
-                                           popup-style="tall"
-                                           title="Cancelled Bills Pending Review">
-                                            Cancelled Bills Pending Review
-                                        </a>
-                                    </th>
-                                </tr>
-
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->patientsCountAsDna()}}<th>  
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.patients_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Patients ">Patients </a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->patientsAwaitingMcpVisitCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.patients_awaiting_mcp_visit_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Patients Awaiting MCP Visit">Patients Awaiting MCP Visit</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->patientsWithoutAppointmentCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.patients_without_appointment_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Patients w/o Appointment ">Patients w/o Appointment </a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->encountersPendingMyReviewCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.encounters_pending_my_review_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Encounters Pending My Review ">Encounters Pending My Review </a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->encountersInProgressCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.encounters_in_progress_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Encounters In Progress">Encounters In Progress</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->appointmentsPendingConfirmationCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.appointments_pending_confirmation_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Appointments Pending Confirmation">Appointments Pending Confirmation</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->cancelledAppointmentsPendingAckCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.cancelled_appointments_pending_ack_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Cancelled Appointments Pending Ack.">Cancelled Appointments Pending Ack.</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->reportsPendingAckCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.reports_pending_ack_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Reports Pending Ack.">Reports Pending Ack.</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->supplyOrdersPendingMyAckCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.supply_orders_pending_my_ack_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Supply Orders Pending My Ack.">Supply Orders Pending My Ack.</a>
+                                        </th>
+                                    </tr>
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->supplyOrdersPendingHcpApprovalCountAsDna()}}<th>
+                                        <th class="pl-2">
+                                            <a href="{{route('dna.supply_orders_pending_hcp_approval_count_as_dna')}}" native target="_blank" open-in-stag-popup popup-style="tall" title="Supply Orders Pending HCP Approval">Supply Orders Pending HCP Approval</a>
+                                        </th>
+                                    </tr>
                                 </tbody>
                                 </tbody>
                             </table>
                             </table>
                         </div>
                         </div>

+ 0 - 0
resources/views/app/dna/appointments_pending_confirmation_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/cancelled_appointments_pending_ack_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/encounters_in_progress_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/encounters_pending_my_review_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/patients_awaiting_mcp_visit_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/patients_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/patients_without_appointment_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/reports_pending_ack_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/supply_orders_pending_hcp_approval_count_as_dna.blade.php


+ 0 - 0
resources/views/app/dna/supply_orders_pending_my_ack_count_as_dna.blade.php


+ 12 - 0
routes/web.php

@@ -126,6 +126,18 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('erx_and_orders_pending_signature', 'DnaController@erx_and_orders_pending_signature')->name('erx_and_orders_pending_signature');
         Route::get('erx_and_orders_pending_signature', 'DnaController@erx_and_orders_pending_signature')->name('erx_and_orders_pending_signature');
         Route::get('supply_orders_pending_signature', 'DnaController@supply_orders_pending_signature')->name('supply_orders_pending_signature');
         Route::get('supply_orders_pending_signature', 'DnaController@supply_orders_pending_signature')->name('supply_orders_pending_signature');
 
 
+        //from the new spec
+        Route::get('patients_count_as_dna', 'DnaController@patientsCountAsDna')->name('patients_count_as_dna');
+        Route::get('patients_awaiting_mcp_visit_count_as_dna', 'DnaController@patientsAwaitingMcpVisitCountAsDna')->name('patients_awaiting_mcp_visit_count_as_dna');
+        Route::get('patients_without_appointment_count_as_dna', 'DnaController@patientsWithoutAppointmentCountAsDna')->name('patients_without_appointment_count_as_dna');
+        Route::get('encounters_pending_my_review_count_as_dna', 'DnaController@encountersPendingMyReviewCountAsDna')->name('encounters_pending_my_review_count_as_dna');
+        Route::get('encounters_in_progress_count_as_dna', 'DnaController@encountersInProgressCountAsDna')->name('encounters_in_progress_count_as_dna');
+        Route::get('appointments_pending_confirmation_count_as_dna', 'DnaController@appointmentsPendingConfirmationCountAsDna')->name('appointments_pending_confirmation_count_as_dna');
+        Route::get('cancelled_appointments_pending_ack_count_as_dna', 'DnaController@cancelledAppointmentsPendingAckCountAsDna')->name('cancelled_appointments_pending_ack_count_as_dna');
+        Route::get('reports_pending_ack_count_as_dna', 'DnaController@reportsPendingAckCountAsDna')->name('reports_pending_ack_count_as_dna');
+        Route::get('supply_orders_pending_my_ack_count_as_dna', 'DnaController@supplyOrdersPendingMyAckCountAsDna')->name('supply_orders_pending_my_ack_count_as_dna');
+        Route::get('supply_orders_pending_hcp_approval_count_as_dna', 'DnaController@supplyOrdersPendingHcpApprovalCountAsDna')->name('supply_orders_pending_hcp_approval_count_as_dna');
+
     });
     });
 
 
     Route::name('admin.')->prefix('a')->group(function () {
     Route::name('admin.')->prefix('a')->group(function () {