瀏覽代碼

Admin dashboard optimize

Vijayakrishnan 3 年之前
父節點
當前提交
28e81d9691
共有 2 個文件被更改,包括 228 次插入146 次删除
  1. 64 16
      app/Http/Controllers/HomeController.php
  2. 164 130
      resources/views/app/dashboard-admin.blade.php

+ 64 - 16
app/Http/Controllers/HomeController.php

@@ -1150,17 +1150,37 @@ WHERE cl.shadow_pro_id IS NULL
             ->whereRaw('created_by_session_id IN (SELECT id FROM app_session where pro_id = ?)', [$performer->pro->id])
             ->count();
 
-        $newMCPAssociations = ClientProChange
-            ::where('new_pro_id', $performerProID)
-            ->where('responsibility_type', 'MCP')
-            ->whereNull('current_client_pro_change_decision_id')
-            ->get();
+        $newMCPAssociations = [];
+        if($request->input('mcpas')) {
+            $newMCPAssociations = ClientProChange
+                ::where('new_pro_id', $performerProID)
+                ->where('responsibility_type', 'MCP')
+                ->whereNull('current_client_pro_change_decision_id')
+                ->get();
+        }
+        else {
+            $newMCPAssociations = ClientProChange
+                ::where('new_pro_id', $performerProID)
+                ->where('responsibility_type', 'MCP')
+                ->whereNull('current_client_pro_change_decision_id')
+                ->count();
+        }
 
-        $newNAAssociations = ClientProChange
-            ::where('new_pro_id', $performerProID)
-            ->where('responsibility_type', 'DEFAULT_NA')
-            ->whereNull('current_client_pro_change_decision_id')
-            ->get();
+        $newNAAssociations = [];
+        if($request->input('naas')) {
+            $newNAAssociations = ClientProChange
+                ::where('new_pro_id', $performerProID)
+                ->where('responsibility_type', 'DEFAULT_NA')
+                ->whereNull('current_client_pro_change_decision_id')
+                ->get();
+        }
+        else {
+            $newNAAssociations = ClientProChange
+                ::where('new_pro_id', $performerProID)
+                ->where('responsibility_type', 'DEFAULT_NA')
+                ->whereNull('current_client_pro_change_decision_id')
+                ->count();
+        }
 
         $proApptUpdates = AppointmentConfirmationDecision
             ::select('appointment_confirmation_decision.uid', 'client.name_first', 'client.name_last', 'appointment.start_time')
@@ -1198,8 +1218,10 @@ WHERE cl.shadow_pro_id IS NULL
 
         // unstamped client memos
         // for mcp
-        $mcpClientMemos = DB::select(
-            DB::raw("
+        $mcpClientMemos = [];
+        if($request->input('mcpcm')) {
+            $mcpClientMemos = DB::select(
+                DB::raw("
 SELECT c.uid as client_uid, c.name_first, c.name_last,
        cm.uid, cm.content, cm.created_at
 FROM client c join client_memo cm on c.id = cm.client_id
@@ -1208,10 +1230,24 @@ WHERE
       cm.mcp_stamp_id IS NULL
 ORDER BY cm.created_at DESC
             ")
-        );
+            );
+        }
+        else {
+            $mcpClientMemos = DB::select(
+                DB::raw("
+SELECT COUNT(cm.id)
+FROM client c join client_memo cm on c.id = cm.client_id
+WHERE
+      c.mcp_pro_id = {$performerProID} AND
+      cm.mcp_stamp_id IS NULL
+            ")
+            );
+        }
         // for na
-        $naClientMemos = DB::select(
-            DB::raw("
+        $naClientMemos = [];
+        if($request->input('nacm')) {
+            $naClientMemos = DB::select(
+                DB::raw("
 SELECT c.uid as client_uid, c.name_first, c.name_last,
        cm.uid, cm.content, cm.created_at
 FROM client c join client_memo cm on c.id = cm.client_id
@@ -1220,7 +1256,19 @@ WHERE
       cm.default_na_stamp_id IS NULL
 ORDER BY cm.created_at DESC
             ")
-        );
+            );
+        }
+        else {
+            $naClientMemos = DB::select(
+                DB::raw("
+SELECT COUNT(cm.id)
+FROM client c join client_memo cm on c.id = cm.client_id
+WHERE
+      c.default_na_pro_id = {$performerProID} AND
+      cm.default_na_stamp_id IS NULL
+            ")
+            );
+        }
 
         $keyNumbers['rmBillsToSign'] = Bill
             ::where('is_cancelled', false)

+ 164 - 130
resources/views/app/dashboard-admin.blade.php

@@ -400,152 +400,186 @@
 
                     <div class="row mt-3">
                         <div class="col-6">
-                        <!-- new associations -->
-                            @if(count($newMCPAssociations))
-                                <div class="mb-3 border rounded px-3 py-2 ack-container">
-                                    <p class="pt-1 mb-2"><b>New Patients</b></p>
-                                    @foreach($newMCPAssociations as $assoc)
-                                        <div class="d-flex align-items-start bg-light mb-2 px-2 py-1">
-                                            <div class="flex-grow-1">
-                                                You are now the MCP for
-                                                <a href="/patients/view/{{$assoc->patient->uid}}"
-                                                   class="">{{$assoc->patient->displayName()}}</a>
-                                                <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
-                                                @if($nextAppt)
-                                                    <div class="font-size-11">
-                                                        <span class="text-secondary font-size-11">Appt.</span>
-                                                        {{$nextAppt->pro->displayName()}}
-                                                        <span class="text-secondary font-size-11">on</span>
-                                                        {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
-                                                    </div>
-                                                    @if($nextAppt->status === 'PENDING') {{-- WIP: ALIX overhaul --}}
-                                                        <div
-                                                            class="text-warning-mellow font-weight-bold font-size-11 mt-1">
-                                                            <i class="fa fa-exclamation-triangle"></i>
-                                                            Confirmation pending
-                                                        </div>
-                                                    @endif
-                                                    @if($nextAppt->status === 'CONFIRMED')
-                                                        <div class="text-success font-weight-bold font-size-11 mt-1">
-                                                            <i class="fa fa-check"></i>
-                                                            Confirmed by the patient
-                                                        </div>
-                                                    @endif
-                                                    @if($nextAppt->status === 'CANCELLED')
-                                                        <div class="text-danger font-weight-bold font-size-11 mt-1">
-                                                            <i class="fa fa-stop"></i>
-                                                            Cancelled
+                            @if(request()->input('mcpas'))
+                                @if(count($newMCPAssociations))
+                                    <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                        <div class="d-flex align-items-baseline pt-1 mb-2">
+                                            <p class=""><b>New Patients</b></p>
+                                            <a href="/" class="ml-auto">Close</a>
+                                        </div>
+                                        @foreach($newMCPAssociations as $assoc)
+                                            <div class="d-flex align-items-start bg-light mb-2 px-2 py-1">
+                                                <div class="flex-grow-1">
+                                                    You are now the MCP for
+                                                    <a href="/patients/view/{{$assoc->patient->uid}}"
+                                                       class="">{{$assoc->patient->displayName()}}</a>
+                                                    <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
+                                                    @if($nextAppt)
+                                                        <div class="font-size-11">
+                                                            <span class="text-secondary font-size-11">Appt.</span>
+                                                            {{$nextAppt->pro->displayName()}}
+                                                            <span class="text-secondary font-size-11">on</span>
+                                                            {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
                                                         </div>
+                                                        @if($nextAppt->status === 'PENDING') {{-- WIP: ALIX overhaul --}}
+                                                            <div
+                                                                class="text-warning-mellow font-weight-bold font-size-11 mt-1">
+                                                                <i class="fa fa-exclamation-triangle"></i>
+                                                                Confirmation pending
+                                                            </div>
+                                                        @endif
+                                                        @if($nextAppt->status === 'CONFIRMED')
+                                                            <div class="text-success font-weight-bold font-size-11 mt-1">
+                                                                <i class="fa fa-check"></i>
+                                                                Confirmed by the patient
+                                                            </div>
+                                                        @endif
+                                                        @if($nextAppt->status === 'CANCELLED')
+                                                            <div class="text-danger font-weight-bold font-size-11 mt-1">
+                                                                <i class="fa fa-stop"></i>
+                                                                Cancelled
+                                                            </div>
+                                                        @endif
                                                     @endif
-                                                @endif
+                                                </div>
+                                                <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Ack.</a>
                                             </div>
-                                            <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Ack.</a>
-                                        </div>
-                                    @endforeach
-                                </div>
+                                        @endforeach
+                                    </div>
+                                @endif
+                            @else
+                                @if(!!$newMCPAssociations)
+                                    <a href="/?mcpas=1" class="d-block mb-2">You have <b>{{$newMCPAssociations}}</b> new MCP association{{$newMCPAssociations === 1 ? '' : 's'}}</a>
+                                @endif
                             @endif
-                            
-                            @if(count($newNAAssociations))
-                                <div class="mb-3 border rounded px-3 py-2 ack-container">
-                                    <p class="pt-1 mb-2"><b>New Patients</b></p>
-                                    @foreach($newNAAssociations as $assoc)
-                                        <div class="d-flex align-items-start bg-light mb-2 px-2 py-1">
-                                            <div class="flex-grow-1">
-                                                You are now the Care Coordinator for
-                                                <a href="/patients/view/{{$assoc->patient->uid}}"
-                                                   class="">{{$assoc->patient->displayName()}}</a>
-                                                <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
-                                                @if($nextAppt)
-                                                    <div class="font-size-11">
-                                                        <span class="text-secondary font-size-11">Appt.</span>
-                                                        {{$nextAppt->pro->displayName()}}
-                                                        <span class="text-secondary font-size-11">on</span>
-                                                        {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
-                                                    </div>
-                                                    @if($nextAppt->status === 'PENDING') {{-- WIP: ALIX overhaul --}}
+                            @if(request()->input('naas'))
+                                @if(count($newNAAssociations))
+                                    <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                        <div class="d-flex align-items-baseline pt-1 mb-2">
+                                            <p class=""><b>New Patients</b></p>
+                                            <a href="/" class="ml-auto">Close</a>
+                                        </div>
+                                        @foreach($newNAAssociations as $assoc)
+                                            <div class="d-flex align-items-start bg-light mb-2 px-2 py-1">
+                                                <div class="flex-grow-1">
+                                                    You are now the Care Coordinator for
+                                                    <a href="/patients/view/{{$assoc->patient->uid}}"
+                                                       class="">{{$assoc->patient->displayName()}}</a>
+                                                    <?php $nextAppt = $assoc->patient->nextAppointment(); ?>
+                                                    @if($nextAppt)
+                                                        <div class="font-size-11">
+                                                            <span class="text-secondary font-size-11">Appt.</span>
+                                                            {{$nextAppt->pro->displayName()}}
+                                                            <span class="text-secondary font-size-11">on</span>
+                                                            {{friendlier_date_time($nextAppt->raw_date . ' ' . $nextAppt->raw_start_time)}}
+                                                        </div>
+                                                        @if($nextAppt->status === 'PENDING') {{-- WIP: ALIX overhaul --}}
                                                         <div
-                                                            class="text-warning-mellow font-weight-bold font-size-11 mt-1">
+                                                                class="text-warning-mellow font-weight-bold font-size-11 mt-1">
                                                             <i class="fa fa-exclamation-triangle"></i>
                                                             Confirmation pending
                                                         </div>
+                                                        @endif
+                                                        @if($nextAppt->status === 'CONFIRMED')
+                                                            <div class="text-success font-weight-bold font-size-11 mt-1">
+                                                                <i class="fa fa-check"></i>
+                                                                Confirmed by the patient
+                                                            </div>
+                                                        @endif
+                                                        @if($nextAppt->status === 'CANCELLED')
+                                                            <div class="text-danger font-weight-bold font-size-11 mt-1">
+                                                                <i class="fa fa-stop"></i>
+                                                                Cancelled
+                                                            </div>
+                                                        @endif
                                                     @endif
-                                                    @if($nextAppt->status === 'CONFIRMED')
-                                                        <div class="text-success font-weight-bold font-size-11 mt-1">
-                                                            <i class="fa fa-check"></i>
-                                                            Confirmed by the patient
-                                                        </div>
-                                                    @endif
-                                                    @if($nextAppt->status === 'CANCELLED')
-                                                        <div class="text-danger font-weight-bold font-size-11 mt-1">
-                                                            <i class="fa fa-stop"></i>
-                                                            Cancelled
-                                                        </div>
-                                                    @endif
-                                                @endif
+                                                </div>
+                                                <a href="#" class="ack-client-pro-change"
+                                                   data-uid="{{$assoc->uid}}">Ack.</a>
                                             </div>
-                                            <a href="#" class="ack-client-pro-change"
-                                               data-uid="{{$assoc->uid}}">Ack.</a>
-                                        </div>
-                                    @endforeach
-                                </div>
+                                        @endforeach
+                                    </div>
+                                @endif
+                            @else
+                                @if(!!$newNAAssociations)
+                                    <a href="/?naas=1" class="d-block">You have <b>{{$newNAAssociations}}</b> new NA association{{$newNAAssociations === 1 ? '' : 's'}}</a>
+                                @endif
                             @endif
                         </div>
                         <div class="col-6">
-                            @if(count($mcpClientMemos))
-                                <div class="mb-3 border rounded px-3 py-2 ack-container table-responsive">
-                                    <p class="pt-1 mb-2"><b>New Patients Memos (MCP)</b></p>
-                                    <table class="table table-sm table-hover table-striped table-bordered">
-                                        <thead class="bg-light">
-                                        <tr>
-                                            <th class="border-bottom-0">Patient</th>
-                                            <th class="border-bottom-0">Memo</th>
-                                            <th class="border-bottom-0">Created</th>
-                                            <th class="border-bottom-0"></th>
-                                        </tr>
-                                        </thead>
-                                        <tbody>
-                                        @foreach($mcpClientMemos as $memo)
+                            @if(request()->input('mcpcm'))
+                                @if(count($mcpClientMemos))
+                                    <div class="mb-3 border rounded px-3 py-2 ack-container table-responsive">
+                                        <div class="d-flex align-items-baseline pt-1 mb-2">
+                                            <p class=""><b>New Patients Memos (MCP)</b></p>
+                                            <a href="/" class="ml-auto">Close</a>
+                                        </div>
+                                        <table class="table table-sm table-hover table-striped table-bordered">
+                                            <thead class="bg-light">
                                             <tr>
-                                                <td class="">
-                                                    <a href="/patients/view/{{$memo->client_uid}}">{{$memo->name_first}} {{$memo->name_last}}</a>
-                                                </td>
-                                                <td>{!! $memo->content !!}</td>
-                                                <td class="text-nowrap">{{friendlier_date_time($memo->created_at)}}</td>
-                                                <td><a href="#" class="ack-client-memo"
-                                                       data-uid="{{$memo->uid}}">Ack.</a></td>
+                                                <th class="border-bottom-0">Patient</th>
+                                                <th class="border-bottom-0">Memo</th>
+                                                <th class="border-bottom-0">Created</th>
+                                                <th class="border-bottom-0"></th>
                                             </tr>
-                                        @endforeach
-                                        </tbody>
-                                    </table>
-                                </div>
+                                            </thead>
+                                            <tbody>
+                                            @foreach($mcpClientMemos as $memo)
+                                                <tr>
+                                                    <td class="">
+                                                        <a href="/patients/view/{{$memo->client_uid}}">{{$memo->name_first}} {{$memo->name_last}}</a>
+                                                    </td>
+                                                    <td>{!! $memo->content !!}</td>
+                                                    <td class="text-nowrap">{{friendlier_date_time($memo->created_at)}}</td>
+                                                    <td><a href="#" class="ack-client-memo"
+                                                           data-uid="{{$memo->uid}}">Ack.</a></td>
+                                                </tr>
+                                            @endforeach
+                                            </tbody>
+                                        </table>
+                                    </div>
+                                @endif
+                            @else
+                                @if($mcpClientMemos[0]->count)
+                                    <a href="/?mcpcm=1" class="d-block mb-2">You have <b>{{$mcpClientMemos[0]->count}}</b> new MCP client memo{{$mcpClientMemos[0]->count === 1 ? '' : 's'}}</a>
+                                @endif
                             @endif
-                            @if(count($naClientMemos))
-                                <div class="mb-3 border rounded px-3 py-2 ack-container table-responsive">
-                                    <p class="pt-1 mb-2"><b>New Patients Memos (NA)</b></p>
-                                    <table class="table table-sm table-hover table-striped table-bordered">
-                                        <thead class="bg-light">
-                                        <tr>
-                                            <th class="border-bottom-0">Patient</th>
-                                            <th class="border-bottom-0">Memo</th>
-                                            <th class="border-bottom-0">Created</th>
-                                            <th class="border-bottom-0"></th>
-                                        </tr>
-                                        </thead>
-                                        <tbody>
-                                        @foreach($naClientMemos as $memo)
-                                            <tr>
-                                                <td class="">
-                                                    <a href="/patients/view/{{$memo->client_uid}}">{{$memo->name_first}} {{$memo->name_last}}</a>
-                                                </td>
-                                                <td>{!! $memo->content !!}</td>
-                                                <td class="text-nowrap">{{friendlier_date_time($memo->created_at)}}</td>
-                                                <td><a href="#" class="ack-client-memo"
-                                                       data-uid="{{$memo->uid}}">Ack.</a></td>
-                                            </tr>
-                                        @endforeach
-                                        </tbody>
-                                    </table>
-                                </div>
+                            @if(request()->input('nacm'))
+                                @if(count($naClientMemos))
+                                        <div class="mb-3 border rounded px-3 py-2 ack-container table-responsive">
+                                            <div class="d-flex align-items-baseline pt-1 mb-2">
+                                                <p class=""><b>New Patients Memos (NA)</b></p>
+                                                <a href="/" class="ml-auto">Close</a>
+                                            </div>
+                                            <table class="table table-sm table-hover table-striped table-bordered">
+                                                <thead class="bg-light">
+                                                <tr>
+                                                    <th class="border-bottom-0">Patient</th>
+                                                    <th class="border-bottom-0">Memo</th>
+                                                    <th class="border-bottom-0">Created</th>
+                                                    <th class="border-bottom-0"></th>
+                                                </tr>
+                                                </thead>
+                                                <tbody>
+                                                @foreach($naClientMemos as $memo)
+                                                    <tr>
+                                                        <td class="">
+                                                            <a href="/patients/view/{{$memo->client_uid}}">{{$memo->name_first}} {{$memo->name_last}}</a>
+                                                        </td>
+                                                        <td>{!! $memo->content !!}</td>
+                                                        <td class="text-nowrap">{{friendlier_date_time($memo->created_at)}}</td>
+                                                        <td><a href="#" class="ack-client-memo"
+                                                               data-uid="{{$memo->uid}}">Ack.</a></td>
+                                                    </tr>
+                                                @endforeach
+                                                </tbody>
+                                            </table>
+                                        </div>
+                                    @endif
+                            @else
+                                @if($naClientMemos[0]->count)
+                                    <a href="/?nacm=1" class="d-block mb-2">You have <b>{{$naClientMemos[0]->count}}</b> new MCP client memo{{$naClientMemos[0]->count === 1 ? '' : 's'}}</a>
+                                @endif
                             @endif
                         </div>
                     </div>