ソースを参照

added mcp requests table

= 4 年 前
コミット
5cbb01fde0

+ 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'));
+    }
 }

+ 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

+ 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')

+ 5 - 0
routes/web.php

@@ -93,9 +93,14 @@ Route::middleware('pro.auth')->group(function () {
             Route::get('tickets', 'PracticeManagementController@tickets')->name('tickets');
             Route::get('claims', 'PracticeManagementController@claims')->name('claims');
             Route::get('claims-download', 'PracticeManagementController@downloadClaims')->name('download-claims');
+
         });
     });
 
+    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');