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

Merge branch 'dev' of rav.triplestart.com:jmudaka/stagfe2 into dev

= 3 жил өмнө
parent
commit
0e5dd78a41

+ 51 - 1
app/Http/Controllers/PracticeManagementController.php

@@ -1046,6 +1046,7 @@ SELECT client.name_first, client.name_last,
        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,
@@ -1072,7 +1073,7 @@ SELECT client.name_first, client.name_last,
        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
+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.mcp_pro_id = {$performer->pro->id} OR care_month.rmm_pro_id = {$performer->pro->id})
       AND EXTRACT(MONTH from care_month.start_date) = " . ($request->input('m') ?: 'EXTRACT(MONTH from now())') . "
@@ -1089,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], 'trIndex' => $request->input('trIndex')]);
+    }
+
     public function rpm_work_matrix(Request $request) {
 
         // get the patient having most recent unstamped measurement

+ 1 - 1
config/app.php

@@ -65,7 +65,7 @@ return [
 
     'hrm2_url' => env('HRM2_URL'),
 
-    'asset_version' => 53,
+    'asset_version' => 54,
 
     'temp_dir' => env('TEMP_DIR'),
 

+ 3 - 0
js-dev/mc-init.js

@@ -64,6 +64,9 @@ window.addMCHook = function(_name, _func) {
         func: _func
     };
 };
+window.hasMCHook = function(_initer) {
+    return !!mcHooks && !!mcHooks[_initer];
+}
 window.runMCHook = function(_initer) {
     if(!!mcHooks && !!mcHooks[_initer]) {
         try {

+ 21 - 6
js-dev/stag-popup.js

@@ -47,12 +47,18 @@ function closeStagPopup(_noEvent = false) {
     }
     else {
         if(popup.is('[update-parent]') && !_noEvent) {
-            if(stagPopupsQueue.length) {
-                refreshDynamicStagPopup();
+            let hook = popup.attr('update-parent');
+            if(!!$.trim(hook) && hasMCHook(hook)) {
+                runMCHook(hook)
             }
             else {
-                fastReload(popup.is('[update-target]') ? popup.attr('update-target') : '');
-                return;
+                if(stagPopupsQueue.length) {
+                    refreshDynamicStagPopup();
+                }
+                else {
+                    fastReload(popup.is('[update-target]') ? popup.attr('update-target') : '');
+                    return;
+                }
             }
         }
     }
@@ -129,7 +135,7 @@ function openDynamicStagPopup(_url, initer, title, updateParent, style = '', rep
 
         if(!replace) {
             if(updateParent) {
-                popup.attr('update-parent', 1);
+                popup.attr('update-parent', updateParent);
             }
             else {
                 popup.removeAttr('update-parent');
@@ -245,11 +251,20 @@ function hasResponseError(_data) {
             .off('click.open-in-stag-popup', '[open-in-stag-popup]')
             .on('click.open-in-stag-popup', '[open-in-stag-popup]', function() {
                 let trig = $(this);
+                let updateParent = trig.is('[update-parent]');
+                if(updateParent) {
+                    if(!!$.trim(trig.attr('update-parent'))) {
+                        updateParent = trig.attr('update-parent');
+                    }
+                    else {
+                        updateParent = true;
+                    }
+                }
                 openDynamicStagPopup(
                     trig.attr('href'),
                     trig.attr('mc-initer'),
                     trig.attr('title'),
-                    trig.is('[update-parent]'),
+                    updateParent,
                     trig.attr('popup-style'),
                     false,
                     trig.is('[update-target]') ? trig.attr('update-target') : null

+ 23 - 1
public/css/style.css

@@ -3064,4 +3064,26 @@ body.forced-masking {
 }
 body.forced-masking #mask {
     display: block !important;
-}
+}
+[stag-title] {
+    position: relative;
+}
+[stag-title]:hover:after {
+    content: attr(stag-title);
+    position: absolute;
+    bottom: 100%;
+    left: 0;
+    width: 100%;
+    background: #f7f7f7;
+    border-top: 1px solid #d7d7d7;
+    border-bottom: 1px solid #d7d7d7;
+    color: #888;
+    text-align: center;
+    font-size: 80%;
+    font-weight: normal;
+    padding: 1px 3px;
+    z-index: 1;
+}
+.post-refresh-highlight {
+    background: #cbf4f0 !important;
+}

+ 1 - 1
resources/views/app/admin/part_b_patients-table.blade.php

@@ -35,7 +35,7 @@
 				</td>
 				<td>
 					@if($patient->latestClientPrimaryCoverage)
-						{{$patient->latestClientPrimaryCoverage->auto_medicare_mpb_deductible}}
+						{{friendly_money($patient->latestClientPrimaryCoverage->auto_medicare_mpb_remaining)}}
 					@else 
 						No data
 					@endif	

+ 2 - 2
resources/views/app/patient/segment-templates/typical_day_lifestyle/summary.blade.php

@@ -44,13 +44,13 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
             <tbody>
             @foreach(@$contentData["lines"] as $line)
                 <tr>
-                    <td><pre class="m-0">{{$line['S']}}</pre></td>
+                    <td><pre class="m-0">{{$line['S']}}&nbsp;</pre></td>
                     <td>
                         <div class="d-flex align-items-baseline">
                             @if(@$line['I'])
                                 <b class="mr-2">{{$line['I']}}</b>
                             @endif
-                            <pre class="m-0">{{$line['P']}}</pre>
+                            <pre class="m-0">{{$line['P']}}&nbsp;</pre>
                         </div>
                     </td>
                 </tr>

+ 1 - 1
resources/views/app/practice-management/billing-report.blade.php

@@ -49,7 +49,7 @@
                                 <div>Plan Type: {{$row->client->latestClientPrimaryCoverage->plan_type}}</div>
                                 @if($row->client->latestClientPrimaryCoverage->auto_medicare_is_partbprimary == 'YES')
                                     <div>
-                                        Deductible: {{$row->client->latestClientPrimaryCoverage->auto_medicare_mpb_remaining}}
+                                        Deductible: {{friendly_money($row->client->latestClientPrimaryCoverage->auto_medicare_mpb_remaining)}}
                                     </div>
                                 @else 
                                     <div>

+ 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>

+ 99 - 30
resources/views/app/practice-management/remote-monitoring.blade.php

@@ -31,8 +31,6 @@
                 </span>
                 <?php
 
-                use App\Models\Note;
-
                 $mStr = request()->input('m') ? request()->input('m') : date('m');
                 $yStr = request()->input('y') ? request()->input('y') : date('Y');
                 $rcmStartDate = $yStr . '-' . $mStr . '-' . '01';
@@ -81,9 +79,21 @@
             <div class="card-body p-0">
                 <div class="d-flex align-items-start m-0">
                     <div class="flex-grow-1 px-0 pt-2">
+                        <?php $trIndex = 0; ?>
+                        @foreach ($patients as $iPatient)
+                            <script>
+                                addMCHook(
+                                    'refresh-rpm-row-{{$trIndex}}',
+                                    function () {
+                                        refreshRpmRow({{$trIndex}});
+                                    }
+                                );
+                            </script>
+                            <?php $trIndex++; ?>
+                        @endforeach
                         <table class="table table-sm table-striped table-hover p-0 m-0 border-top" id="table-rm-matrix">
                             <thead class="bg-light">
-                            <tr>
+                            <tr stag-title="Click to sort. Shift+Click to multi-sort.">
                                 <th class="border-0 pl-2">Name</th>
                                 <th class="border-0">DOB</th>
                                 <th class="border-0">RPM?</th>
@@ -100,16 +110,15 @@
                             </tr>
                             </thead>
                             <tbody>
+                            <?php $trIndex = 0; ?>
                             @foreach ($patients as $iPatient)
                                 <?php
 
                                 $daysDiff = -1;
-                                $mostRecentCompletedMcpNote = null;
                                 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;
-                                    $mostRecentCompletedMcpNote = Note::where('id', $iPatient->most_recent_completed_mcp_note_id)->first();
                                 }
                                 $lastVisitWithin90Days = ($daysDiff !== -1 && $daysDiff <= 90);
 
@@ -123,16 +132,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>
@@ -140,28 +149,32 @@
                                     <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>
-                                        {{$iPatient->most_recent_cellular_bp_sbp_mm_hg ?: '-'}}/{{$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 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>
-                                        {{$iPatient->most_recent_cellular_weight_value ? round($iPatient->most_recent_cellular_weight_value, 1) : '-'}}
-                                        @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 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($mostRecentCompletedMcpNote)
-                                                <a href = "{{route('patients.view.notes.view.dashboard', ['patient' => $iPatient->client_uid, 'note' => $mostRecentCompletedMcpNote])}}">
-                                                    <span>{{$iPatient->most_recent_completed_mcp_note_date ? friendly_date($iPatient->most_recent_completed_mcp_note_date) : '-'}}</span>
+                                            @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>-</span>
+                                                <span class="sort-data">-</span>
                                             @endif
                                         </div>
                                         {{--@if(!$lastVisitWithin90Days)
@@ -175,7 +188,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">
@@ -234,7 +247,7 @@
                                     <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>{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</span>
+                                            <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>
@@ -263,12 +276,12 @@
                                     <td>
                                         <div class="d-flex align-items-baseline">
                                             @if($performerRole === 'MCP')
-                                                <span>{{$iPatient->rm_num_measurements_not_stamped_by_mcp}}</span>
+                                                <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
+                                                       update-parent="refresh-rpm-row-{{$trIndex}}"
                                                        popup-style="tall overflow-visible"
                                                        class="ml-2 text-sm"
                                                        mc-initer="rpm-work-matrix"
@@ -277,12 +290,12 @@
                                                     </a>
                                                 @endif
                                             @elseif($performerRole === 'RMM')
-                                                <span>{{$iPatient->rm_num_measurements_not_stamped_by_rmm}}</span>
+                                                <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
+                                                       update-parent="refresh-rpm-row-{{$trIndex}}"
                                                        popup-style="tall overflow-visible"
                                                        class="ml-2 text-sm"
                                                        mc-initer="rpm-work-matrix"
@@ -298,6 +311,7 @@
                                             <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>
@@ -306,6 +320,7 @@
                                             <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>
@@ -338,6 +353,7 @@
                                         @endif
                                     </td>
                                 </tr>
+                                <?php $trIndex++; ?>
                             @endforeach
                             </tbody>
                         </table>
@@ -348,11 +364,64 @@
     </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 + '&trIndex=' + _index, _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();
+                    tr.addClass('post-refresh-highlight');
+                    setTimeout(function() {
+                        tr.removeClass('post-refresh-highlight');
+                    }, 1000);
+                });
+            }
             function init() {
-                $('#table-rm-matrix').DataTable({
-                    "pageLength": 100
+                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,
+                            type: 'date',
+                            render: function (data, type, row, meta) {
+                                if(type === 'sort') {
+                                    return $(data).find('.sort-data').first().text();
+                                }
+                                return data;
+                            },
+                        },
+                        {
+                            targets: [5, 6, 9, 10, 11],
+                            type: 'num',
+                            render: function (data, type, row, meta) {
+                                if(type === 'sort') {
+                                    return +($(data).find('.sort-data').first().text());
+                                }
+                                return data;
+                            },
+                        },
+                    ]
                 });
                 $('#practice-remote-monitoring').removeAttr('v-cloak');
+                $('#practice-remote-monitoring [moe][initialized]').removeAttr('initialized');
+                initMoes();
             }
             addMCInitializer('practice-remote-monitoring', init, '#practice-remote-monitoring');
         }).call(window);

+ 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');