Эх сурвалжийг харах

Show patients granted access to

Samson Mutunga 1 жил өмнө
parent
commit
627c4553bb

+ 6 - 0
app/Http/Controllers/DnaController.php

@@ -9,6 +9,7 @@ use App\Models\CareMonth;
 use App\Models\Client;
 use App\Models\ClientBDTDevice;
 use App\Models\ClientInfoLine;
+use App\Models\ClientProAccess;
 use App\Models\Erx;
 use App\Models\Facility;
 use App\Models\Handout;
@@ -41,6 +42,11 @@ class DnaController extends Controller
         $filters = $request->all();
         $patients = Client::whereNull('shadow_pro_id')->where('default_na_pro_id', $this->performer->pro->id);
 
+        //Also include the ones given access to:
+        $proAccessClientIDs = ClientProAccess::where('pro_id', $this->performer->pro->id)->pluck('client_id')->toArray();
+        $patients = $patients->orWhereIn('id', $proAccessClientIDs);
+
+
         if ($request->input('name')) {
             $name = trim($request->input('name'));
             if ($name) {

+ 8 - 2
app/Http/Controllers/McpController.php

@@ -31,6 +31,7 @@ use App\Models\Bill;
 use App\Models\ClientSMS;
 use App\Models\AccountInvite;
 use App\Models\ClientMemo;
+use App\Models\ClientProAccess;
 use Illuminate\Support\Facades\Http;
 use PDF;
 
@@ -39,13 +40,18 @@ class McpController extends Controller
 
     public function patients(Request $request)
     {
+        $pro = $this->performer->pro;
         $filters = $request->all();
         $patients = Client::whereNull('shadow_pro_id');
         
         //TODO: implement in admin controller 
-        if($this->performer->pro->pro_type != 'ADMIN'){
-            $patients->where('mcp_pro_id', $this->performer->pro->id);
+        if($pro->pro_type != 'ADMIN'){
+            $patients->where('mcp_pro_id', $pro->id);
         }
+
+        //Also include the ones given access to:
+        $proAccessClientIDs = ClientProAccess::where('pro_id', $pro->id)->pluck('client_id')->toArray();
+        $patients = $patients->orWhereIn('id', $proAccessClientIDs);
         
 
         // filters

+ 6 - 1
resources/views/app/dna/patients-table.blade.php

@@ -24,7 +24,12 @@
 					{{$patient->chart_number}}
 				</a>
 			</td>
-			<td>{{$patient->displayName()}}</td>
+			<td>
+				{{$patient->displayName()}}
+				@if($patient->default_na_pro_id != $pro->id)
+					<span class="text-danger ml-1" title="This is not your patient but you have been granted access!"><i class="fas fa-user-clock fa-fw"></i></span>
+				@endif
+			</td>
 			<td class="text-nowrap">{{ friendly_date_time($patient->dob, false) }}</td>
 			<td>{{ $patient->age_in_years ?  $patient->age_in_years : '-' }}</td>
 			<td>{{ $patient->sex }}</td>

+ 6 - 1
resources/views/app/mcp/patients-table.blade.php

@@ -39,7 +39,12 @@
 						{{$patient->chart_number}}
 					</a>
 				</td>
-				<td>{{$patient->displayName()}}</td>
+				<td>
+					{{$patient->displayName()}}
+					@if($patient->mcp_pro_id != $pro->id)
+						<span class="text-danger ml-1" title="This is not your patient but you have been granted access!"><i class="fas fa-user-clock fa-fw"></i></span>
+					@endif
+				</td>
 				<td>{{ friendly_date_time($patient->dob, false) }}</td>
 				<td>{{ $patient->age_in_years ?  $patient->age_in_years : '-' }}</td>
 				<td>{{ $patient->sex }}</td>

+ 1 - 1
resources/views/app/patient/partials/cpt-alert.blade.php

@@ -1,6 +1,6 @@
 @if($pro->pro_type === 'ADMIN')
     <div id="cptAlertComponent" v-cloak>
-        <div v-if="errorCodes.length" class="alert alert-danger p-0 rounded-0 text-center">
+        <div v-if="errorCodes.length" class="alert alert-danger p-0 rounded-0 text-center mb-0">
             <div style="font-size: 14px;">
             <i class="fas fa-exclamation-triangle fa-fw"></i>
             <b>@{{ errorCodes.join(', ') }}</b> @{{ errorCodes.length > 1 ? 'codes have ':'code has ' }} never been submitted for this patient!</div>

+ 17 - 0
resources/views/layouts/patient-header.blade.php

@@ -45,6 +45,23 @@ $addressParts .= implode(", ", $addressPart2);
     }
 </style>
 <div class="px-2 pb-2 mcp-theme-1 patient-header">
+    @if($pro->pro_type !== 'ADMIN')
+        <?php 
+            $showNotYourPatientAlert = false;
+            if($pro->is_hcp && $patient->mcp_pro_id != $pro->id){
+                $showNotYourPatientAlert = true;
+            }
+            if($pro->profession_mode == 'NHCP' && $patient->default_na_pro_id != $pro->id){
+                $showNotYourPatientAlert = true;
+            }
+                
+            ?>
+        @if($showNotYourPatientAlert)
+        <div class="alert alert-danger p-1 rounded-0 mb-0">
+            <span class="ml-1"><i class="fas fa-user-clock fa-fw"></i> This is not your patient but you have been granted access!</span>
+        </div>
+        @endif
+    @endif
     @if($patient->is_duplicate)
         <div class="alert alert-warning p-1 mb-2 border-dark mcp-theme-1 screen-only">
             <span class="text-dark">This chart is a duplicate of&nbsp;</span>