Sfoglia il codice sorgente

RPM matrix - single row refresh after row actions

Vijayakrishnan 3 anni fa
parent
commit
274a8b3270

+ 49 - 0
app/Http/Controllers/PracticeManagementController.php

@@ -1090,6 +1090,55 @@ WHERE
         return view('app.practice-management.remote-monitoring', compact('patients', 'daysRemaining', 'careMonthStart'));
     }
 
+    public function remoteMonitoring_Row(Request $request) {
+
+        $clientUid = $request->input('clientUid');
+        $careMonthUid = $request->input('careMonthUid');
+
+        $query = "
+SELECT client.name_first, client.name_last,
+       (client.name_first || ' ' || client.name_last) as client_name,
+       client.uid as client_uid, 
+       client.dob,
+       client.is_enrolled_in_rm,
+       client.most_recent_completed_mcp_note_date,
+       client.most_recent_completed_mcp_note_id,
+       mrnote.uid as most_recent_completed_mcp_note_uid,
+       client.cell_number,
+       client.is_assigned_cellular_bp_device,
+       client.is_assigned_cellular_weight_scale_device,
+       care_month.uid as care_month_uid,
+       care_month.id as care_month_id,
+       care_month.start_date,
+       care_month.rm_total_time_in_seconds_by_mcp,
+       care_month.rm_total_time_in_seconds_by_rmm_pro,
+       care_month.number_of_days_with_remote_measurements,
+       care_month.has_mcp_interacted_with_client_about_rm,
+       care_month.rm_num_measurements_not_stamped_by_mcp,
+       care_month.rm_num_measurements_not_stamped_by_non_hcp,
+       care_month.rm_num_measurements_not_stamped_by_rmm,
+       care_month.rm_num_measurements_not_stamped_by_rme,
+       care_month.mcp_pro_id as care_month_mcp_pro_id,
+       care_month.rmm_pro_id as care_month_rmm_pro_id,
+       client.mcp_pro_id,
+       client.default_na_pro_id,
+       client.rmm_pro_id,
+       client.rme_pro_id,
+       client.cell_number,
+       client.most_recent_cellular_bp_dbp_mm_hg,
+       client.most_recent_cellular_bp_sbp_mm_hg,
+       client.most_recent_cellular_bp_measurement_at,      
+       client.most_recent_cellular_weight_value,
+       client.most_recent_cellular_weight_measurement_at
+FROM care_month join client on care_month.client_id = client.id join note mrnote on client.most_recent_completed_mcp_note_id = mrnote.id
+WHERE care_month.uid = '{$careMonthUid}' AND client.uid = '{$clientUid}'
+";
+
+        $patients = DB::select($query);
+
+        return view('app.practice-management.remote-monitoring-row', ['iPatient' => $patients[0]]);
+    }
+
     public function rpm_work_matrix(Request $request) {
 
         // get the patient having most recent unstamped measurement

+ 247 - 0
resources/views/app/practice-management/remote-monitoring-row.blade.php

@@ -0,0 +1,247 @@
+<?php
+
+$mStr = request()->input('m') ? request()->input('m') : date('m');
+$yStr = request()->input('y') ? request()->input('y') : date('Y');
+$rcmStartDate = $yStr . '-' . $mStr . '-' . '01';
+$m = +$mStr;
+$y = +$yStr;
+
+$daysDiff = -1;
+if($iPatient->most_recent_completed_mcp_note_date) {
+    $careMonthLastDay = date_add(date_create($rcmStartDate), date_interval_create_from_date_string("1 month"));
+    $careMonthLastDay = date_sub($careMonthLastDay, date_interval_create_from_date_string("1 day"));
+    $daysDiff = date_diff($careMonthLastDay, date_create($iPatient->most_recent_completed_mcp_note_date))->days;
+}
+$lastVisitWithin90Days = ($daysDiff !== -1 && $daysDiff <= 90);
+
+$performerRole = false;
+if ($pro->pro_type === 'ADMIN') {
+    $performerRole = 'ADMIN';
+} else if ($iPatient->care_month_mcp_pro_id === $pro->id) {
+    $performerRole = 'MCP';
+} else if ($iPatient->care_month_rmm_pro_id === $pro->id) {
+    $performerRole = 'RMM';
+}
+
+?>
+<tr data-client-uid="{{$iPatient->client_uid}}" data-care-month-uid="{{$iPatient->care_month_uid}}">
+    <td class="pl-2">
+        <a href="/patients/view/{{ $iPatient->client_uid }}/care-months/view/{{$iPatient->care_month_uid}}" class="text-nowrap"
+           native target="_blank"
+           open-in-stag-popup
+           update-parent="refresh-rpm-row-{{$trIndex}}"
+           popup-style="tall overflow-visible"
+           mc-initer="care-month-dashboard-{{$iPatient->client_uid}}"
+           title="{{$iPatient->client_name}}"
+        ><span class="sort-data">{{ $iPatient->client_name }}</span></a>
+    </td>
+
+    <td>{{friendly_date($iPatient->dob)}}</td>
+    <td>{!! $iPatient->is_enrolled_in_rm === 'YES' ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>{!! $iPatient->is_assigned_cellular_bp_device ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>{!! $iPatient->is_assigned_cellular_weight_scale_device ? '<i class="fa fa-check text-success"></i>' : 'No' !!}</td>
+    <td>
+        <div class="text-nowrap">
+            <span class="sort-data">{{$iPatient->most_recent_cellular_bp_sbp_mm_hg ?: '-'}}</span>/{{$iPatient->most_recent_cellular_bp_dbp_mm_hg ?: '-'}}
+            @if($iPatient->most_recent_cellular_bp_measurement_at)
+                <span class="text-sm text-secondary text-nowrap ml-1"
+                      title="{{friendly_date_time($iPatient->most_recent_cellular_bp_measurement_at)}}">({{friendly_date($iPatient->most_recent_cellular_bp_measurement_at)}})</span>
+            @endif
+        </div>
+    </td>
+    <td>
+        <div class="text-nowrap">
+            <span class="sort-data">{{$iPatient->most_recent_cellular_weight_value ? round($iPatient->most_recent_cellular_weight_value, 1) : '-'}}</span>
+            @if($iPatient->most_recent_cellular_weight_measurement_at)
+                <span class="text-sm text-secondary text-nowrap ml-1"
+                      title="{{friendly_date_time($iPatient->most_recent_cellular_weight_measurement_at)}}">({{friendly_date($iPatient->most_recent_cellular_weight_measurement_at)}})</span>
+            @endif
+        </div>
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$lastVisitWithin90Days ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+            @if($iPatient->most_recent_completed_mcp_note_uid)
+                <a href = "/patients/view/{{$iPatient->client_uid}}/notes/view/{{$iPatient->most_recent_completed_mcp_note_uid}}">
+                    <span class="sort-data">{{$iPatient->most_recent_completed_mcp_note_date ? friendly_date($iPatient->most_recent_completed_mcp_note_date) : '-'}}</span>
+                </a>
+            @else
+                <span class="sort-data">-</span>
+            @endif
+        </div>
+        {{--@if(!$lastVisitWithin90Days)
+            <div class="text-sm font-italic text-secondary">No visit in over 90 days</div>
+        @endif--}}
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$iPatient->has_mcp_interacted_with_client_about_rm ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+            <span>{{$iPatient->has_mcp_interacted_with_client_about_rm ? 'Yes' : 'No'}}</span>
+            @if($performerRole === 'MCP')
+                <div moe large relative class="ml-2">
+                    <a start show class="py-0 mb-3 text-sm">Edit</a>
+                    <form url="/api/careMonthEntry/createForRm" right hook="refresh-rpm-row-{{$trIndex}}">
+                        <input type="hidden" name="careMonthUid" value="{{ $iPatient->care_month_uid }}">
+                        <input type="hidden" name="proUid" value="{{ $pro->uid }}">
+                        <div class="mb-2">
+                            <div class="row">
+                                <div class="col-6 pr-0">
+                                    <?php
+                                    $sD = strtotime($rcmStartDate);
+                                    $y = date('Y', $sD);
+                                    $m0 = date('m', $sD);
+                                    $d = date('t', $sD);
+                                    $defaultED = $sD >= strtotime(date('Y-m-d')) ? date('Y-m-d') : $rcmStartDate;
+                                    ?>
+                                    <label class="text-sm text-secondary mb-1">Effective Date</label>
+                                    <input autofocus type="date" min="{{ date($y . '-' . $m0 . '-01') }}" max="{{ date($y . '-' . $m0 . '-' . $d) }}"
+                                           value="{{$defaultED}}"
+                                           class="form-control form-control-sm w-100" name="effectiveDate"
+                                           placeholder="Effective Date" required>
+                                </div>
+                                <div class="col-6">
+                                    <label class="text-sm text-secondary mb-1">Seconds</label>
+                                    <input type="number" min="75" max="300" class="form-control form-control-sm w-100 cm-time-value" name="timeInSeconds"
+                                           value="75" placeholder="Time (secs.)" required>
+                                </div>
+                            </div>
+                        </div>
+                        <div class="mb-2 border border-info p-2 mt-2 bg-light">
+                            <span>I have had interactive communication with <b>{{$iPatient->client_name}}</b>.</span>
+                            <div class="d-flex border-top mt-2">
+                                <label class="mt-2 mb-0 d-inline-flex align-items-center mr-3">
+                                    <input type="radio" class="mr-2" name="didProInteractWithClientAboutRm" value="true" required>
+                                    <span>Yes</span>
+                                </label>
+                                <label class="mt-2 mb-0 d-inline-flex align-items-center">
+                                    <input type="radio" class="mr-2" name="didProInteractWithClientAboutRm" value="false" required>
+                                    <span>No</span>
+                                </label>
+                            </div>
+                        </div>
+                        <div class="mb-2">
+                            <label class="text-sm text-secondary mb-1">Memo</label>
+                            <textarea class="form-control form-control-sm w-100" name="contentText"
+                                      required>Interacted with the patient</textarea>
+                        </div>
+                        <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>
+        {{--@if(!$iPatient->has_mcp_interacted_with_client_about_rm)
+            <div class="text-sm font-italic text-secondary">{{$performerRole === 'MCP' ? 'Not' : "MCP hasn't"}} interacted this month!</div>
+        @endif--}}
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            <i class="mr-1 text-sm fa {{$iPatient->number_of_days_with_remote_measurements >= 16 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+            <span class="sort-data">{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</span>
+            @if($iPatient->number_of_days_with_remote_measurements < 16)
+                <div moe relative class="ml-2">
+                    <a href="#" start show class="text-sm">SMS</a>
+                    <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1" noreload="" style="display: none;">
+                        <input type="hidden" name="uid" value="{{ $iPatient->client_uid }}">
+                        <div class="mb-2">
+                            <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
+                            <input type="text" class="form-control form-control-sm" name="cellNumber" value="{{$iPatient->cell_number}}">
+                        </div>
+                        <div class="mb-2">
+                            <label for="" class="text-sm text-secondary mb-1">Message</label>
+                            <textarea rows="5" class="form-control form-control-sm" name="message">Hi! This is {{$pro->displayName(true)}}, from Cardio 1st. Please check your blood pressure.</textarea>
+                        </div>
+                        <div class="d-flex align-items-center">
+                            <button class="btn btn-sm btn-primary mr-2" submit="">Send</button>
+                            <button class="btn btn-sm btn-default mr-2 border" cancel="">Cancel</button>
+                        </div>
+                    </form>
+                </div>
+            @endif
+        </div>
+        {{--@if($iPatient->number_of_days_with_remote_measurements < 16)
+            <div class="text-sm font-italic text-secondary">Meas. days < 16</div>
+        @endif--}}
+    </td>
+    <td>
+        <div class="d-flex align-items-baseline">
+            @if($performerRole === 'MCP')
+                <span class="sort-data">{{$iPatient->rm_num_measurements_not_stamped_by_mcp}}</span>
+                @if($iPatient->rm_num_measurements_not_stamped_by_mcp)
+                    <a href="{{ route('practice-management.rpm_work_matrix') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
+                       native target="_blank"
+                       open-in-stag-popup
+                       update-parent="refresh-rpm-row-{{$trIndex}}"
+                       popup-style="tall overflow-visible"
+                       class="ml-2 text-sm"
+                       mc-initer="rpm-work-matrix"
+                       title="RPM Work Matrix">
+                        View
+                    </a>
+                @endif
+            @elseif($performerRole === 'RMM')
+                <span class="sort-data">{{$iPatient->rm_num_measurements_not_stamped_by_rmm}}</span>
+                @if($iPatient->rm_num_measurements_not_stamped_by_rmm)
+                    <a href="{{ route('practice-management.rpm_work_matrix') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
+                       native target="_blank"
+                       open-in-stag-popup
+                       update-parent="refresh-rpm-row-{{$trIndex}}"
+                       popup-style="tall overflow-visible"
+                       class="ml-2 text-sm"
+                       mc-initer="rpm-work-matrix"
+                       title="RPM Work Matrix">
+                        View
+                    </a>
+                @endif
+            @endif
+        </div>
+    </td>
+    <td>
+        @if($performerRole === 'MCP')
+            <div class="d-flex align-items-baseline">
+                <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_mcp >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+                <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_mcp / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_mcp % 60)}}s</span>
+                <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_mcp}}</span>
+            </div>
+            {{--@if($iPatient->rm_total_time_in_seconds_by_mcp < 1200)
+                <div class="text-sm font-italic text-secondary">Entry mins. < 20</div>
+            @endif--}}
+        @elseif($performerRole === 'RMM')
+            <div class="d-flex align-items-baseline">
+                <i class="mr-1 text-sm fa {{$iPatient->rm_total_time_in_seconds_by_rmm_pro >= 1200 ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+                <span class="text-nowrap">{{round($iPatient->rm_total_time_in_seconds_by_rmm_pro / 60)}}m {{round($iPatient->rm_total_time_in_seconds_by_rmm_pro % 60)}}s</span>
+                <span class="sort-data d-none">{{$iPatient->rm_total_time_in_seconds_by_rmm_pro}}</span>
+            </div>
+            {{--@if($iPatient->rm_total_time_in_seconds_by_rmm_pro < 1200)
+                <div class="text-sm font-italic text-secondary">Entry mins. < 20</div>
+            @endif--}}
+        @endif
+    </td>
+    <td>
+        @if($performerRole === 'MCP')
+            @if($lastVisitWithin90Days && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_mcp >= 1200)
+                <span class="text-success font-weight-bold">
+                                                    <i class="fa fa-check"></i>
+                                                    Yes
+                                                </span>
+            @else
+                <span class="text-danger font-weight-normal">
+                                                    Not yet
+                                                </span>
+            @endif
+        @elseif($performerRole === 'RMM')
+            @if($lastVisitWithin90Days && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_rmm_pro >= 1200)
+                <span class="text-success font-weight-bold">
+                                                    <i class="fa fa-check"></i>
+                                                    Yes
+                                                </span>
+            @else
+                <span class="text-danger font-weight-normal">
+                                                    Not yet
+                                                </span>
+            @endif
+        @endif
+    </td>
+</tr>

+ 41 - 7
resources/views/app/practice-management/remote-monitoring.blade.php

@@ -94,6 +94,7 @@
                             </tr>
                             </thead>
                             <tbody>
+                            <?php $trIndex = 0; ?>
                             @foreach ($patients as $iPatient)
                                 <?php
 
@@ -115,16 +116,16 @@
                                 }
 
                                 ?>
-                                <tr>
+                                <tr data-client-uid="{{$iPatient->client_uid}}" data-care-month-uid="{{$iPatient->care_month_uid}}">
                                     <td class="pl-2">
                                         <a href="/patients/view/{{ $iPatient->client_uid }}/care-months/view/{{$iPatient->care_month_uid}}" class="text-nowrap"
                                            native target="_blank"
                                            open-in-stag-popup
-                                           update-parent
+                                           update-parent="refresh-rpm-row-{{$trIndex}}"
                                            popup-style="tall overflow-visible"
                                            mc-initer="care-month-dashboard-{{$iPatient->client_uid}}"
                                            title="{{$iPatient->client_name}}"
-                                        >{{ $iPatient->client_name }}</a>
+                                        ><span class="sort-data">{{ $iPatient->client_name }}</span></a>
                                     </td>
 
                                     <td>{{friendly_date($iPatient->dob)}}</td>
@@ -171,7 +172,7 @@
                                             @if($performerRole === 'MCP')
                                                 <div moe large relative class="ml-2">
                                                     <a start show class="py-0 mb-3 text-sm">Edit</a>
-                                                    <form url="/api/careMonthEntry/createForRm" right>
+                                                    <form url="/api/careMonthEntry/createForRm" right hook="refresh-rpm-row-{{$trIndex}}">
                                                         <input type="hidden" name="careMonthUid" value="{{ $iPatient->care_month_uid }}">
                                                         <input type="hidden" name="proUid" value="{{ $pro->uid }}">
                                                         <div class="mb-2">
@@ -264,7 +265,7 @@
                                                     <a href="{{ route('practice-management.rpm_work_matrix') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
                                                        native target="_blank"
                                                        open-in-stag-popup
-                                                       update-parent
+                                                       update-parent="refresh-rpm-row-{{$trIndex}}"
                                                        popup-style="tall overflow-visible"
                                                        class="ml-2 text-sm"
                                                        mc-initer="rpm-work-matrix"
@@ -278,7 +279,7 @@
                                                     <a href="{{ route('practice-management.rpm_work_matrix') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
                                                        native target="_blank"
                                                        open-in-stag-popup
-                                                       update-parent
+                                                       update-parent="refresh-rpm-row-{{$trIndex}}"
                                                        popup-style="tall overflow-visible"
                                                        class="ml-2 text-sm"
                                                        mc-initer="rpm-work-matrix"
@@ -336,6 +337,15 @@
                                         @endif
                                     </td>
                                 </tr>
+                                <script>
+                                    addMCHook(
+                                        'refresh-rpm-row-{{$trIndex}}',
+                                        function () {
+                                            refreshRpmRow({{$trIndex}});
+                                        }
+                                    );
+                                </script>
+                                <?php $trIndex++; ?>
                             @endforeach
                             </tbody>
                         </table>
@@ -346,10 +356,34 @@
     </div>
     <script>
         (function() {
+            let dataTableInst = null;
+            window.refreshRpmRow = function(_index) {
+                let tr = $('#table-rm-matrix tbody tr:eq(' + _index + ')');
+                if(!tr.length) return;
+                let clientUid = tr.attr('data-client-uid'), careMonthUid = tr.attr('data-care-month-uid');
+                $.get('/rpm-matrix-row?m={{$mStr}}&y={{$yStr}}&clientUid=' + clientUid + '&careMonthUid=' + careMonthUid, _data => {
+                    let row = $(_data);
+                    row.find('>td').each(function(_columnIndex) {
+                        dataTableInst.cell(_index, _columnIndex).data(this.innerHTML); //.draw();
+                    });
+                    $('#practice-remote-monitoring [moe][initialized]').removeAttr('initialized');
+                    initMoes();
+                });
+            }
             function init() {
-                $('#table-rm-matrix').DataTable({
+                dataTableInst = $('#table-rm-matrix').DataTable({
                     paging: false,
                     columnDefs: [
+                        {
+                            targets: 0,
+                            type: 'string',
+                            render: function (data, type, row, meta) {
+                                if(type === 'sort') {
+                                    return $(data).find('.sort-data').first().text();
+                                }
+                                return data;
+                            },
+                        },
                         {targets: 1, type: 'date'},
                         {
                             targets: 7,

+ 3 - 0
routes/web.php

@@ -615,6 +615,9 @@ Route::middleware('pro.auth')->group(function () {
     // refresh single ticket
     Route::get('/get-ticket/{ticket}', 'HomeController@getTicket');
 
+    // rpm matrix single row
+    Route::get('/rpm-matrix-row', 'PracticeManagementController@remoteMonitoring_Row');
+
 
     Route::get('/appointment-confirmation-history/{appointment}', 'AppointmentController@appointmentConfirmationHistory')->name('appointment-confirmation-history');