Pārlūkot izejas kodu

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

= 3 gadi atpakaļ
vecāks
revīzija
ad4d9fd0f8

+ 7 - 0
app/Http/Controllers/McpController.php

@@ -423,6 +423,13 @@ class McpController extends Controller
         ];
         return view('app.mcp.measurements_pending_stamping', $data);
     }
+
+    public function measurements_pending_stamping_in_care_month(Request $request) {
+        $patient = Client::where('uid', $request->input('patientUid'))->first();
+        $careMonth = CareMonth::where('uid', $request->input('careMonthUid'))->first();
+        return view('app.mcp.measurements_pending_stamping_in_care_month', compact('patient', 'careMonth'));
+    }
+
     public function measurements_mass_stamping(Request $request){
         $careMonthsWithMeasurementsPendingStamping = CareMonth::select('id')
             ->where('mcp_pro_id', $this->performer->pro->id)

+ 11 - 9
app/Http/Controllers/PracticeManagementController.php

@@ -1033,11 +1033,13 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
 
         $conditions = $this->rpmConditions($performer, $rc, $rc2);
 
-        $patients = DB::select(
-            DB::raw(
-                "
-SELECT client.name_first, 
-       client.name_last, 
+        $sortBy = $request->input('sort_by') ?: 'name_first';
+        $sortDir = $request->input('sort_dir') ?: 'ASC';
+        $orderBy = "ORDER BY $sortBy $sortDir NULLS LAST";
+
+        $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,
@@ -1068,10 +1070,10 @@ WHERE
       AND EXTRACT(MONTH from care_month.start_date) = " . ($request->input('m') ?: 'EXTRACT(MONTH from now())') . "
       AND EXTRACT(YEAR from care_month.start_date) = " . ($request->input('y') ?: 'EXTRACT(YEAR from now())') . "
       " . (count($conditions) > 0 ? 'AND ' . implode(" AND ", $conditions) : '') . "
-ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST, client.name_first, client.name_last
-"
-            )
-        );
+      $orderBy
+";
+
+        $patients = DB::select($query);
 
         $timestamp = strtotime(date('Y-m-d'));
         $daysRemaining = (int)date('t', $timestamp) - (int)date('j', $timestamp);

+ 21 - 0
resources/views/app/mcp/measurements_pending_stamping_in_care_month.blade.php

@@ -0,0 +1,21 @@
+<div class="px-3 pt-3 mcp-theme-1">
+    <div class="card border-0">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0 hide-inside-popup">
+            <strong class="mr-4">
+                <i class="fas fa-user"></i>
+                Measurements Pending Stamping
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-0">
+
+            @include('app.patient.care-month._matrix', ['onlyMatrix' => true])
+
+        </div>
+    </div>
+
+</div>
+
+
+

+ 4 - 2
resources/views/app/patient/care-month/_matrix.blade.php

@@ -29,12 +29,14 @@ foreach ($days as $k => $day) {
 ?>
 
 <div id="cm-matrix-{{$patient->id}}">
-<div class="d-flex align-items-baseline" tab-links>
+@if(!@$onlyMatrix)
+<div class="d-flex align-items-baseline mb-3" tab-links>
     <a class="tab-link-active" href="#" tab-link="matrix">Care Month Matrix</a>
     <a class="" href="#" tab-link="bmi-summary">BMI/Weight Management Settings</a>
     <a class="" href="#" tab-link="bp-summary">BP Management Settings</a>
 </div>
-<table class="table table-condensed table-sm table-bordered my-3 cm-tab" tab-key="matrix">
+@endif
+<table class="table table-condensed table-sm table-bordered mb-3 cm-tab" tab-key="matrix">
     <thead>
     <tr>
         <th class="px-2 text-secondary align-bottom" rowspan="2">Date</th>

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

@@ -33,6 +33,9 @@
 	    <div class="row client-single-dashboard">
             <div class="col-6">
 
+                {{-- rpm summary for current caremonth --}}
+                @include('app/patient/partials/caremonth-summary', ['careMonth' => $patient->currentCareMonth()])
+
                 {{-- appointments --}}
                 @include('app/patient/partials/appointments')
 

+ 93 - 0
resources/views/app/patient/partials/caremonth-summary.blade.php

@@ -0,0 +1,93 @@
+<div class="pb-3 mb-2 border-bottom">
+    <div class="d-flex align-items-center mb-2 pt-2">
+        <h6 class="my-0 font-weight-bold">RPM: {{friendly_month($careMonth->start_date)}}</h6>
+        <span class="mx-2 text-secondary">|</span>
+        <a href="/patients/view/{{ $patient->uid }}/care-months/view/{{ $careMonth->uid }}">View</a>
+    </div>
+    <div class="mt-2">
+        <?php $daysDiff = -1; ?>
+        @if($patient->most_recent_completed_mcp_note_date)
+            <?php
+            $careMonthLastDay = date_add(date_create($careMonth->start_date), 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($patient->most_recent_completed_mcp_note_date))->days;
+            ?>
+        @endif
+        <span class="font-weight-bold text-secondary">Last Visit:</span>
+        <b class="{{$daysDiff === -1 ? 'text-secondary' : ($daysDiff <= 90 ? 'text-success' : 'text-warning-mellow')}}">
+            {{friendly_date($patient->most_recent_completed_mcp_note_date)}}
+            @if($daysDiff !== -1)
+                @if($daysDiff > 90)
+                    <i class="fa fa-exclamation-triangle"></i>
+                    <span class="ml-1 text-secondary text-sm font-weight-normal">({{$daysDiff}} days ago)</span>
+                @else
+                    <i class="fa fa-check"></i>
+                @endif
+            @endif
+        </b>
+    </div>
+
+    <div class="mt-2">
+        <span class="font-weight-bold text-secondary">Days with meas.:</span>
+        <b class="{{$careMonth->number_of_days_with_remote_measurements >= 16 ? 'text-success' : 'text-warning-mellow'}}">
+            {{$careMonth->number_of_days_with_remote_measurements}}
+            @if($careMonth->number_of_days_with_remote_measurements >= 16)
+                <i class="fa fa-check"></i>
+            @else
+                <i class="fa fa-exclamation-triangle"></i>
+            @endif
+            <span class="ml-1 text-secondary text-sm font-weight-normal">(16 needed)</span>
+        </b>
+        @if($careMonth->number_of_days_with_remote_measurements < 16)
+            <div moe relative class="ml-2">
+                <a href="#" start show class="text-sm">SMS Patient</a>
+                <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1" noreload="" style="display: none;">
+                    <input type="hidden" name="uid" value="{{ $patient->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="{{$patient->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">Please use your weight-scale and BP meter more often to stay safe during this pandemic! Leadership Health.</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($careMonth->number_of_days_with_remote_measurements < 16)
+        <div class="alert alert-warning p-2 mt-1">
+            Need <b>{{16 - $careMonth->number_of_days_with_remote_measurements}} more days</b> with measurements before RM becomes billable.
+        </div>
+    @endif
+
+    <div class="mt-2">
+        <?php $spoken = $careMonth->has_anyone_interacted_with_client_about_rm_outside_note; ?>
+        <span class="font-weight-bold text-secondary">MCP spoke to patient:</span>
+        <b class="{{$spoken ? 'text-success' : 'text-warning-mellow'}}">
+            {{$spoken ? 'Yes' : 'No'}}
+            @if(!$spoken)
+                <i class="fa fa-exclamation-triangle"></i>
+            @else
+                <i class="fa fa-check"></i>
+            @endif
+        </b>
+        @if($careMonth->mcp && $pro->id === $careMonth->mcp->id)
+            <div moe relative class="ml-2">
+                <a href="#" start show class="text-sm">Toggle</a>
+                <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
+                    <input type="hidden" name="uid" value="{{$careMonth->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>
+</div>

+ 2 - 2
resources/views/app/practice-management/_sort_header.blade.php

@@ -1,9 +1,9 @@
 <b class="{{request()->input('sort_by') === $key ? 'text-primary' : 'text-secondary'}}">{{$label}}</b>
 <span class="ml-2 d-inline-flex align-items-baseline">
-    <a href="{{ route("practice-management.hcp-note-activity") }}?{{queryLineExcept(['sort_by', 'sort_dir'])}}&sort_by={{$key}}&sort_dir=DESC" class="ml-1">
+    <a href="{{ $route }}?{{queryLineExcept(['sort_by', 'sort_dir'])}}&sort_by={{$key}}&sort_dir=DESC" class="ml-1">
         <i class="fa fa-arrow-up {{request()->input('sort_by') === $key && request()->input('sort_dir') === 'DESC' ? '' : 'on-hover-opaque text-secondary'}}"></i>
     </a>
-    <a href="{{ route("practice-management.hcp-note-activity") }}?{{queryLineExcept(['sort_by', 'sort_dir'])}}&sort_by={{$key}}&sort_dir=ASC" class="ml-1">
+    <a href="{{ $route }}?{{queryLineExcept(['sort_by', 'sort_dir'])}}&sort_by={{$key}}&sort_dir=ASC" class="ml-1">
         <i class="fa fa-arrow-down {{request()->input('sort_by') === $key && request()->input('sort_dir') === 'ASC' ? '' : 'on-hover-opaque text-secondary'}}"></i>
     </a>
 </span>

+ 7 - 7
resources/views/app/practice-management/hcp-note-activity.blade.php

@@ -85,15 +85,15 @@
             <table class="table table-sm table-striped border-0 p-0 m-0 text-nowrap">
                 <thead class="bg-light">
                     <tr>
-                        <th>@include('app.practice-management._sort_header', ['label' => 'First Name', 'key' => 'name_first'])</th>
-                        <th>@include('app.practice-management._sort_header', ['label' => 'Last Name', 'key' => 'name_last'])</th>
-                        <th>@include('app.practice-management._sort_header', ['label' => 'Last Note Created At', 'key' => 'last_note_created_at'])</th>
-                        <th>@include('app.practice-management._sort_header', ['label' => '# Notes This Month', 'key' => 'notes_this_month'])</th>
+                        <th>@include('app.practice-management._sort_header', ['route' => route("practice-management.hcp-note-activity"), 'label' => 'First Name', 'key' => 'name_first'])</th>
+                        <th>@include('app.practice-management._sort_header', ['route' => route("practice-management.hcp-note-activity"), 'label' => 'Last Name', 'key' => 'name_last'])</th>
+                        <th>@include('app.practice-management._sort_header', ['route' => route("practice-management.hcp-note-activity"), 'label' => 'Last Note Created At', 'key' => 'last_note_created_at'])</th>
+                        <th>@include('app.practice-management._sort_header', ['route' => route("practice-management.hcp-note-activity"), 'label' => '# Notes This Month', 'key' => 'notes_this_month'])</th>
                         @if(request()->input('from_date') && request()->input('from_date'))
-                            <th>@include('app.practice-management._sort_header', ['label' => '# Notes In the Period', 'key' => 'notes_this_period'])</th>
+                            <th>@include('app.practice-management._sort_header', ['route' => route("practice-management.hcp-note-activity"), 'label' => '# Notes In the Period', 'key' => 'notes_this_period'])</th>
                         @endif
-                        <th>@include('app.practice-management._sort_header', ['label' => '# Clients', 'key' => 'total_client_count'])</th>
-                        <th>@include('app.practice-management._sort_header', ['label' => '# Active Clients', 'key' => 'active_client_count'])</th>
+                        <th>@include('app.practice-management._sort_header', ['route' => route("practice-management.hcp-note-activity"), 'label' => '# Clients', 'key' => 'total_client_count'])</th>
+                        <th>@include('app.practice-management._sort_header', ['route' => route("practice-management.hcp-note-activity"), 'label' => '# Active Clients', 'key' => 'active_client_count'])</th>
                     </tr>
                 </thead>
                 <tbody>

+ 1 - 1
resources/views/app/practice-management/pro-financials.blade.php

@@ -37,7 +37,7 @@
                     <tbody>
                     @foreach ($fPros as $row)
                         <tr>
-                            <td class="text-nowrap">{{$row->name_first}} {{$row->name_first}}</td>
+                            <td class="text-nowrap">{{$row->name_first}} {{$row->name_last}}</td>
                             <td><b>${{friendly_money($row->balance)}}</b>
                                 <div class="mt-2">
                                     @foreach($row->companyPros as $companyPro)

+ 9 - 9
resources/views/app/practice-management/remote-monitoring-tree.blade.php

@@ -11,43 +11,43 @@ if(!@$rc) {
         </a>
         <div class="condition-children">
             <div class="condition">
-                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=2"
+                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                         {!! $rc == 2 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many are enrolled in RPM?
                     <span class="rm-count ml-1" data-rc="2">(0)</span>
                 </a>
                 <div class="condition-children">
                     <div class="condition">
-                        <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=3"
+                        <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                                 {!! $rc == 3 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many given a cellular device?
                             <span class="rm-count ml-1" data-rc="3">(0)</span>
                         </a>
                         <div class="condition-children">
                             <div class="condition">
-                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=4"
+                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                                         {!! $rc == 4 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have I seen w/in 90 days?
                                     <span class="rm-count ml-1" data-rc="4">(0)</span>
                                 </a>
                                 <div class="condition-children">
                                     <div class="condition">
-                                        <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=5"
+                                        <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                                                 {!! $rc == 5 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have I spoken to this month?
                                             <span class="rm-count ml-1" data-rc="5">(0)</span>
                                         </a>
                                         <div class="condition-children">
                                             <div class="condition">
-                                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=6"
+                                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                                                         {!! $rc == 6 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with no unstamped meas.?
                                                     <span class="rm-count ml-1" data-rc="6">(0)</span>
                                                 </a>
                                             </div>
                                             <div class="condition">
-                                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=7"
+                                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                                                         {!! $rc == 7 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with 16 or more meas. days?
                                                     <span class="rm-count ml-1" data-rc="7">(0)</span>
                                                 </a>
                                                 <div class="condition-children">
                                                     <div class="condition">
-                                                        <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=10"
+                                                        <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                                                                 {!! $rc == 10 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many with 20 or more billing mins.?
                                                             <span class="rm-count ml-1" data-rc="10">(0)</span>
                                                         </a>
@@ -59,13 +59,13 @@ if(!@$rc) {
                                 </div>
                             </div>
                             <div class="condition">
-                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=8"
+                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                                         {!! $rc == 8 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>Home many have subscribed to SMS?
                                     <span class="rm-count ml-1" data-rc="8">(0)</span>
                                 </a>
                             </div>
                             <div class="condition">
-                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=9"
+                                <a href="{{route('practice-management.remote-monitoring')}}?m={{request()->input('m')}}&y={{request()->input('y')}}&rc=1"
                                         {!! $rc == 9 ? 'class="bg-aliceblue font-weight-bold"' : ''!!}>How many have used the device?
                                     <span class="rm-count ml-1" data-rc="9">(0)</span>
                                 </a>

+ 101 - 51
resources/views/app/practice-management/remote-monitoring.blade.php

@@ -12,29 +12,36 @@
                     <i class="fas fa-arrow-right text-sm mx-1"></i>
                     <b class="font-size-14">{{friendly_month(date((request()->input('y') ?: 'Y') . '-' . (request()->input('m') ?: 'm') . '-d'))}}</b>
                 </span>
+                <?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;
+                ?>
                 <form class="ml-auto d-inline-flex flex-nowrap align-items-center" action="" method="GET">
                     <span class="mr-2">Month</span>
                     <select class="form-control form-control-sm min-width-unset width-100px mr-3" name="m"
                             onchange="fastLoad('{{route('practice-management.remote-monitoring')}}?' + $(this).closest('form').serialize())">
-                        <option value="01" {{request()->input('m') === '01' ? 'selected' : ''}}>Jan</option>
-                        <option value="02" {{request()->input('m') === '02' ? 'selected' : ''}}>Feb</option>
-                        <option value="03" {{request()->input('m') === '03' ? 'selected' : ''}}>Mar</option>
-                        <option value="04" {{request()->input('m') === '04' ? 'selected' : ''}}>Apr</option>
-                        <option value="05" {{request()->input('m') === '05' ? 'selected' : ''}}>May</option>
-                        <option value="06" {{request()->input('m') === '06' ? 'selected' : ''}}>Jun</option>
-                        <option value="07" {{request()->input('m') === '07' ? 'selected' : ''}}>Jul</option>
-                        <option value="08" {{request()->input('m') === '08' ? 'selected' : ''}}>Aug</option>
-                        <option value="09" {{request()->input('m') === '09' ? 'selected' : ''}}>Sep</option>
-                        <option value="10" {{request()->input('m') === '10' ? 'selected' : ''}}>Oct</option>
-                        <option value="11" {{request()->input('m') === '11' ? 'selected' : ''}}>Nov</option>
-                        <option value="12" {{request()->input('m') === '12' ? 'selected' : ''}}>Dec</option>
+                        <option value="01" {{$m === 1 ? 'selected' : ''}}>Jan</option>
+                        <option value="02" {{$m === 2 ? 'selected' : ''}}>Feb</option>
+                        <option value="03" {{$m === 3 ? 'selected' : ''}}>Mar</option>
+                        <option value="04" {{$m === 4 ? 'selected' : ''}}>Apr</option>
+                        <option value="05" {{$m === 5 ? 'selected' : ''}}>May</option>
+                        <option value="06" {{$m === 6 ? 'selected' : ''}}>Jun</option>
+                        <option value="07" {{$m === 7 ? 'selected' : ''}}>Jul</option>
+                        <option value="08" {{$m === 8 ? 'selected' : ''}}>Aug</option>
+                        <option value="09" {{$m === 9 ? 'selected' : ''}}>Sep</option>
+                        <option value="10" {{$m === 10 ? 'selected' : ''}}>Oct</option>
+                        <option value="11" {{$m === 11 ? 'selected' : ''}}>Nov</option>
+                        <option value="12" {{$m === 12 ? 'selected' : ''}}>Dec</option>
                     </select>
                     <span class="mr-2">Year</span>
                     <select class="form-control form-control-sm min-width-unset width-100px" name="y"
                             onchange="fastLoad('{{route('practice-management.remote-monitoring')}}?' + $(this).closest('form').serialize())">
-                        <option value="2020" {{request()->input('y') === '2020' ? 'selected' : ''}}>2020</option>
-                        <option value="2021" {{request()->input('y') === '2021' ? 'selected' : ''}}>2021</option>
-                        <option value="2022" {{request()->input('y') === '2022' ? 'selected' : ''}}>2022</option>
+                        <option value="2020" {{$y === 2020 ? 'selected' : ''}}>2020</option>
+                        <option value="2021" {{$y === 2021 ? 'selected' : ''}}>2021</option>
+                        <option value="2022" {{$y === 2022 ? 'selected' : ''}}>2022</option>
                     </select>
                 </form>
             </div>
@@ -43,10 +50,10 @@
 
             <div class="card-body p-0">
                 <div class="d-flex align-items-start m-0">
-                    <div class="p-0">
+                    {{--<div class="p-0">
                         @include('app.practice-management.remote-monitoring-tree')
-                    </div>
-                    <div class="flex-grow-1 border-left p-0">
+                    </div>--}}
+                    <div class="flex-grow-1 p-0">
                         @if($rc == 4)
                             <?php $rc2 = request()->input('rc2') ? request()->input('rc2') : 2; ?>
                             <div class="d-flex align-items-baseline p-2 border-bottom">
@@ -81,44 +88,38 @@
                         <table class="table table-sm table-striped table-hover p-0 m-0">
                             <thead class="bg-light">
                             <tr>
-                                <th class="border-0">Name</th>
-                                <!--<th class="border-0">Relation</th>-->
-
-                                <th class="border-0">DOB</th>
-                                <th class="border-0">Enrolled in RPM?</th>
+                                <th class="border-0 pl-2">@include('app.practice-management._sort_header', ['route' => route("practice-management.remote-monitoring"), 'label' => 'Name', 'key' => 'client_name'])</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.remote-monitoring"), 'label' => 'DOB', 'key' => 'dob'])</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.remote-monitoring"), 'label' => 'RPM Enrolled?', 'key' => 'is_enrolled_in_rm'])</th>
                                 <th class="border-0">Cellular BP?</th>
                                 <th class="border-0">Cellular Scale?</th>
                                 <th class="border-0">Latest BP</th>
                                 <th class="border-0">Latest Weight</th>
-                                <th class="border-0">Latest Visit</th>
-                                <th class="border-0">RPM Interaction This Month?</th>
-                                <th class="border-0">Measurements Pending Stamp</th>
-                                <th class="border-0"># Meas. Days This Month</th>
-                                <th class="border-0"># RPM Minutes</th>
-
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.remote-monitoring"), 'label' => 'Last Visit', 'key' => 'most_recent_completed_mcp_note_date'])</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.remote-monitoring"), 'label' => 'Communicated?', 'key' => 'has_anyone_interacted_with_client_about_rm_outside_note'])</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.remote-monitoring"), 'label' => '#Meas. Days', 'key' => 'number_of_days_with_remote_measurements'])</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.remote-monitoring"), 'label' => '#Unstamped', 'key' => 'rm_num_measurements_not_stamped_by_mcp'])</th>
+                                <th class="border-0">@include('app.practice-management._sort_header', ['route' => route("practice-management.remote-monitoring"), 'label' => '#RPM Mins.', 'key' => 'rm_total_time_in_seconds_by_mcp'])</th>
                             </tr>
                             </thead>
                             <tbody>
                             @foreach ($patients as $iPatient)
-                                <?php $oPatient = \App\Models\Client::where('uid', $iPatient->client_uid)->first(); ?>
+                                <?php
+                                $oPatient = \App\Models\Client::where('uid', $iPatient->client_uid)->first();
+
+                                $daysDiff = -1;
+                                if($oPatient->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($oPatient->most_recent_completed_mcp_note_date))->days;
+                                }
+                                $lastVisitWithin90Days = ($daysDiff !== -1 && $daysDiff <= 90);
+
+                                ?>
                                 <tr>
-                                    <td class="">
-                                        <a href="/patients/view/{{ $iPatient->client_uid }}" class="text-nowrap">{{ $oPatient->displayName() }}</a>
+                                    <td class="pl-2">
+                                        <a href="/patients/view/{{ $iPatient->client_uid }}" class="text-nowrap">{{ $iPatient->client_name }}</a>
                                     </td>
-                                    <!--<td class="">
-                                        @if($iPatient->mcp_pro_id === $pro->id)
-                                            <div>MCP</div>
-                                        @endif
-                                        @if($iPatient->default_na_pro_id === $pro->id)
-                                            <div>Care Coordinator</div>
-                                        @endif
-                                        @if($iPatient->rmm_pro_id === $pro->id)
-                                            <div>RMM</div>
-                                        @endif
-                                        @if($iPatient->rme_pro_id === $pro->id)
-                                            <div>RME</div>
-                                        @endif
-                                    </td>-->
 
                                     <td>{{friendly_date($iPatient->dob)}}</td>
                                     <td>{{ucwords(strtolower($iPatient->is_enrolled_in_rm ?: ''))}}</td>
@@ -136,12 +137,61 @@
                                             <div class="text-sm text-secondary text-nowrap">{{friendly_date_time($iPatient->most_recent_cellular_weight_measurement_at)}}</div>
                                         @endif
                                     </td>
-                                    <td>{{$iPatient->most_recent_completed_mcp_note_date ? friendly_date($iPatient->most_recent_completed_mcp_note_date) : '-'}}</td>
-                                    <td>{{$iPatient->has_anyone_interacted_with_client_about_rm_outside_note ? 'Yes' : 'No'}}</td>
-                                    <td>{{$iPatient->rm_num_measurements_not_stamped_by_mcp}}</td>
-                                    <td>{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</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>
+                                            <span>{{$iPatient->most_recent_completed_mcp_note_date ? friendly_date($iPatient->most_recent_completed_mcp_note_date) : '-'}}</span>
+                                        </div>
+                                        @if(!$lastVisitWithin90Days)
+                                            <div class="text-sm font-italic text-secondary">Last visit > 90 days ago</div>
+                                        @endif
+                                    </td>
+                                    <td>
+                                        <div class="d-flex align-items-baseline">
+                                            <i class="mr-1 text-sm fa {{$iPatient->has_anyone_interacted_with_client_about_rm_outside_note ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
+                                            <span>{{$iPatient->has_anyone_interacted_with_client_about_rm_outside_note ? 'Yes' : 'No'}}</span>
+                                            <div moe relative class="ml-2">
+                                                <a href="#" start show class="text-sm">Toggle</a>
+                                                <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteToTrue" right>
+                                                    <input type="hidden" name="uid" value="{{$iPatient->care_month_uid}}">
+                                                    <p>Set to 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>
+                                        </div>
+                                        @if(!$iPatient->has_anyone_interacted_with_client_about_rm_outside_note)
+                                            <div class="text-sm font-italic text-secondary">Not spoken to 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>{{$iPatient->number_of_days_with_remote_measurements ?: 0}}</span>
+                                        </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">
+                                            <span>{{$iPatient->rm_num_measurements_not_stamped_by_mcp}}</span>
+                                            @if($iPatient->rm_num_measurements_not_stamped_by_mcp)
+                                                <a href="{{ route('mcp.measurements_pending_stamping_in_care_month') }}?patientUid={{$iPatient->client_uid}}&careMonthUid={{$iPatient->care_month_uid}}"
+                                                   native target="_blank"
+                                                   open-in-stag-popup
+                                                   update-parent
+                                                   popup-style="tall overflow-visible"
+                                                   class="ml-2 text-sm"
+                                                   mc-initer="cm-matrix-{{$oPatient->id}}"
+                                                   title="Measurements Pending Stamping">
+                                                    Stamp
+                                                </a>
+                                            @endif
+                                    </td>
                                     <td>{{floor($iPatient->rm_total_time_in_seconds_by_mcp / 60)}}</td>
-
                                 </tr>
                             @endforeach
                             </tbody>

+ 1 - 0
routes/web.php

@@ -106,6 +106,7 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('supply-orders-awaiting-shipment', 'McpController@supply_orders_awaiting_shipment')->name('supply_orders_awaiting_shipment');
 
         Route::get('measurements-pending-stamping', 'McpController@measurements_pending_stamping')->name('measurements_pending_stamping');
+        Route::get('measurements-pending-stamping-in-care-month', 'McpController@measurements_pending_stamping_in_care_month')->name('measurements_pending_stamping_in_care_month');
 
         Route::get('measurements-mass-stamping', 'McpController@measurements_mass_stamping')->name('measurements_mass_stamping');