Browse Source

Pro care month report

Vijayakrishnan 3 years ago
parent
commit
ed08e3a854

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

@@ -1829,4 +1829,43 @@ ORDER BY claim.created_at DESC
 
     }
 
+    public function careMonthReport(Request $request) {
+        $m = $request->input('m');
+        $y = $request->input('y');
+        if(!$m || !$y) {
+            $date = date('Y-m-01');
+        }
+        else {
+            $date = date('Y-m-d', strtotime("$m/1/$y"));
+        }
+
+        $pro = $this->pro;
+
+        $records = DB::select("
+SELECT cm.id                                as care_month_id,
+       cm.uid                               as care_month_uid,
+       c.id                                 as client_id,
+       c.uid                                as client_uid,
+       cm.number_of_days_with_remote_measurements,
+       cm.rm_total_time_in_seconds_by_mcp,
+       cm.rm_total_time_in_seconds_by_rme_pro,
+       cm.rm_total_time_in_seconds_by_rmm_pro,
+       cm.mcp_pro_id,
+       cm.rme_pro_id,
+       cm.rmm_pro_id,
+       (c.name_first || ' ' || c.name_last) as client_name
+FROM care_month cm
+         JOIN client c on cm.client_id = c.id
+WHERE cm.start_date = :startDate
+  AND (cm.mcp_pro_id = :proID OR
+       cm.rme_pro_id = :proID OR
+       cm.rmm_pro_id = :proID)
+ORDER BY c.name_last, c.name_first
+            ",
+            ['startDate' => $date, 'proID' => $pro->id]
+        );
+
+        return view('app.practice-management.care-month-report', compact('records', 'date'));
+    }
+
 }

+ 65 - 0
resources/views/app/practice-management/care-month-report.blade.php

@@ -0,0 +1,65 @@
+@extends ('layouts/template')
+
+@section('content')
+    <div id="care-month-report" class="p-3 mcp-theme-1">
+        <div class="card">
+
+            <div class="card-header px-3 py-2 d-flex align-items-center">
+                <strong class="mr-4">
+                    <i class="fas fa-user-injured"></i>
+                    Care Month Report: {{date('M Y', strtotime($date))}}
+                </strong>
+            </div>
+
+            <div class="card-body p-0 border-0">
+                <table class="table table-sm table-condensed p-0 m-0">
+                    <thead class="bg-light">
+                    <tr>
+                        <th>Patient</th>
+                        <th>Role</th>
+                        <th># Days with measurements</th>
+{{--                        <th>Last Measurement</th>--}}
+                        <th># Minutes</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach ($records as $record)
+                        <tr>
+                            <td><a href="/patients/view/{{$record->client_uid}}/care-months/view/{{$record->care_month_uid}}">{{$record->client_name}}</a></td>
+                            <td>{{$record->mcp_pro_id === $pro->id ? 'MCP' : ($record->rme_pro_id === $pro->id ? 'RME' : ($record->rmm_pro_id === $pro->id ? 'RMM' : '-'))}}</td>
+                            <td>{{$record->number_of_days_with_remote_measurements}}</td>
+                            <?php /* <td>
+                                <?php
+                                $lastMeasurement = \App\Models\Measurement::where('care_month_id', $record->care_month_id)
+                                    ->whereNotNull('client_bdt_measurement_id')
+                                    ->where('is_cellular_zero', FALSE)
+                                    ->where('is_removed', FALSE)
+                                    ->where('label', '!=', 'SBP')
+                                    ->where('label', '!=', 'DBP')
+                                    ->whereNotNull('ts')
+                                    ->orderBy('ts', 'DESC')
+                                    ->first();
+                                ?>
+                                @if(!!$lastMeasurement)
+                                        @if($lastMeasurement->is_cellular_zero)
+                                            <i class="font-size-11 fa fa-rss"></i>
+                                        @elseif($lastMeasurement->label === 'BP')
+                                            Wt. {{ $lastMeasurement->sbp_mm_hg }}/{{ $lastMeasurement->dbp_mm_hg }} mmHg
+                                        @elseif($lastMeasurement->label === 'Wt. (lbs.)')
+                                            BP. {{ round(floatval($lastMeasurement->numeric_value), 2) }} lbs
+                                        @else
+                                            {{$lastMeasurement->label}}. {{$lastMeasurement->value}}
+                                        @endif
+                                @else
+                                    -
+                                @endif
+                            </td> */ ?>
+                            <td>{{$record->mcp_pro_id === $pro->id ? $record->rm_total_time_in_seconds_by_mcp : ($record->rme_pro_id === $pro->id ? $record->rm_total_time_in_seconds_by_rme_pro : ($record->rmm_pro_id === $pro->id ? $record->rm_total_time_in_seconds_by_rmm_pro : '-'))}}</td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+    </div>
+@endsection

+ 1 - 0
routes/web.php

@@ -370,6 +370,7 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/remote-monitoring-measurements/{careMonth}', 'PracticeManagementController@remoteMonitoringMeasurements')->name('remote-monitoring-measurements');
 
     Route::get('/patient-care-month-matrix/{careMonth}', 'PatientController@careMonthMatrix')->name('patient-care-month-matrix');
+    Route::get('/pro-care-month-report', 'PracticeManagementController@careMonthReport')->name('pro-care-month-report');
 
     // fdb playground
     Route::get('/fdb-pg-rx', 'FDBPGController@rx')->name('fdb-pg-rx');