Browse Source

Dashboard appointments

Samson Mutunga 1 year ago
parent
commit
571baeab80

+ 42 - 1
app/Models/Pro.php

@@ -1398,6 +1398,16 @@ WHERE
         return $totalExpectedAmount;
         return $totalExpectedAmount;
     }
     }
 
 
+    public function getProcessingAmountAsRd(){
+        $expectedForCm = DB::select(DB::raw("SELECT coalesce(SUM(cm_expected_payment_amount),0) as expected_pay  FROM bill WHERE cm_pro_id = :performerProID  AND has_cm_been_paid = false AND is_signed_by_cm IS TRUE AND is_cancelled = false"), ['performerProID' => $this->id])[0]->expected_pay;
+        $expectedForRme = DB::select(DB::raw("SELECT coalesce(SUM(rme_expected_payment_amount),0) as expected_pay  FROM bill WHERE rme_pro_id = :performerProID  AND has_rme_been_paid = false AND is_signed_by_rme IS TRUE AND is_cancelled = false"), ['performerProID' => $this->id])[0]->expected_pay;
+        $expectedForRmm = DB::select(DB::raw("SELECT coalesce(SUM(rmm_expected_payment_amount),0) as expected_pay  FROM bill WHERE rmm_pro_id = :performerProID  AND has_rmm_been_paid = false AND is_signed_by_rmm IS TRUE AND is_cancelled = false"), ['performerProID' => $this->id])[0]->expected_pay;
+        $expectedForNa = DB::select(DB::raw("SELECT coalesce(SUM(generic_pro_expected_payment_amount),0) as expected_pay  FROM bill WHERE generic_pro_id = :performerProID  AND has_generic_pro_been_paid = false AND is_signed_by_generic_pro IS TRUE AND is_cancelled = false"), ['performerProID' => $this->id])[0]->expected_pay;
+        $totalExpectedAmount =  $expectedForCm + $expectedForRme + $expectedForRmm + $expectedForNa;
+
+        return $totalExpectedAmount;
+    }
+
     public function getNextPaymentDateAsDna(){
     public function getNextPaymentDateAsDna(){
         $nextPaymentDate = '--';
         $nextPaymentDate = '--';
         //if today is < 15th, next payment is 15th, else nextPayment is
         //if today is < 15th, next payment is 15th, else nextPayment is
@@ -1418,7 +1428,29 @@ WHERE
         }
         }
 
 
         return $nextPaymentDate;
         return $nextPaymentDate;
-    }       
+    }
+    
+    public function getNextPaymentDateAsRd(){
+        $nextPaymentDate = '--';
+        //if today is < 15th, next payment is 15th, else nextPayment is
+        $today = strtotime(date('Y-m-d'));
+        $todayDate = date('j', $today);
+
+        $todayMonth =  date('m', $today);
+        $todayYear = date('Y', $today);
+        if ($todayDate < 15) {
+            $nextPaymentDate = new DateTime(); 
+            $nextPaymentDate->setDate($todayYear, $todayMonth, 15);
+            $nextPaymentDate = $nextPaymentDate->format('m/d/Y');
+        } else {
+            $nextPaymentDate = new \DateTime();
+            $lastDayOfMonth = date('t', $today);
+            $nextPaymentDate->setDate($todayYear, $todayMonth, $lastDayOfMonth);
+            $nextPaymentDate = $nextPaymentDate->format('m/d/Y');
+        }
+
+        return $nextPaymentDate;
+    }
 
 
 
 
     public function clientSmsesAsDna(){
     public function clientSmsesAsDna(){
@@ -1430,6 +1462,15 @@ WHERE
         ->paginate(15);
         ->paginate(15);
     }
     }
 
 
+    public function clientSmsesAsrd(){
+        $myId = $this->id;
+        return ClientSMS::whereHas('client', function($clientQuery) use ($myId){
+            return $clientQuery->where('rd_pro_id', $myId);
+        })
+        ->orderBy('created_at', 'DESC')
+        ->paginate(15);
+    }
+
     public function clientMemosAsDna(){
     public function clientMemosAsDna(){
         $naClientMemos = DB::select(
         $naClientMemos = DB::select(
             DB::raw("
             DB::raw("

+ 7 - 4
resources/views/app/rd/dashboard.blade.php

@@ -126,7 +126,7 @@
                                         </tr>
                                         </tr>
                                         <tr>
                                         <tr>
                                             <th class="px-2 text-center">
                                             <th class="px-2 text-center">
-                                                {{ $pro->supplyOrdersPendingHcpApprovalCountAsRd() }}
+                                                {{ $pro->supplyOrdersPendingHcpApprovalCountAsDna() }}
                                             <th>
                                             <th>
                                             <th class="pl-2">
                                             <th class="pl-2">
                                                 <a class="font-weight-normal"
                                                 <a class="font-weight-normal"
@@ -167,7 +167,7 @@
                                         </tr>
                                         </tr>
                                         <tr class="thin">
                                         <tr class="thin">
                                             <th class="font-weight-normal px-2 pl-4">
                                             <th class="font-weight-normal px-2 pl-4">
-                                                {{ friendly_date_time($performer->pro->getNextPaymentDateAsDna(), false) }}
+                                                {{ friendly_date_time($performer->pro->getNextPaymentDateAsRd(), false) }}
                                             </th>
                                             </th>
                                             <th class="font-weight-normal pl-2">Next Payment Date</th>
                                             <th class="font-weight-normal pl-2">Next Payment Date</th>
                                         </tr>
                                         </tr>
@@ -180,7 +180,7 @@
                                         </tr>
                                         </tr>
                                         <tr class="thin">
                                         <tr class="thin">
                                             <th class="font-weight-normal px-2 pl-4">
                                             <th class="font-weight-normal px-2 pl-4">
-                                                ${{ friendly_money($performer->pro->getProcessingAmountAsDna()) }}</th>
+                                                ${{ friendly_money($performer->pro->getProcessingAmountAsRd()) }}</th>
                                             <th class="font-weight-normal pl-2"><a
                                             <th class="font-weight-normal pl-2"><a
                                                     href="/practice-management/bills-under-processing">Processing</a></th>
                                                     href="/practice-management/bills-under-processing">Processing</a></th>
                                         </tr>
                                         </tr>
@@ -191,10 +191,13 @@
                             </div>
                             </div>
                         </div>
                         </div>
                     </div>
                     </div>
-                    <div class="col-md-9">
+                    <div class="col-md-9 pl-1">
                         <div class="row mcp-theme-1">
                         <div class="row mcp-theme-1">
                             <div class="col-md-6 mcp-theme-1">
                             <div class="col-md-6 mcp-theme-1">
+                                <!-- APPOINTMENTS -->
+                                <div id="dna-dashboard-appointments" class="mb-4">
 
 
+                                </div>
 
 
                                 <!-- ENCOUNTERS PENDING MY REVIEW -->
                                 <!-- ENCOUNTERS PENDING MY REVIEW -->
                                 <div class="card mb-4">
                                 <div class="card mb-4">

+ 36 - 0
resources/views/app/rd/dashboard/messages.blade.php

@@ -0,0 +1,36 @@
+@php 
+$clientSmses = $performer->pro->clientSmsesAsRd();
+@endphp 
+
+@if(!$clientSmses || !count($clientSmses))
+    <div class="px-2 py-3">No messages</div>
+@else
+    <table class="table table-sm m-0">
+        <tbody>
+        @foreach($clientSmses as $msg)
+            <tr>
+                <td class="px-1">
+                    <a href="{{route('patients.view.sms', $msg->client->uid)}}">
+                        {{$msg->client->name_first}} {{$msg->client->name_last}}
+                    </a>
+                    <a class="text-sm text-nowrap d-block"
+                       href="/messages-thread/{{$msg->client->uid}}"
+                       native target="_blank"
+                       open-in-stag-popup
+                       popup-style="tall"
+                       title="Messages for {{$msg->client->name_first}} {{$msg->client->name_last}}">
+                        {{friendlier_date_time($msg->created_at)}}
+                    </a>
+                </td>
+                <td class="px-1 w-75 text-left">
+                    {{$msg->body}}
+                </td>
+               
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+    <div class="p-2 border-top bg-light text-center">
+        {{$clientSmses->links()}}
+    </div>
+@endif