Jelajahi Sumber

RPM push - MCP/RMM dashboard stat + link to view

Vijayakrishnan 3 tahun lalu
induk
melakukan
6f2e71cef2
2 mengubah file dengan 80 tambahan dan 0 penghapusan
  1. 60 0
      app/Models/Pro.php
  2. 20 0
      resources/views/app/dashboard-mcp.blade.php

+ 60 - 0
app/Models/Pro.php

@@ -633,6 +633,66 @@ WHERE mcp_pro_id = :pro_id
             ->count();
     }
 
+    function get_unsigned_rpm_bills_count_as_mcp() {
+
+        $query = "
+SELECT count(distinct(care_month.id))
+FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
+    left join bill on care_month.mcp_rm_generic_bill_id = bill.id
+    left join note mrmnote on mrmnote.id = (
+        select max(n.id) from note n 
+        where 
+              n.client_id = client.id AND 
+              n.is_cancelled = FALSE AND
+              (n.is_signed_by_hcp IS NOT NULL AND n.is_signed_by_hcp = TRUE) AND
+              n.effective_dateest::date >= care_month.start_date::date AND 
+              n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
+     )
+WHERE
+      care_month.mcp_pro_id = {$this->id}
+      AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
+      AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
+      AND care_month.mcp_rm_generic_bill_id IS NOT NULL
+      AND bill.is_signed_by_generic_pro = TRUE
+";
+
+        // dd($query);
+
+        $count = DB::select($query);
+
+        return $count[0]->count;
+    }
+
+    function get_unsigned_rpm_bills_count_as_rmm() {
+
+        $query = "
+SELECT count(distinct(care_month.id))
+FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
+    left join bill on care_month.rmm_rm_generic_bill_id = bill.id
+    left join note mrmnote on mrmnote.id = (
+        select max(n.id) from note n 
+        where 
+              n.client_id = client.id AND 
+              n.is_cancelled = FALSE AND
+              (n.is_signed_by_hcp IS NOT NULL AND n.is_signed_by_hcp = TRUE) AND
+              n.effective_dateest::date >= care_month.start_date::date AND 
+              n.effective_dateest::date < (care_month.start_date::date + INTERVAL '1 month')
+     )
+WHERE
+      care_month.rmm_pro_id = {$this->id}
+      AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
+      AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
+      AND care_month.rmm_rm_generic_bill_id IS NOT NULL
+      AND bill.is_signed_by_generic_pro = TRUE
+";
+
+        // dd($query);
+
+        $count = DB::select($query);
+
+        return $count[0]->count;
+    }
+
     function get_birthdays_today_as_mcp(){
         return;
         $queryClients = $this->performer()->pro->getAccessibleClientsQuery();

+ 20 - 0
resources/views/app/dashboard-mcp.blade.php

@@ -235,6 +235,26 @@
                                         </a>
                                     </th>
                                 </tr>
+                                @if($pro->is_enrolled_as_mcp)
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_unsigned_rpm_bills_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('practice-management.rpm-matrix-mcp') }}?f_billable=yes">
+                                            Unsigned RPM Bills (MCP)
+                                        </a>
+                                    </th>
+                                </tr>
+                                @endif
+                                @if($pro->is_considered_for_rmm)
+                                    <tr>
+                                        <th class="px-2 text-center">{{$pro->get_unsigned_rpm_bills_count_as_rmm()}}</th>
+                                        <th class="pl-2">
+                                            <a href="{{ route('practice-management.rpm-matrix-rmm') }}?f_billable=yes">
+                                                Unsigned RPM Bills (RMM)
+                                            </a>
+                                        </th>
+                                    </tr>
+                                @endif
                                 </tbody>
                             </table>
                         </div>