Procházet zdrojové kódy

New mcp dashboard stats (wip)

Vijayakrishnan před 3 roky
rodič
revize
2d545bbac5
1 změnil soubory, kde provedl 36 přidání a 21 odebrání
  1. 36 21
      app/Models/Pro.php

+ 36 - 21
app/Models/Pro.php

@@ -378,10 +378,10 @@ WHERE
     }
 
     function get_notes_pending_billing_count_as_mcp() {
-        return;
         return Note::where('hcp_pro_id', $this->id)
-            ->where('is_signed_by_hcp', false)
-            ->where('is_cancelled', false)
+            ->where('is_cancelled', '<>', true)
+            ->where('is_signed_by_hcp', true)
+            ->where('is_billing_marked_done', '<>', true)
             ->count();
     }
 
@@ -406,52 +406,67 @@ WHERE
     }
 
     function get_incoming_reports_pending_signature_count_as_mcp() {
-        return;
-        $incomingReports = IncomingReport::where('hcp_pro_id', $performerProID)
-            ->where('has_hcp_pro_signed', false)
-            ->where('is_entry_error', false)
-            ->orderBy('created_at', 'ASC')
-            ->get();
+        return IncomingReport::where('hcp_pro_id', $this->id)
+            ->where('has_hcp_pro_signed', '<>', true)
+            ->where('is_entry_error', '<>', true)
+            ->count();
     }
 
     function get_patients_without_appointment_count_as_mcp() {
+        // SELECT * FROM client WHERE mcp_pro_id = :me.id AND client.next_mcp_appointment_date < today();
+        // TODO: once client.next_mcp_appointment_date is in place
+        return '**';
     }
 
     function get_patients_overdue_count_as_mcp() {
+        // SELECT * FROM client WHERE mcp_pro_id = :me.id AND client.next_expected_mcp_visit_date < today();
+        // TODO: once client.next_expected_mcp_visit_date is in place
+        return '**';
     }
 
     function get_patients_without_remote_measurement_in_48_hours_count_as_mcp() {
     }
 
     function get_cancelled_appointments_pending_acknowledgement_count_as_mcp() {
+        // SELECT * FROM appointment WHERE hcp_pro_id = :me.id AND status = 'REJECTED' AND wasAcknowledgedByAppointmentPro IS NOT TRUE;
+        /*return Appointment::where('pro_id', $this->id)
+            ->where('status', 'REJECTED')
+            ->where('was_acknowledged_by_appointment_pro', '<>', true)
+            ->count();*/
+        // TODO: once appointment.was_acknowledged_by_appointment_pro is in place
+        return '**';
     }
 
     function get_cancelled_bills_awaiting_review_count_as_mcp() {
-        return;
-        Bill::where('hcp_pro_id', $performerProID)
+        // SELECT * FROM bill WHERE bill_service_type = 'NOTE' AND is_cancelled IS TRUE AND isCancellationAcknowledged IS FALSE;
+        return Bill::where('hcp_pro_id', $this->id)
+            ->where('bill_service_type', 'NOTE')
             ->where('is_cancelled', true)
-            ->where('is_cancellation_acknowledged', false)
+            ->where('is_cancellation_acknowledged', '<>', true)
             ->count();
     }
 
     function get_cancelled_supply_orders_awaiting_review_count_as_mcp() {
-        return;
-        $keyNumbers['unacknowledgedCancelledSupplyOrders'] = SupplyOrder::where('signed_by_pro_id', $performerProID)
+        // SELECT * FROM supply_order WHERE signed_by_pro_id = :me.id AND is_cancelled IS TRUE AND isCancellationAcknowledged IS NOT TRUE;
+        return SupplyOrder::where('signed_by_pro_id', $this->id)
             ->where('is_cancelled', true)
-            ->where('is_cancellation_acknowledged', false)
+            ->where('is_cancellation_acknowledged', '<>', true)
             ->count();
-
     }
 
     function get_erx_and_orders_awaiting_signature_count_as_mcp() {
+        // SELECT * FROM erx WHERE hcp_pro_id = :me.id AND pro_declared_status <> 'CANCELLED' AND hasHcpProSigned IS NOT TRUE;
+        return Erx::where('hcp_pro_id', $this->id)
+            ->where('pro_declared_status', '<>', 'CANCELLED')
+            ->where('has_hcp_pro_signed', '<>', true)
+            ->count();
     }
 
     function get_supply_orders_awaiting_signature_count_as_mcp() {
-        return;
-        $keyNumbers['unsignedSupplyOrders'] = SupplyOrder
-            ::where('is_cancelled', false)
-            ->where('is_signed_by_pro', false)
-            ->whereRaw('created_by_session_id IN (SELECT id FROM app_session WHERE pro_id = ?)', [$performerProID])
+        // SELECT supply_order.id FROM supply_order WHERE signed_by_pro_id IS NOT TRUE AND is_cancelled IS NOT TRUE AND created_by_pro_id = :me.id;
+        return SupplyOrder::where('created_by_pro_id', $this->id)
+            ->whereNull('signed_by_pro_id')
+            ->where('is_cancelled', '<>', true)
             ->count();
     }