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

Show client's devices in the dashboard

Vijayakrishnan Krishnan 4 жил өмнө
parent
commit
9782714259

+ 3 - 1
app/Http/Controllers/PatientController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers;
 
+use App\Models\BDTDevice;
 use App\Models\CareMonth;
 use App\Models\Client;
 use App\Models\ClientInfoLine;
@@ -18,7 +19,8 @@ class PatientController extends Controller
     {
         $mcpPros = Pro::where('is_enrolled_as_mcp', true)->get();
         $facilities = Facility::where('is_active', true)->get();
-        return view('app.patient.dashboard', compact('patient', 'facilities'));
+        $devices = BDTDevice::where('is_active', true)->get();
+        return view('app.patient.dashboard', compact('patient', 'facilities', 'devices'));
     }
 
     public function actionItems(Request $request, Client $patient )

+ 9 - 0
app/Models/BDTDevice.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace App\Models;
+
+class BDTDevice extends Model
+{
+    protected $table = 'bdt_device';
+
+}

+ 6 - 0
app/Models/Client.php

@@ -89,4 +89,10 @@ class Client extends Model
             ->orderBy('created_at', 'desc');
     }
 
+    public function devices() {
+        return $this->hasMany(ClientBDTDevice::class, 'client_id', 'id')
+            ->where('is_active', true)
+            ->orderBy('created_at', 'desc');
+    }
+
 }

+ 13 - 0
app/Models/ClientBDTDevice.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+
+class ClientBDTDevice extends Model
+{
+    protected $table = 'client_bdt_device';
+
+    public function device() {
+        return $this->hasOne(BDTDevice::class, 'id', 'device_id');
+    }
+
+}

+ 101 - 0
resources/views/app/patient/dashboard.blade.php

@@ -115,6 +115,107 @@
                     </table>
                 </div>
 
+                {{-- devices --}}
+                <div class="mt-2 pb-1">
+                    <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
+                        <h6 class="my-0 font-weight-bold text-secondary">Devices</h6>
+                        <span class="mx-2 text-secondary">|</span>
+                        <span moe>
+                            <a start show>Add</a>
+                            <form url="/api/clientBdtDevice/create" class="mcp-theme-1">
+                                <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                                <div class="mb-2">
+                                    <label class="text-secondary text-sm">Device</label>
+                                    <select name="deviceUid" class="form-control form-control-sm">
+                                        <option value=""> --select-- </option>
+                                        @foreach($devices as $device)
+                                            <option value="{{$device->uid}}">
+                                                {{$device->category}} (IMEI: {{$device->imei}})
+                                            </option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-secondary text-sm">Instructions</label>
+                                    <input type="text" name="instructions" class="form-control form-control-sm">
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-secondary text-sm">Internal Memo</label>
+                                    <input type="text" name="internalMemo" class="form-control form-control-sm">
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-secondary text-sm">Status</label>
+                                    <input type="text" name="status" class="form-control form-control-sm">
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-secondary text-sm">Status Memo</label>
+                                    <input type="text" name="statusMemo" class="form-control form-control-sm">
+                                </div>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                </div>
+                            </form>
+                        </span>
+                    </div>
+                    <table class="table table-sm border-0 my-0 mx-2">
+                        <tbody>
+                        @foreach($patient->devices as $device)
+                            <tr>
+                                <td class="text-black p-0 border-0">
+                                    <div class="pb-0">
+                                        <span relative moe>
+                                            <a class="on-hover-opaque" start show title="Update">
+                                                <i class="font-size-11 fa fa-edit text-primary"></i>
+                                            </a>
+                                            <form url="/api/clientBdtDevice/update">
+                                                <input type="hidden" name="uid" value="{{ $device->uid }}">
+                                                <div class="mb-2">
+                                                    <label class="text-secondary text-sm">Instructions</label>
+                                                    <input type="text" name="instructions"
+                                                           value="{{$device->instructions}}"
+                                                           class="form-control form-control-sm">
+                                                </div>
+                                                <div class="mb-2">
+                                                    <label class="text-secondary text-sm">Internal Memo</label>
+                                                    <input type="text" name="internalMemo"
+                                                           value="{{$device->internal_memo}}"
+                                                           class="form-control form-control-sm">
+                                                </div>
+                                                <div class="mb-2">
+                                                    <label class="text-secondary text-sm">Status</label>
+                                                    <input type="text" name="status"
+                                                           value="{{$device->status}}"
+                                                           class="form-control form-control-sm">
+                                                </div>
+                                                <div class="mb-2">
+                                                    <label class="text-secondary text-sm">Status Memo</label>
+                                                    <input type="text" name="statusMemo"
+                                                           value="{{$device->status_memo}}"
+                                                           class="form-control form-control-sm">
+                                                </div>
+                                                <div>
+                                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                                </div>
+                                            </form>
+                                        </span>
+                                        <b>{{$device->device->category}}</b>&nbsp;/&nbsp;IMEI: {{$device->device->imei}}
+                                    </div>
+                                </td>
+                            </tr>
+                        @endforeach
+                        @if(!$patient->devices || count($patient->devices) === 0)
+                            <tr>
+                                <td class="text-secondary p-0 border-0">
+                                    No devices
+                                </td>
+                            </tr>
+                        @endif
+                        </tbody>
+                    </table>
+                </div>
+
                 {{-- vitals --}}
                 @include('app/patient/partials/vitals')