Kaynağa Gözat

RPM matrix (wip)

Vijayakrishnan 3 yıl önce
ebeveyn
işleme
08ee0903d5

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

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

+ 32 - 45
resources/views/app/practice-management/remote-monitoring.blade.php

@@ -12,29 +12,33 @@
                     <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
+                $m = request()->input('m') ? +(request()->input('m')) : +(date('m'));
+                $y = request()->input('y') ? +(request()->input('y')) : +(date('Y'));
+                ?>
                 <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 +47,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 +85,27 @@
                         <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' => 'Enrolled in RPM?', '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' => 'Latest 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' => '# 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' => '# 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' => '# RPM Minutes', '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(); ?>
                                 <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>