Explorar o código

Merge branch 'master' of https://rav.triplestart.com/jmudaka/stagfe2

logicpowerhouse %!s(int64=4) %!d(string=hai) anos
pai
achega
14b126f7e1

+ 4 - 0
app/Http/Controllers/PatientController.php

@@ -352,4 +352,8 @@ class PatientController extends Controller
         $ticket->initiatingPro;
         return json_encode($ticket);
     }
+
+    public function mcpRequests(Request $request, Client $patient) {
+        return view('app.patient.mcp-requests', compact('patient'));
+    }
 }

+ 15 - 15
app/Http/Controllers/PracticeManagementController.php

@@ -344,21 +344,21 @@ class PracticeManagementController extends Controller
         if ($requests && count($requests)) {
             foreach ($requests as $mcpRequest) {
                 $client = $mcpRequest->client;
-                if ($client->initiative) {
-                    if (strpos($this->performer->pro->initiative, $client->initiative) !== false) {
-                        $results[] = [
-                            "clientUid" => $client->uid,
-                            "name" => $client->displayName(),
-                            "initials" => substr($client->name_first, 0, 1) . substr($client->name_last, 0, 1)
-                        ];
-                    }
-                } else {
-                    $results[] = [
-                        "clientUid" => $client->uid,
-                        "name" => $client->displayName(),
-                        "initials" => substr($client->name_first, 0, 1) . substr($client->name_last, 0, 1)
-                    ];
-                }
+                // if ($client->initiative) {
+                //     if (strpos($this->performer->pro->initiative, $client->initiative) !== false) {
+                //         $results[] = [
+                //             "clientUid" => $client->uid,
+                //             "name" => $client->displayName(),
+                //             "initials" => substr($client->name_first, 0, 1) . substr($client->name_last, 0, 1)
+                //         ];
+                //     }
+                // } else {
+                $results[] = [
+                    "clientUid" => $client->uid,
+                    "name" => $client->displayName(),
+                    "initials" => substr($client->name_first, 0, 1) . substr($client->name_last, 0, 1)
+                ];
+                //}
             }
         }
         return json_encode($results);

+ 5 - 0
app/Models/AppSession.php

@@ -13,4 +13,9 @@ class AppSession extends Model
     {
         return $this->hasOne(Pro::class, 'id', 'pro_id');
     }
+
+    public function client()
+    {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
 }

+ 6 - 0
app/Models/Client.php

@@ -350,4 +350,10 @@ class Client extends Model
 
     }
 
+    public function mcpRequests()
+    {
+        return $this->hasMany(McpRequest::class, 'for_client_id', 'id')
+            ->orderBy('created_at', 'desc');
+    }
+
 }

+ 36 - 0
app/Models/McpRequest.php

@@ -2,6 +2,9 @@
 
 namespace App\Models;
 
+use Carbon\Carbon;
+use DateTime;
+
 # use Illuminate\Database\Eloquent\Model;
 
 class McpRequest extends Model
@@ -13,4 +16,37 @@ class McpRequest extends Model
         return $this->hasOne(Client::class, 'id', 'for_client_id');
     }
 
+    public function proClientWork()
+    {
+        return $this->hasOne(ProClientWork::class, 'id', 'mcp_pro_client_work_id');
+    }
+
+    public function createdBy()
+    {
+        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
+    }
+
+    public function createdByName(){
+        $performer = $this->createdBy;
+        if($performer->session_type == 'PRO'){
+            return $performer->pro->name_first.' '.$performer->pro->name_last;
+        }
+
+        if($performer->session_type == 'CLIENT_GUEST'){
+            return $performer->client->name_first.' '.$performer->client->name_last;
+        }
+
+        return "-";
+    }
+
+    public function getWaitTime(){
+        if(!$this->was_claimed){
+            return "-";
+        }
+
+        $created_at = new Carbon($this->created_at);
+        $claimed_at = new Carbon($this->proClientWork->created_at);
+        return $claimed_at->diffForHumans($created_at);
+    }
+
 }

+ 5 - 0
app/Models/ProClientWork.php

@@ -12,4 +12,9 @@ class ProClientWork extends Model
     {
         return $this->hasOne(Client::class, 'id', 'client_id');
     }
+
+    public function pro()
+    {
+        return $this->hasOne(Pro::class, 'id', 'pro_id');
+    }
 }

+ 42 - 0
resources/views/app/patient/mcp-requests.blade.php

@@ -0,0 +1,42 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+<div id="client-settings-container">
+    <div class="row">
+        <div class="col-md-12">
+            <h1>MCP Requests</h1>
+            <hr>
+            <table class="table table-condensed table-striped">
+                <thead>
+                    <tr>
+                        <th>Created At</th>
+                        <th>Created By</th>
+                        <th>Was Claimed?</th>
+                        <th>Claimed At</th>
+                        <th>Claimed By</th>
+                        <th>Waiting Time</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($patient->mcpRequests as $mcp)
+                    <tr>
+                        <td>{{friendly_date_time($mcp->created_at)}}</td>
+                        <td>[{{$mcp->createdBy->session_type}}] {{$mcp->createdByName()}}</td>
+                        <td>{{$mcp->was_claimed?'Yes':'No'}}</td>
+                       
+                        @if($mcp->was_claimed)
+                        <td>{{friendly_date_time($mcp->proClientWork->created_at)}}</td>
+                        <td>{{$mcp->proClientWork->pro->name_first}} {{$mcp->proClientWork->pro->name_last}}</td>
+                        @else 
+                        <td>-</td>
+                        <td>-</td>
+                        @endif
+                        <td>{{$mcp->getWaitTime()}}</td>
+                    </tr>
+                    @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+</div>
+@endsection

+ 54 - 4
resources/views/app/patient/partials/mcp-queue.blade.php

@@ -1,15 +1,62 @@
+<style>
+    [v-cloak] {
+        opacity: 0;
+    }
+    #queueComponent .patient-avatar {
+        width: 50px;
+        height: 50px;
+        background: #ddd;
+        display: inline-flex;
+        align-items: center;
+        justify-content: center;
+        border-radius: 100%;
+    }
+    #queueComponent .large {
+        font-size: 16px !important;
+    }
+    #queueComponent .queue-item {
+        width: 100px;
+        padding: 0.5rem;
+        padding-bottom: 0.25rem;
+        text-align: center;
+        cursor: pointer;
+    }
+    .patient-queue {
+        display: flex;
+        flex-direction: column;
+        position: fixed;
+        left: 0;
+        width: 100%;
+        bottom: 0;
+        z-index: 4;
+    }
+    .patient-queue .btn.btn-primary:not(:disabled),
+    .patient-queue .btn.btn-primary:not(:disabled):active {
+        color: #fff;
+        background-color: #0062cc;
+        border-color: #005cbf;
+        font-family: Verdana, sans-serif;
+        font-size: 12px;
+    }
+    body.has-mcp-queue {
+        padding-bottom: 150px;
+    }
+    body.has-mcp-queue #call-actions {
+        bottom: 150px;
+    }
+</style>
 <div class="border-top patient-queue mcp-theme-1" id="queueComponent" v-cloak>
-    <div class="bg-secondary text-white font-weight-bold text-center py-1" v-if="items.length > 0">
+    <div class="bg-secondary text-white font-weight-bold text-center py-1 small " v-if="items.length > 0">
         @{{ items.length }} patient@{{ items.length > 1 ? 's' : '' }} in the queue
     </div>
-    <div class="bg-secondary text-white font-weight-bold text-center py-1" v-if="items.length === 0">
+    <div class="bg-secondary text-white font-weight-bold text-center py-1 small " v-if="items.length === 0">
         No patients in the queue
     </div>
     <div v-if="items && items.length" class="d-flex align-items-center my-1">
         <div v-for="item in items">
             <div class="queue-item border border-primary rounded mx-1" :title="item.name">
-                <div class="patient-avatar mb-1 text-dark">@{{ item.initials }}</div>
-                <div class="font-weight-bold small text-nowrap text-ellipsis">@{{ item.name }}</div>
+                <div class="patient-avatar mb-1 text-dark small font-weight-bold">@{{ item.initials }}</div>
+                <div class="font-weight-bold small text-nowrap text-ellipsis text-secondary">@{{ item.name }}</div>
             </div>
             <button class="btn btn-sm btn-primary mt-1 text-white font-weight-bold py-0 mx-auto d-block"
                     v-on:click.prevent="claim(item.clientUid)">Claim</button>
@@ -53,6 +100,9 @@
             mounted:function(){
                 let self = this;
                 self.refresh();
+                window.setInterval(function(){
+                    self.refresh();
+                }, 5000)
                 let socket = new SockJS("{{ config('app.backend_ws_url') }}");
                 self.socketClient = Stomp.over(socket);
                 self.socketClient.connect({}, (frame) => {

+ 4 - 1
resources/views/app/video/call-minimal.blade.php

@@ -16,7 +16,7 @@
     <link href="/css/call-minimal.css" rel="stylesheet">
 </head>
 
-<body class="p-0 m-0">
+<body class="p-0 m-0 has-mcp-queue">
 
 <div class="d-flex px-3 border-bottom">
     <div class="py-2 font-weight-normal mcp-theme-1 d-inline-flex align-items-center">
@@ -675,5 +675,8 @@
     }).call(window);
 </script>
 
+<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
+@include('app/patient/partials/mcp-queue')
+
 </body>
 </html>

+ 6 - 0
resources/views/layouts/patient.blade.php

@@ -133,6 +133,12 @@
                         {{--<li class="nav-item">
                             <a class="nav-link" href="/patients/view/{{ $patient->uid }}/intake">Intake</a>
                         </li>--}}
+                        @if($performer->pro->pro_type == 'ADMIN')
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.mcp-requests') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.mcp-requests', $patient) }}">MCP Requests</a>
+                        </li>
+                        @endif
                     </ul>
                     <div class="mt-3 mcp-theme-1">
                         @yield('left-nav-content')

+ 4 - 0
routes/web.php

@@ -99,6 +99,10 @@ Route::middleware('pro.auth')->group(function () {
         });
     });
 
+    Route::middleware('pro.auth.admin')->group(function(){
+        Route::get('patients/view/mcp-requests/{patient?}', 'PatientController@mcpRequests')->name('patients.view.mcp-requests');
+    });
+
     Route::name('patients.view.')->prefix('patients/view/{patient}')->group(function () {
         Route::get('intake', 'PatientController@intake')->name('intake');
         Route::get('', 'PatientController@dashboard')->name('dashboard');