瀏覽代碼

RM Setup logic/UI fixes

Vijayakrishnan 3 年之前
父節點
當前提交
d4e8ddb11c

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

@@ -337,7 +337,23 @@ class PatientController extends Controller
 
     public function rmSetup(Request $request, Client $patient)
     {
-        return view('app.patient.rm-setup', compact('patient'));
+
+        // get assigned devices
+        $assignedDeviceIDs = DB::select(DB::raw("SELECT device_id from client_bdt_device where is_active = true"));
+        $assignedDeviceIDs = array_map(function($_x) {
+            return $_x->device_id;
+        }, $assignedDeviceIDs);
+
+        // get all except assigned ones
+        $devices = BDTDevice::where('is_active', true)
+            ->whereNotIn('id', $assignedDeviceIDs)
+            ->orderBy('imei', 'asc')
+            ->get();
+
+        $assignedDeviceIDs = null;
+        unset($assignedDeviceIDs);
+
+        return view('app.patient.rm-setup', compact('patient', 'devices'));
     }
 
     public function handouts(Request $request, Client $patient )

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

@@ -1070,7 +1070,7 @@ use App\Models\Handout;
 
                 <div class="row border-bottom mx-0">
                     <div class="col-12 px-0">
-                        <div class="p-3 screen-only h-100" data-non-segment-section="RM Setup">
+                        <div class="p-3 screen-only h-100" data-non-segment-section="Remote Monitoring">
                             <div class="d-flex align-items-center mb-3">
                                 <p class="font-weight-bold text-secondary m-0 font-size-14">Remote Monitoring</p>
                             </div>

+ 1 - 1
resources/views/app/patient/note/lhs-tree.blade.php

@@ -51,7 +51,7 @@
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Prescriptions" href="#">ERx &amp; Orders</a></div>
     @endif
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Incoming Reports" href="#">Incoming Reports</a></div>
-    <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="RM Setup" href="#">RM Setup</a></div>
+    <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Remote Monitoring" href="#">Remote Monitoring</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Supply Orders Summary" href="#">Supply Orders Summary</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="Vitals Settings" href="#">Vitals Settings</a></div>
     <div class="note-tree-node"><a native="" target="_top" data-non-segment-target="ICDs" href="#">ICDs</a></div>

+ 3 - 1
resources/views/app/patient/note/partials/care-plan-details.blade.php

@@ -1,3 +1,4 @@
+@if(@$note)
 <table class="table-sm table-bordered v-top">
     <tr>
         <td class="text-secondary">Care Plan:</td>
@@ -97,4 +98,5 @@
             </div>
         </td>
     </tr>
-</table>
+</table>
+@endif

+ 126 - 257
resources/views/app/patient/note/rm-setup.blade.php

@@ -1,120 +1,141 @@
 <div class="row" id="rm-setup">
     <div class="col-7">
-        @if($pro->pro_type === 'ADMIN')
-            <div class="mb-2">
-                <div class="d-flex flex-wrap">
-                    <div class="d-flex align-items-center">
-                        <span class="mr-2 text-secondary">Eligible for RM?</span>
-                        <span class="mr-1">{{ ucwords($patient->is_eligible_for_rm ? $patient->is_eligible_for_rm : '-') }}</span>
-                        <div moe class="">
+        <div class="mb-2">
+            <div class="d-flex flex-wrap">
+                <div class="d-flex align-items-center">
+                    <span class="mr-2 text-secondary">Eligible for RM?</span>
+                    <span class="mr-1">{{ ucwords($patient->is_eligible_for_rm ? $patient->is_eligible_for_rm : '-') }}</span>
+                    <div moe class="">
+                        <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                        <form url="/api/client/updateRmEligibility" class="mcp-theme-1">
+                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                            <div class="mb-2">
+                                <label class="text-sm mb-1 text-secondary">Is Eligible?</label>
+                                <select name="isEligibleForRm"
+                                        class="form-control form-control-sm"
+                                        onchange="toggleDisabledAsNeeded(this, 'NO', 'not-eligible-for-rm')">
+                                    <option value="">-- Select Status --</option>
+                                    <option value="YES" {{ $patient->is_eligible_for_rm === 'YES' ? 'selected' : '' }}>YES</option>
+                                    <option value="NO" {{ $patient->is_eligible_for_rm === 'NO' ? 'selected' : '' }}>NO</option>
+                                    <option value="UNKNOWN" {{ $patient->is_eligible_for_rm === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
+                                </select>
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-sm mb-1 text-secondary">Why not eligible category</label>
+                                <input type="text" class="not-eligible-for-rm form-control form-control-sm"
+                                    {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
+                                    name="whyNotEligibleForRmCategory" value="{{$patient->why_not_eligible_for_rm_category}}">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-sm mb-1 text-secondary">Why not eligible memo</label>
+                                <input type="text" class="not-eligible-for-rm form-control form-control-sm"
+                                    {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
+                                    name="whyNotEligibleForRmMemo" value="{{$patient->why_not_eligible_for_rm_memo}}">
+                            </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>
+                    </div>
+                    @if($patient->is_eligible_for_rm === 'NO')
+                    <span class="ml-1 on-hover-show d-inline-block on-hover-opaque">
+                        <i class="fa fa-info-circle"></i>
+                        <div class="on-hover-content py-2 pl-3 text-nowrap text-dark" style="left:0;right:auto;">
+                            <div>
+                                <small class="text-sm"><b>Category:</b> {{$patient->why_not_eligible_for_rm_category ?: '-'}}</small>
+                            </div>
+                            <div>
+                                <small class="text-sm"><b>Memo:</b> {{$patient->why_not_eligible_for_rm_memo ?: '-'}}</small>
+                            </div>
+                        </div>
+                    </span>
+                    @endif
+                </div>
+                <span class="text-secondary mx-2">|</span>
+                <?php $currentCareMonth = $patient->currentCareMonth(); ?>
+                @if($currentCareMonth && $pro->id === $currentCareMonth->mcp_pro_id)
+                <?php $spoken = $currentCareMonth->has_anyone_interacted_with_client_about_rm_outside_note; ?>
+                {{--
+                <div class="d-flex align-items-center">
+                    <span class="mr-1 text-secondary">Comm. this month:</span>
+                    <span class="{{$spoken ? 'text-success' : ''}}">
+                        {{$spoken ? 'Yes' : 'No'}}
+                        @if(!$spoken)
+                            <i class="fa fa-exclamation-triangle"></i>
+                        @else
+                            <i class="fa fa-check"></i>
+                        @endif
+                    </span>
+                    @if($currentCareMonth->mcp && $pro->id === $currentCareMonth->mcp->id)
+                        <div moe relative class="ml-1">
+                            <a href="#" start show class=""><i class="fa fa-edit on-hover-opaque"></i></a>
+                            <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
+                                <input type="hidden" name="uid" value="{{$currentCareMonth->uid}}">
+                                <p>Set to {{$spoken ? 'No' : 'Yes'}}?</p>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @endif
+                </div>
+                <span class="text-secondary mx-2 d-xlarge">|</span>--}}
+                @endif
+
+                <div class="d-flex align-items-center">
+                    <span class="mr-1 text-secondary">Enrollment:</span>
+                    <span>{{ ucwords($patient->is_enrolled_in_rm ? $patient->is_enrolled_in_rm : '-') }}</span>
+                    @if($patient->is_enrolled_in_rm === 'YES')
+                        <div moe class="ml-1">
                             <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
-                            <form url="/api/client/updateRmEligibility" class="mcp-theme-1">
+                            <form url="/api/client/setIsEnrolledInRmToFalse" class="mcp-theme-1">
                                 <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                <div class="mb-2">
-                                    <label class="text-sm mb-1 text-secondary">Is Eligible?</label>
-                                    <select name="isEligibleForRm"
-                                            class="form-control form-control-sm"
-                                            onchange="toggleDisabledAsNeeded(this, 'NO', 'not-eligible-for-rm')">
-                                        <option value="">-- Select Status --</option>
-                                        <option value="YES" {{ $patient->is_eligible_for_rm === 'YES' ? 'selected' : '' }}>YES</option>
-                                        <option value="NO" {{ $patient->is_eligible_for_rm === 'NO' ? 'selected' : '' }}>NO</option>
-                                        <option value="UNKNOWN" {{ $patient->is_eligible_for_rm === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
-                                    </select>
-                                </div>
-                                <div class="mb-2">
-                                    <label class="text-sm mb-1 text-secondary">Why not eligible category</label>
-                                    <input type="text" class="not-eligible-for-rm form-control form-control-sm"
-                                        {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
-                                        name="whyNotEligibleForRmCategory" value="{{$patient->why_not_eligible_for_rm_category}}">
-                                </div>
-                                <div class="mb-2">
-                                    <label class="text-sm mb-1 text-secondary">Why not eligible memo</label>
-                                    <input type="text" class="not-eligible-for-rm form-control form-control-sm"
-                                        {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
-                                        name="whyNotEligibleForRmMemo" value="{{$patient->why_not_eligible_for_rm_memo}}">
-                                </div>
+                                <p>Un-enroll from RPM?</p>
                                 <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>
                         </div>
-                        @if($patient->is_eligible_for_rm === 'NO')
-                        <span class="ml-1 on-hover-show d-inline-block on-hover-opaque">
-                            <i class="fa fa-info-circle"></i>
-                            <div class="on-hover-content py-2 pl-3 text-nowrap text-dark" style="left:0;right:auto;">
-                                <div>
-                                    <small class="text-sm"><b>Category:</b> {{$patient->why_not_eligible_for_rm_category ?: '-'}}</small>
-                                </div>
-                                <div>
-                                    <small class="text-sm"><b>Memo:</b> {{$patient->why_not_eligible_for_rm_memo ?: '-'}}</small>
+                    @else
+                        <div moe wide class="ml-2">
+                            <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                            <form url="/api/client/setIsEnrolledInRmToTrue" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                <h2>RPM Enrollment:</h2>
+                                <h3>Please confirm the following with patient:</h3>
+                                <p class="mb-2">I understand that:</p>
+                                <ul style="list-style:none;" class="pl-2">
+                                    <li class="d-flex mb-1">
+                                        <input type="checkbox" required="true" class="mt-1 mr-2" id="x" name="x">
+                                        <label class="c-pointer" for="x">I am the only person who should be using the remote monitoring equipment as instructed. I will
+                                            not use the device for reasons other than my own personal health monitoring. I understand that
+                                            I can only participate in this program with one Medical Provider at a time.</label>
+                                    </li>
+                                    <li class="d-flex mb-1">
+                                        <input type="checkbox" required="true" class="mt-1 mr-2" id="y" name="y">
+                                        <label class="c-pointer" for="y">I will not tamper with the equipment. I understand that I am responsible for any fees associated
+                                            with misuse of the equipment.</label>
+                                    </li>
+                                    <li class="d-flex mb-1">
+                                        <input type="checkbox" required="true" class="mt-1 mr-2" id="z" name="z">
+                                        <label class="c-pointer" for="z">I understand the devices are only designed for the RPM program.</label>
+                                    </li>
+                                </ul>
+
+                                <div class="mb-2">
+                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
                                 </div>
-                            </div>
-                        </span>
-                        @endif
-                    </div>
-                    <span class="text-secondary mx-2">|</span>
-                    <?php $currentCareMonth = $patient->currentCareMonth(); ?>
-                    @if($currentCareMonth && $pro->id === $currentCareMonth->mcp_pro_id)
-                    <?php $spoken = $currentCareMonth->has_anyone_interacted_with_client_about_rm_outside_note; ?>
-                    <div class="d-flex align-items-center">
-                        <span class="mr-1 text-secondary">Comm. this month:</span>
-                        <span class="{{$spoken ? 'text-success' : ''}}">
-                            {{$spoken ? 'Yes' : 'No'}}
-                            @if(!$spoken)
-                                <i class="fa fa-exclamation-triangle"></i>
-                            @else
-                                <i class="fa fa-check"></i>
-                            @endif
-                        </span>
-                        @if($currentCareMonth->mcp && $pro->id === $currentCareMonth->mcp->id)
-                            <div moe relative class="ml-1">
-                                <a href="#" start show class=""><i class="fa fa-edit on-hover-opaque"></i></a>
-                                <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
-                                    <input type="hidden" name="uid" value="{{$currentCareMonth->uid}}">
-                                    <p>Set to {{$spoken ? 'No' : 'Yes'}}?</p>
-                                    <div class="d-flex align-items-center">
-                                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                                    </div>
-                                </form>
-                            </div>
-                        @endif
-                    </div>
-                    <span class="text-secondary mx-2 d-xlarge">|</span>
+                            </form>
+                        </div>
                     @endif
-
-                    <div class="d-flex align-items-center">
-                        <span class="mr-1 text-secondary">Enrollment:</span>
-                        <span>{{ ucwords($patient->is_enrolled_in_rm ? $patient->is_enrolled_in_rm : '-') }}</span>
-                        @if($patient->is_enrolled_in_rm === 'YES')
-                            <div moe class="ml-1">
-                                <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
-                                <form url="/api/client/setIsEnrolledInRmToFalse" class="mcp-theme-1">
-                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                    <p>Un-enroll from RPM?</p>
-                                    <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>
-                            </div>
-                        @else
-                            <a native target="_blank"
-                            class="screen-only ml-2"
-                            open-in-stag-popup
-                            popup-style="medium overflow-visible"
-                            mc-initer="rpm-agreement-{{$note->id}}"
-                            title="Leadership Health Remote Patient Monitoring Consent Form"
-                            href="/note/rpm-agreement/{{$note->uid}}?popupmode=1">
-                                Mark as enrolled
-                            </a>
-                        @endif
-                    </div>
                 </div>
-
             </div>
-        @endif
+
+        </div>
 
         <div class="d-flex align-items-baseline mb-1">
             <div class="flex-grow-1">
@@ -318,164 +339,12 @@
                 </table>
             </div>
         @endif
-        <div class="border-top mt-1 pt-2">
+        {{--<div class="border-top mt-1 pt-2">
             @include('app.patient.partials.client_bp_weight_phone_number_status')
-        </div>
+        </div>--}}
 
     </div>
-    <div class="col-5 border-left">
-        <?php
-        $bpDevice = null;
-        $weightScale = null;
-        if(count($patient->devices)) {
-            foreach($patient->devices as $device) {
-                if(!$bpDevice && $device->device->category === 'BP') {
-                    $bpDevice = $device;
-                }
-                elseif(!$weightScale && $device->device->category === 'WEIGHT') {
-                    $weightScale = $device;
-                }
-                if($bpDevice && $weightScale) break;
-            }
-        }
-        $bpMeasurements = [];
-        if($bpDevice) {
-            $bpMeasurements["first"] = \App\Models\Measurement
-                ::where('imei', $bpDevice->device->imei)
-                ->where('client_id', $patient->id)
-                ->where('is_cellular_zero', false)
-                ->orderBy('ts')
-                ->first();
-            $bpMeasurements["last"] = \App\Models\Measurement
-                ::where('imei', $bpDevice->device->imei)
-                ->where('client_id', $patient->id)
-                ->where('is_cellular_zero', false)
-                ->orderBy('ts', 'DESC')
-                ->first();
-        }
-        $weightMeasurements = [];
-        if($weightScale) {
-            $weightMeasurements["first"] = \App\Models\Measurement
-                ::where('imei', $weightScale->device->imei)
-                ->where('client_id', $patient->id)
-                ->where('is_cellular_zero', false)
-                ->orderBy('ts')
-                ->first();
-            $weightMeasurements["last"] = \App\Models\Measurement
-                ::where('imei', $weightScale->device->imei)
-                ->where('client_id', $patient->id)
-                ->where('is_cellular_zero', false)
-                ->orderBy('ts', 'DESC')
-                ->first();
-        }
-        $careMonth = $patient->currentCareMonth();
-        ?>
-
-        @if($bpDevice)
-            <div class="mb-2">
-                <table class="table table-sm table-bordered mb-0">
-                    <tr class="bg-light">
-                        <td class="text-secondary" style="width: 125px;">Cellular BP Device</td>
-                        <td colspan="2">Yes <i>({{$bpDevice->device->imei}})</i></td>
-                    </tr>
-                    <tr>
-                        <td class="text-secondary">Arrived</td>
-                        <td colspan="2">Yes</td>
-                    </tr>
-                    <tr>
-                        <td class="text-secondary">First Meas.</td>
-                        @if($bpMeasurements["first"])
-                        <td class="">{{ $bpMeasurements["first"]->sbp_mm_hg . '/' . $bpMeasurements["first"]->dbp_mm_hg . '' }}</td>
-                        <td class="">{{friendly_date_short(date("Y-m-d", $bpMeasurements["first"]->ts/1000))}} <i class="text-muted">- {{date_diff(date_create(date("Y-m-d", $bpMeasurements["first"]->ts/1000)), date_create('now'))->days}} <small class="text-sm">days ago</small></i></td>
-                        @else
-                            <td colspan="3">-</td>
-                        @endif
-                    </tr>
-                    <tr>
-                        <td class="text-secondary">Last Meas.</td>
-                        @if($bpMeasurements["last"])
-                            <td>{{ $bpMeasurements["last"]->sbp_mm_hg . '/' . $bpMeasurements["last"]->dbp_mm_hg . '' }}</td>
-                            <td>{{friendly_date_short(date("Y-m-d", $bpMeasurements["last"]->ts/1000))}} <i class="text-muted">- {{date_diff(date_create(date("Y-m-d", $bpMeasurements["last"]->ts/1000)), date_create('now'))->days}} <small class="text-sm">days ago</small></i></td>
-                        @else
-                           <td colspan="3">-</td>
-                        @endif
-                    </tr>
-                    {{--
-                    <tr>
-                        <td class="text-secondary">How often to measure</td>
-                        <td colspan="2">-</td>
-                    </tr>
-                    <tr>
-                        <td class="text-secondary">SMS reminders</td>
-                        <td colspan="2">-</td>
-                    </tr>
-                    --}}
-                </table>
-            </div>
-        @else
-            <div class="d-flex align-items-baseline mb-3">
-                <span class="min-width-200px">Cellular BP Device</span>
-                <b class="ml-3">No</b>
-            </div>
-        @endif
-
-        @if($weightScale)
-            <div class="mb-2">
-            <table class="table table-sm table-bordered mb-0">
-                <tr class="bg-light">
-                    <td class="text-secondary">Cellular Wt. Scale</td>
-                    <td colspan="3">Yes <i>({{$weightScale->device->imei}})</i></td>
-                </tr>
-                <tr>
-                    <td class="text-secondary">Arrived</td>
-                    <td colspan="3">Yes</td>
-                </tr>
-                <tr>
-                    <td class="text-secondary">First Meas.</td>
-                    @if($weightMeasurements["first"])
-                        <td>{{ round($weightMeasurements["first"]->value, 2) . ' lbs' }}</td>
-                        <td colspan="2">{{ friendly_date_short(date("Y-m-d", $weightMeasurements["first"]->ts/1000)) }} <i class="text-muted">- {{date_diff(date_create(date("Y-m-d", $weightMeasurements["first"]->ts/1000)), date_create('now'))->days}} <small class="text-asm">days ago</small></i></td>
-                    @else
-                        <td colspan="4"></td>
-                    @endif
-                </tr>
-                <tr>
-                        <td class="text-secondary">Last Meas.</td>
-                        @if($weightMeasurements["last"])
-                            <td>{{ round($weightMeasurements["last"]->value, 2) . ' lbs' }}</td>
-                            <td>{{ friendly_date_short(date("Y-m-d", $weightMeasurements["last"]->ts/1000)) }} <i class="text-muted">- {{date_diff(date_create(date("Y-m-d", $weightMeasurements["last"]->ts/1000)), date_create('now'))->days}} <small class="text-sm">days ago</small></i></td>
-                        @else
-                            <td colspan="4">-</td>
-                        @endif
-                    </tr>
-                    {{--
-                    <tr>
-                        <td class="text-secondary">How often to measure</td>
-                        <td colspan="3">-</td>
-                    </tr>
-                    <tr>
-                        <td class="text-secondary">SMS reminders:</td>
-                        <td colspan="3">-</td>
-                    </tr>
-                    --}}
-            </table>
-            </div>
-        @else
-            <div class="d-flex align-items-baseline mb-3">
-                <span class="min-width-200px">Cellular Weight Scale</span>
-                <b class="ml-3">No</b>
-            </div>
-        @endif
 
-        @if($careMonth && ($bpDevice || $weightScale))
-            <div class="d-flex align-items-baseline mb-1">
-                <span class="min-width-200px">Measurement days this month:</span>
-                <div class="ml-3">
-                    <b>{{$careMonth->number_of_days_with_remote_measurements}} days</b>
-                </div>
-            </div>
-        @endif
-    </div>
 </div>
 <script>
     (function () {

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

@@ -251,9 +251,9 @@
                 @endif
             </div>
         @endif
-        <div class="border-top mt-2 pt-2">
+        {{--<div class="border-top mt-2 pt-2">
             @include('app.patient.partials.client_bp_weight_phone_number_status')
-        </div>
+        </div>--}}
     </div>
     <div class="col-5 border-left">
         <?php

+ 168 - 2
resources/views/app/patient/rm-setup.blade.php

@@ -2,7 +2,173 @@
 
 @section('inner-content')
 
-    <h4 class="font-weight-bold mb-3" id="rm-setup">RM Setup</h4>
+    <h4 class="font-weight-bold mb-3" id="rm-setup">Remote Monitoring</h4>
 
-    @include('app.patient.partials.rm-setup')
+    @include('app.patient.note.rm-setup')
+
+    <hr>
+
+    <link href="/select2/select2.min.css" rel="stylesheet" />
+    <script src="/select2/select2.min.js"></script>
+    <div id="patient-devices">
+        <div class="d-flex align-items-center pb-2">
+            <h4 class="font-weight-bold">Devices</h4>
+            @if(count($devices) && $pro->pro_type === 'ADMIN')
+                <span class="mx-2 text-secondary">|</span>
+                <div 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->imei}} ({{$device->category}})
+                                    </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>
+                </div>
+            @endif
+        </div>
+        <table class="table table-striped table-sm table-bordered mb-0">
+            @if($patient->devices && count($patient->devices))
+                <thead class="bg-light">
+                <tr>
+                    <th class="border-0 text-secondary">Created</th>
+                    <th class="border-0 text-secondary">Category</th>
+                    <th class="border-0 text-secondary">IMEI</th>
+                    <th class="border-0 text-secondary">Last Measurement</th>
+                    <th class="border-0 text-secondary"></th>
+                    <th class="border-0 text-secondary"></th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($patient->devices as $device)
+                    <tr>
+                        <td class="text-nowrap">{{ friendly_date_time($device->device->created_at) }}</td>
+                        <td>{{ $device->device->category }}</td>
+                        <td><pre class="m-0">{{ $device->device->imei }}</pre></td>
+                        <td>
+                            <?php $lastMeasurement = $device->lastDeviceMeasurement(); ?>
+                            @if($lastMeasurement)
+                                @if($lastMeasurement->is_cellular_zero)
+                                    <i class="font-size-11 fa fa-rss"></i>
+                                @elseif($lastMeasurement->label === 'BP')
+                                    {{ $lastMeasurement->sbp_mm_hg }} / {{ $lastMeasurement->dbp_mm_hg }}
+                                @elseif($lastMeasurement->label === 'Wt. (lbs.)')
+                                    {{ round($lastMeasurement->numeric_value, 2) }} lbs
+                                @else
+                                    {{ $lastMeasurement->value }}
+                                @endif
+                                <div>
+                                    <i class="far fa-calendar-check"></i> <span class="text-secondary">{{ friendly_date_time($lastMeasurement->created_at) }}</span>
+                                </div>
+                            @else
+                                <small class="text-muted">-</small>
+                            @endif
+                        </td>
+                        <td>
+                            <div moe relative>
+                                <a start show class="on-hover-opaque">Deactivate</a>
+                                <form url="/api/clientBdtDevice/deactivate" right>
+                                    <input type="hidden" name="uid" value="{{ $device->uid }}">
+                                    <p class="small">Are you sure you want to deactivate this device?</p>
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-danger mr-2" submit>Deactivate</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                        <td class="text-nowrap">
+                            @include('app.generic-bills.modal', ['entityType' => 'ClientBDTDevice', 'entityUid' => $device->uid])
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            @else
+                <tbody>
+                <tr>
+                    <td class="text-secondary p-3">No active devices for this patient</td>
+                </tr>
+                </tbody>
+            @endif
+        </table>
+        <hr>
+        <h2>Deactivated Devices</h2>
+        <table class="table table-striped table-sm table-bordered mb-0">
+            @if($patient->deactivatedDevices && count($patient->deactivatedDevices))
+                <thead class="bg-light">
+                <tr>
+                    <th class="border-0 text-secondary">Created</th>
+                    <th class="border-0 text-secondary w-25">Category</th>
+                    <th class="border-0 text-secondary w-50">IMEI</th>
+                    <th class="border-0 text-secondary"></th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($patient->deactivatedDevices as $deactivatedDevice)
+                    <tr>
+                        <td>{{ friendly_date_time($deactivatedDevice->device->created_at) }}</td>
+                        <td>{{ $deactivatedDevice->device->category }}</td>
+                        <td><pre class="m-0">{{ $deactivatedDevice->device->imei }}</pre></td>
+                        <td>
+                            <div moe relative>
+                                <a start show class="on-hover-opaque">Reactivate</a>
+                                <form url="/api/clientBdtDevice/reactivate" right>
+                                    <input type="hidden" name="uid" value="{{ $deactivatedDevice->uid }}">
+                                    <p class="small">Are you sure you want to reactivate this device?</p>
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-danger mr-2" submit>Reactivate</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            @else
+                <tbody>
+                <tr>
+                    <td class="text-secondary p-3">No deactivated devices for this patient</td>
+                </tr>
+                </tbody>
+            @endif
+        </table>
+    </div>
+    <script>
+        (function() {
+            function init() {
+                $('select[name="deviceUid"]').select2({
+                    width: '100%'
+                });
+            }
+            addMCInitializer('patient-devices', init, '#patient-devices');
+        }).call(window);
+    </script>
 @endsection

+ 1 - 4
resources/views/layouts/patient.blade.php

@@ -59,9 +59,6 @@ $isOldClient = (date_diff(date_create(config('app.point_impl_date')), date_creat
 					<li class="nav-item">
 						<a class="nav-link {{ strpos($routeName, 'patients.view.care-months') === 0 ? 'active' : '' }}" href="{{ route('patients.view.care-months', ['patient' => $patient]) }}">Care Months</a>
 					</li>
-					<li class="nav-item">
-						<a class="nav-link {{ strpos($routeName, 'patients.view.devices') === 0 ? 'active' : '' }}" href="{{ route('patients.view.devices', ['patient' => $patient]) }}">Devices</a>
-					</li>
 					<li class="nav-item">
 						<a class="nav-link {{ strpos($routeName, 'patients.view.measurements') === 0 ? 'active' : '' }}" href="{{ route('patients.view.measurements', ['patient' => $patient]) }}">Measurements</a>
 					</li>
@@ -75,7 +72,7 @@ $isOldClient = (date_diff(date_create(config('app.point_impl_date')), date_creat
 						<a class="nav-link {{ strpos($routeName, 'patients.view.handouts') === 0 ? 'active' : '' }}" href="{{ route('patients.view.handouts', ['patient' => $patient]) }}">Handouts</a>
 					</li>
 					<li class="nav-item">
-						<a class="nav-link {{ strpos($routeName, 'patients.view.rm-setup') === 0 ? 'active' : '' }}" href="{{ route('patients.view.rm-setup', ['patient' => $patient]) }}">RM Setup</a>
+						<a class="nav-link {{ strpos($routeName, 'patients.view.rm-setup') === 0 ? 'active' : '' }}" href="{{ route('patients.view.rm-setup', ['patient' => $patient]) }}">Remote Monitoring</a>
 					</li>
 					<?php /* <li class="nav-item">
 							<a class="nav-link d-flex align-items-center {{ strpos($routeName, 'patients.view.action-items') === 0 ? 'active' : '' }}"