Samson Mutunga 1 anno fa
parent
commit
165780f42b

+ 11 - 2
app/Http/Controllers/PatientController.php

@@ -35,7 +35,7 @@ use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\File;
 use App\Models\Measurement;
 use App\Models\ClientReviewRequest;
-
+use App\Models\Point;
 use Illuminate\Support\Facades\Http;
 use PDF;
 
@@ -101,6 +101,12 @@ class PatientController extends Controller
         $assignedDeviceIDs = null;
         unset($assignedDeviceIDs);
 
+        $availableDevices = count($devices);
+            $patientDeviceIDs = ClientBDTDevice::select('id')->where('client_id', $patient->id)->where('is_active', true)->get()->toArray();
+            $patientDeviceIDs = array_map(function ($_x) {
+                return $_x["id"];
+            }, $patientDeviceIDs);
+
         $dxInfoLines = ClientInfoLine::where('client_id', $patient->id)
             ->where('category', 'dx')
             ->where('is_removed', false)
@@ -120,10 +126,13 @@ class PatientController extends Controller
                 "value" => $shortcut->text
             ];
         }
+        
+        $recentMeasurements = $patient->recentMeasurements;
 
+        $latestVitals = Point::where('client_id', $patient->id)->where('category', 'VITALS')->orderBy('id', 'DESC')->first();
 
         return view('app.patient.dashboard',
-            compact('patient', 'facilities', 'devices', 'dxInfoLines', 'clientMemos', 'shortCutsObject'));
+            compact('patient', 'facilities', 'devices', 'dxInfoLines', 'clientMemos', 'shortCutsObject', 'availableDevices', 'patientDeviceIDs', 'recentMeasurements', 'latestVitals'));
     }
 
     public function canvasMigrate(Request $request, Client $patient )

+ 1 - 9
resources/views/app/patient/dashboard.blade.php

@@ -21,7 +21,7 @@
     <div class="row client-single-dashboard">
         <div class="col-6">
             <?php
-            $myCurrentClientReviewRequest = $performer->pro->currentMonthClientReviewRequest($patient->id);
+            $myCurrentClientReviewRequest = $pro->currentMonthClientReviewRequest($patient->id);
             ?>
             @if($myCurrentClientReviewRequest)
             <div class="pt-2 mt-2">
@@ -112,13 +112,6 @@
             @include('app.patient.point-based-partials.rx')
 
             {{-- devices --}}
-            <?php
-            $availableDevices = count($devices);
-            $patientDeviceIDs = \App\Models\ClientBDTDevice::select('id')->where('client_id', $patient->id)->where('is_active', true)->get()->toArray();
-            $patientDeviceIDs = array_map(function ($_x) {
-                return $_x["id"];
-            }, $patientDeviceIDs);
-            ?>
             <div class="mt-2 pb-1" id="patient-dashboard-devices">
                 <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
                     <h6 class="my-0 font-weight-bold">Devices</h6>
@@ -240,7 +233,6 @@
             @endif
 
             <!-- vitals - point -->
-            <?php $latestVitals = \App\Models\Point::where('client_id', $patient->id)->where('category', 'VITALS')->orderBy('id', 'DESC')->first(); ?>
             <div class="pt-2 mt-2">
                 <div class="d-flex align-items-center pb-2">
                     <h6 class="my-0 font-weight-bold">Vitals

+ 2 - 2
resources/views/app/patient/partials/measurements.blade.php

@@ -9,7 +9,7 @@
     </div>
     <table class="table table-sm border-0 m-0">
         <tbody>
-        @foreach($patient->recentMeasurements as $measurement)
+        @foreach($recentMeasurements as $measurement)
             @if(1 || !empty($measurement->label) && !in_array($measurement->label, $vitalLabels))
                 @if(!in_array($measurement->label, ["SBP", "DBP"]))
                     @if(!empty($measurement->client_bdt_measurement_id))
@@ -44,7 +44,7 @@
                 @endif
             @endif
         @endforeach
-        @if(!$patient->measurements || !count($patient->measurements))
+        @if(!$recentMeasurements || !count($recentMeasurements))
             <tr>
                 <td class="text-secondary p-0 border-0 pl-2">
                     No items to show