Ver Fonte

cellular-device-manager UI updates (wip)

Vijayakrishnan há 3 anos atrás
pai
commit
5235b995b1

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

@@ -572,9 +572,9 @@ class PracticeManagementController extends Controller
         }
         $clients = [];
         if ($targetPro) {
-            $clients = Client::where('mcp_pro_id', $targetPro->id)->orderBy('created_at', 'desc')->paginate(100);
+            $clients = Client::where('mcp_pro_id', $targetPro->id)->orderBy('created_at', 'desc')->paginate(20);
         } else {
-            $clients = Client::orderBy('created_at', 'desc')->paginate(100);
+            $clients = Client::orderBy('created_at', 'desc')->paginate(20);
         }
         return view('app.practice-management.cellular-device-manager', compact('clients', 'targetPro', 'proUid'));
     }

+ 11 - 3
app/Models/Client.php

@@ -346,12 +346,12 @@ class Client extends Model
 
     public function firstCellularBPDevice()
     {
-        $devices = $this->devices();
+        $devices = $this->devices;
         $x = null;
         foreach($devices as $device){
             if($device->device->category == 'BP'){
                 $x = $device;
-                continue;
+                break;
             }
         }
         return $x;
@@ -371,7 +371,15 @@ class Client extends Model
 
     public function firstCellularWeightDevice()
     {
-
+        $devices = $this->devices;
+        $x = null;
+        foreach($devices as $device){
+            if($device->device->category == 'WEIGHT'){
+                $x = $device;
+                break;
+            }
+        }
+        return $x;
     }
 
     public function getFirstCellularWeightMeasurementAt()

+ 117 - 17
resources/views/app/practice-management/cellular-device-manager.blade.php

@@ -35,11 +35,6 @@
                         <col span="4" class="cellular-weight">
                     </colgroup>
                     <thead class="bg-light">
-                    <tr>
-                        <th colspan="7"></th>
-                        <th colspan="4">Cellular BP</th>
-                        <th colspan="4">Cellular Weight</th>
-                    </tr>
                     <tr>
                         <th class="px-3 border-0">Patient</th>
                         <th class="border-0">DOB</th>
@@ -49,15 +44,8 @@
                         <th class="border-0">MC</th>
                         <th class="border-0">MC Part-B</th>
 
-                        <th class="border-0">Sent?</th>
-                        <th class="border-0">First use</th>
-                        <th class="border-0">Last use</th>
-                        <th class="border-0">Total measurements</th>
-
-                        <th class="border-0">Sent?</th>
-                        <th class="border-0">First use</th>
-                        <th class="border-0">Last use</th>
-                        <th class="border-0">Total measurements</th>
+                        <th class="border-0" colspan="4">Cellular BP</th>
+                        <th class="border-0" colspan="4">Cellular Weight</th>
                     </tr>
                     </thead>
                     <tbody>
@@ -76,21 +64,133 @@
                             <td>{{ $client->was_medicare_validation_successful ? 'Yes' : '' }}</td>
                             <td>{{ $client->was_medicare_validation_successful && $client->is_part_b_primary == 'YES' ? 'Yes' : '' }}</td>
 
-                            <td>{{ $client->firstCellularBPDevice() ? 'Yes' : 'No' }}</td>
+                            <td colspan="4">
+                                <?php
+                                $bpDevice = $client->firstCellularBPDevice();
+                                $bpMeasurements = [];
+                                if ($bpDevice) {
+                                    $bpMeasurements["first"] = \App\Models\Measurement
+                                        ::where('imei', $bpDevice->device->imei)
+                                        ->where('client_id', $client->id)
+                                        ->where('is_cellular_zero', false)
+                                        ->orderBy('ts')
+                                        ->first();
+                                    $bpMeasurements["last"] = \App\Models\Measurement
+                                        ::where('imei', $bpDevice->device->imei)
+                                        ->where('client_id', $client->id)
+                                        ->where('is_cellular_zero', false)
+                                        ->orderBy('ts', 'DESC')
+                                        ->first();
+                                }
+                                ?>
+                                @if($bpDevice)
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">IMEI:</span>
+                                        <span class="ml-3">{{$bpDevice->device->imei}}</span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Sent:</span>
+                                        <span class="ml-3">Yes</span>*
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Arrived:</span>
+                                        <span class="ml-3">Yes</span>*
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">First Use:</span>
+                                        @if(@$bpMeasurements["first"])
+                                            <span class="ml-3">{{ $bpMeasurements["first"]->sbp_mm_hg . '/' . $bpMeasurements["first"]->dbp_mm_hg . ' mmHg' }}</span>
+                                            <span class="ml-3 text-secondary">{{date("Y-m-d", $bpMeasurements["first"]->ts/1000)}}</span>
+                                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $bpMeasurements["first"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Last Use:</span>
+                                        @if(@$bpMeasurements["last"])
+                                            <span class="ml-3">{{ $bpMeasurements["last"]->sbp_mm_hg . '/' . $bpMeasurements["last"]->dbp_mm_hg . ' mmHg' }}</span>
+                                            <span class="ml-3 text-secondary">{{date("Y-m-d", $bpMeasurements["last"]->ts/1000)}}</span>
+                                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $bpMeasurements["last"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                @endif
+                            </td>
+
+                            <td colspan="4">
+                                <?php
+                                $weightScale = $client->firstCellularWeightDevice();
+                                $weightMeasurements = [];
+                                if ($weightScale) {
+                                    $weightMeasurements["first"] = \App\Models\Measurement
+                                        ::where('imei', $weightScale->device->imei)
+                                        ->where('client_id', $client->id)
+                                        ->where('is_cellular_zero', false)
+                                        ->orderBy('ts')
+                                        ->first();
+                                    $weightMeasurements["last"] = \App\Models\Measurement
+                                        ::where('imei', $weightScale->device->imei)
+                                        ->where('client_id', $client->id)
+                                        ->where('is_cellular_zero', false)
+                                        ->orderBy('ts', 'DESC')
+                                        ->first();
+                                }
+                                ?>
+                                @if($weightScale)
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">IMEI:</span>
+                                        <span class="ml-3">{{$weightScale->device->imei}}</span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Sent:</span>
+                                        <span class="ml-3">Yes</span>*
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Arrived:</span>
+                                        <span class="ml-3">Yes</span>*
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">First Use:</span>
+                                        @if($weightMeasurements["first"])
+                                            <span class="ml-3">{{ round($weightMeasurements["first"]->value, 2) . ' lbs' }}</span>
+                                            <span class="ml-3 text-secondary">{{date("Y-m-d", $weightMeasurements["first"]->ts/1000)}}</span>
+                                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $weightMeasurements["first"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Last Use:</span>
+                                        @if($weightMeasurements["last"])
+                                            <span class="ml-3">{{ round($weightMeasurements["last"]->value, 2) . ' lbs' }}</span>
+                                            <span class="ml-3 text-secondary">{{date("Y-m-d", $weightMeasurements["last"]->ts/1000)}}</span>
+                                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $weightMeasurements["last"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                @endif
+                            </td>
+
+                            {{--
+                            <td>{{ $client->firstCellularBPDevice() ? 'Yes' : '' }}</td>
                             <td>{{ $client->getFirstCellularBPMeasurementAt()  }}</td>
                             <td>{{ $client->getLatestCellularBPMeasurementAt() }}</td>
                             <td>{{ $client->getTotalCellularBPMeasurements() }}</td>
 
-                            <td>{{ $client->firstCellularWeightDevice() ? 'Yes' : 'No' }}</td>
+                            <td>{{ $client->firstCellularWeightDevice() ? 'Yes' : '' }}</td>
                             <td>{{ $client->getFirstCellularWeightMeasurementAt()  }}</td>
                             <td>{{ $client->getLatestCellularWeightMeasurementAt() }}</td>
                             <td>{{ $client->getTotalCellularWeightMeasurements() }}</td>
+                            --}}
 
                         </tr>
                     @endforeach
                     </tbody>
                 </table>
-                <div>
+                <div class="border-top px-3 pt-3">
                     {{$clients->links()}}
                 </div>
             </div>