Samson Mutunga 3 жил өмнө
parent
commit
e3ae74fd5a

+ 9 - 0
app/Models/ClientBDTDevice.php

@@ -14,4 +14,13 @@ class ClientBDTDevice extends Model
         return $this->hasOne(Client::class, 'id', 'client_id');
         return $this->hasOne(Client::class, 'id', 'client_id');
     }
     }
 
 
+    public function lastDeviceMeasurement() {
+        return BDTMeasurement::select('bdt_measurement.*')
+        ->join('client_bdt_measurement', 'client_bdt_measurement.bdt_measurement_id','=', 'bdt_measurement.id')
+        ->where('client_bdt_measurement.client_id', $this->client_id)
+        ->where('bdt_measurement.imei', $this->device->imei)
+        ->orderBy('bdt_measurement.created_at', 'DESC')
+        ->first();
+    }
+
 }
 }

+ 25 - 4
resources/views/app/patient/devices.blade.php

@@ -51,8 +51,9 @@
                 <thead>
                 <thead>
                 <tr>
                 <tr>
                     <th class="px-2 text-secondary">Created</th>
                     <th class="px-2 text-secondary">Created</th>
-                    <th class="px-2 text-secondary w-25">Category</th>
-                    <th class="px-2 text-secondary w-50">IMEI</th>
+                    <th class="px-2 text-secondary">Category</th>
+                    <th class="px-2 text-secondary">IMEI</th>
+                    <th class="px-2 text-secondary">Last Measurement</th>
                     <th class="px-2 text-secondary"></th>
                     <th class="px-2 text-secondary"></th>
                     <th class="px-2 text-secondary"></th>
                     <th class="px-2 text-secondary"></th>
                 </tr>
                 </tr>
@@ -60,9 +61,29 @@
                 <tbody>
                 <tbody>
                 @foreach($patient->devices as $device)
                 @foreach($patient->devices as $device)
                     <tr>
                     <tr>
-                        <td class="px-2">{{ friendly_date_time($device->device->created_at) }}</td>
+                        <td class="px-2 text-nowrap">{{ friendly_date_time($device->device->created_at) }}</td>
                         <td class="px-2">{{ $device->device->category }}</td>
                         <td class="px-2">{{ $device->device->category }}</td>
                         <td class="px-2"><pre class="m-0">{{ $device->device->imei }}</pre></td>
                         <td class="px-2"><pre class="m-0">{{ $device->device->imei }}</pre></td>
+                        <td class="px-2">
+                            @if($device->lastDeviceMeasurement())
+                                <div>
+                                <i class="far fa-calendar-check"></i> {{ friendly_date_time($device->lastDeviceMeasurement()->created_at) }}
+                                </div>
+                                <?php $measurement = $device->lastDeviceMeasurement(); ?>
+                                @if($measurement->is_cellular_zero)
+                                    <i class="font-size-11 fa fa-rss"></i>
+                                @elseif($measurement->label === 'BP')
+                                    {{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mmHg  <span class="font-weight-normal d-inline-block pl-2">Pulse:</span> {{ $measurement->value_pulse }} {{ $measurement->value_irregular === 0?'Irregular':'' }} {{ $measurement->value_irregular === 1?'Regular':'' }}
+                                @elseif($measurement->label === 'Wt. (lbs.)')
+                                    {{ $measurement->numeric_value }} lbs
+                                @else
+                                    {{ $measurement->value }}
+                                @endif
+                            @else
+                                <small class="text-muted">No</small>
+                            @endif
+                            
+                        </td>
                         <td>
                         <td>
                             <div moe relative>
                             <div moe relative>
                                 <a start show class="on-hover-opaque">Deactivate</a>
                                 <a start show class="on-hover-opaque">Deactivate</a>
@@ -76,7 +97,7 @@
                                 </form>
                                 </form>
                             </div>
                             </div>
                         </td>
                         </td>
-                        <td>
+                        <td class="text-nowrap">
                             @include('app.generic-bills.modal', ['entityType' => 'ClientBDTDevice', 'entityUid' => $device->uid])
                             @include('app.generic-bills.modal', ['entityType' => 'ClientBDTDevice', 'entityUid' => $device->uid])
                         </td>
                         </td>
                     </tr>
                     </tr>