Переглянути джерело

Client memo notifications and stamping

Vijayakrishnan 3 роки тому
батько
коміт
e3543fff28

+ 27 - 1
app/Http/Controllers/HomeController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
 use App\Lib\Backend;
 use App\Models\Appointment;
 use App\Models\AppSession;
+use App\Models\ClientMemo;
 use App\Models\ClientProChange;
 use App\Models\ClientSMS;
 use App\Models\Facility;
@@ -392,6 +393,30 @@ class HomeController extends Controller
             ->whereNull('current_client_pro_change_decision_id')
             ->get();
 
+        // unstamped client memos
+        // for mcp
+        $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
+WHERE
+      c.mcp_pro_id = {$performerProID} AND
+      cm.mcp_stamp_id IS NULL;
+            ")
+        );
+        // for na
+        $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
+WHERE
+      c.default_na_pro_id = {$performerProID} AND
+      cm.default_na_stamp_id IS NULL;
+            ")
+        );
+
         $naBillableSignedNotes = DB::select(DB::raw("
 SELECT count(note.id) as na_billable_notes
 FROM note
@@ -501,7 +526,8 @@ WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$per
             'businessNumbers',
             'incomingReports', 'tickets', 'supplyOrders',
             'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
-            'newMCPAssociations', 'newNAAssociations'));
+            'newMCPAssociations', 'newNAAssociations',
+            'mcpClientMemos', 'naClientMemos'));
     }
 
     public function dashboardMeasurementsTab(Request $request, $page = 1) {

+ 103 - 18
resources/views/app/dashboard.blade.php

@@ -201,28 +201,90 @@
             </div>
             <div class="col-md-9">
 
-                <!-- 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="mb-1">You have been assigned as the MCP for {{$assoc->patient->displayName()}}.
-                            <a href="#" class="ack-client-pro-change" data-uid="{{$assoc->uid}}">Acknowledge</a>
+                <div class="row">
+                    <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="mb-1">You have been assigned as the MCP for
+                                        <a href="/patients/view/{{$assoc->patient->uid}}" class="d-inline-block width-150px">{{$assoc->patient->displayName()}}</a>.
+                                        <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
+                                    </div>
+                                @endforeach
                             </div>
-                        @endforeach
-                    </div>
-                @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="mb-1">You have been assigned as the Care Coordinator for {{$assoc->patient->displayName()}}.
-                                <a href="#" class="ack-client-pro-change" data-uid="{{$assoc->uid}}">Acknowledge</a>
+                        @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="mb-1">You have been assigned as the Care Coordinator for
+                                        <a href="/patients/view/{{$assoc->patient->uid}}" class="d-inline-block width-150px">{{$assoc->patient->displayName()}}</a>.
+                                        <a href="#" class="ack-client-pro-change ml-3" data-uid="{{$assoc->uid}}">Stamp</a>
+                                    </div>
+                                @endforeach
                             </div>
-                        @endforeach
+                        @endif
                     </div>
-                @endif
+                    <div class="col-6">
+                        @if(count($mcpClientMemos))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>New Patients Memos (MCP)</b></p>
+                                <table class="table table-sm table-hover table-bordered">
+                                    <thead>
+                                    <tr>
+                                        <th>Patient</th>
+                                        <th>Memo</th>
+                                        <th>Created</th>
+                                        <th></th>
+                                    </tr>
+                                    </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}}">Stamp</a></td>
+                                        </tr>
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            </div>
+                        @endif
+                        @if(count($naClientMemos))
+                            <div class="mb-3 border rounded px-3 py-2 ack-container">
+                                <p class="pt-1 mb-2"><b>New Patients Memos (NA)</b></p>
+                                <table class="table table-sm table-hover table-bordered">
+                                    <thead>
+                                    <tr>
+                                        <th>Patient</th>
+                                        <th>Memo</th>
+                                        <th>Created</th>
+                                        <th></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}}">Stamp</a></td>
+                                        </tr>
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            </div>
+                        @endif
+                    </div>
+                </div>
 
                 <ul class="nav nav-tabs">
                     <li class="nav-item">
@@ -696,6 +758,29 @@
                     }, 'json');
                     return false;
                 });
+
+            $(document)
+                .off('click', '.ack-client-memo')
+                .on('click', '.ack-client-memo', function() {
+                    let trigger = $(this).text('…');
+                    $.post('/api/clientMemo/stamp', {
+                        uid: $(this).attr('data-uid')
+                    }, _data => {
+                        if(!hasResponseError(_data)) {
+                            trigger.hide();
+                            let doneElem = $('<i class="text-success fa fa-check"></i>');
+                            doneElem.insertAfter(trigger);
+                            setTimeout(() => {
+                                let tbody = trigger.closest('tbody');
+                                trigger.closest('tr').remove();
+                                if(!tbody.find('>tr').length) {
+                                    tbody.closest('.ack-container').remove();
+                                }
+                            }, 500);
+                        }
+                    }, 'json');
+                    return false;
+                });
         }
         addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
     })();