Преглед изворни кода

Patients awaiting RM interaction - start + matrix

Vijayakrishnan пре 3 година
родитељ
комит
f69f586b07

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

@@ -438,6 +438,34 @@ class McpController extends Controller
         ];
         return view('app.mcp.unsigned_incoming_reports', $data);
     }
+    public function patients_awaiting_rpm_interaction(Request $request) {
+        $cmStartDate = date('Y-m-01');
+        $query = "
+SELECT
+    client.uid as client_uid,
+    care_month.uid as care_month_uid,
+    (client.name_first || ' ' || client.name_last) as client_name,
+    client.age_in_years,
+    client.sex,
+    care_month.start_date,
+    care_month.number_of_days_with_remote_measurements
+FROM
+    client join care_month on client.id = care_month.client_id
+WHERE
+    care_month.start_date = '{$cmStartDate}'
+    AND client.is_enrolled_in_rm = 'YES'
+    AND care_month.has_mcp_interacted_with_client_about_rm IS NOT TRUE
+    AND care_month.mcp_pro_id = {$this->performer->pro->id}
+    AND (client.client_engagement_status_category IS NULL OR client.client_engagement_status_category != 'DUMMY')
+    AND client.name_first NOT ILIKE '%test%'
+    AND client.name_last NOT ILIKE '%test%'
+ORDER BY care_month.number_of_days_with_remote_measurements DESC NULLS LAST
+        ";
+        $data = [
+            'records' => DB::select($query)
+        ];
+        return view('app.mcp.patients_awaiting_rpm_interaction', $data);
+    }
     public function measurements_pending_stamping(Request $request){
         $data = [
             'records' => CareMonth::where('mcp_pro_id', $this->performer->pro->id)

+ 20 - 0
app/Models/Pro.php

@@ -736,6 +736,26 @@ WHERE
         return $count[0]->count;
     }
 
+    function get_patients_awaiting_rpm_interaction_count_as_mcp() {
+        $cmStartDate = date('Y-m-01');
+        $query = "
+SELECT
+    count(client.id)
+FROM
+    client join care_month on client.id = care_month.client_id
+WHERE
+    care_month.start_date = '{$cmStartDate}'
+    AND client.is_enrolled_in_rm = 'YES'
+    AND care_month.has_mcp_interacted_with_client_about_rm IS NOT TRUE
+    AND care_month.mcp_pro_id = {$this->id}
+    AND (client.client_engagement_status_category IS NULL OR client.client_engagement_status_category != 'DUMMY')
+    AND client.name_first NOT ILIKE '%test%'
+    AND client.name_last NOT ILIKE '%test%'
+        ";
+        $count = DB::select($query);
+        return $count[0]->count;
+    }
+
     function get_birthdays_today_as_mcp(){
         return;
         $queryClients = $this->performer()->pro->getAccessibleClientsQuery();

+ 12 - 0
resources/views/app/dashboard-mcp.blade.php

@@ -244,6 +244,18 @@
                                         </a>
                                     </th>
                                 </tr>
+                                <tr>
+                                    <th class="px-2 text-center">{{$pro->get_patients_awaiting_rpm_interaction_count_as_mcp()}}</th>
+                                    <th class="pl-2">
+                                        <a href="{{ route('mcp.patients_awaiting_rpm_interaction') }}"
+                                           native target="_blank"
+                                           open-in-stag-popup
+                                           popup-style="tall"
+                                           title="Patients Awaiting RPM Interaction">
+                                            Patients Awaiting RPM Interaction
+                                        </a>
+                                    </th>
+                                </tr>
                                 @endif
                                 @if($pro->is_considered_for_rmm)
                                     <tr>

+ 47 - 0
resources/views/app/mcp/patients_awaiting_rpm_interaction.blade.php

@@ -0,0 +1,47 @@
+<div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-2 py-1 hide-inside-popup border-bottom-0">
+            <strong class="mr-4">
+                <i class="fas fa-box"></i>
+                Patients Awaiting RPM Interaction
+            </strong>
+        </div>
+
+        <div class="card-body p-0 border-top-0 pb-0">
+
+            <table class="table table-sm table-striped mb-0">
+                <thead class="bg-light">
+                <tr>
+                    <th class="border-0 text-secondary">Patient</th>
+                    <th class="border-0 text-secondary">Gender, Age</th>
+                    <th class="border-0 text-secondary">Care Month</th>
+                    <th class="border-0 text-secondary">Days with measurements</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($records as $record)
+                    <tr>
+                        <td>
+                            <a native target="_blank" href="/mc/patients/view/{{$record->client_uid}}">{{$record->client_name}}</a>
+                        </td>
+                        <td>{{$record->sex}} {{$record->age_in_years}} years</td>
+                        <td>
+                            <a native target="_blank" href="/mc/patients/view/{{$record->client_uid}}/care-months/view/{{$record->care_month_uid}}">{{$record->start_date}}</a>
+                        </td>
+                        <td>
+                            {{$record->number_of_days_with_remote_measurements ?: 0}}
+                        </td>
+                    </tr>
+                @endforeach
+                @if(!count($records))
+                    <tr>
+                        <td colspan="6">No records found.</td>
+                    </tr>
+                @endif
+                </tbody>
+            </table>
+
+        </div>
+    </div>
+</div>

+ 1 - 0
routes/web.php

@@ -105,6 +105,7 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('supply-orders-pending-signature', 'McpController@supply_orders_pending_signature')->name('supply_orders_pending_signature');
         Route::get('supply-orders-awaiting-shipment', 'McpController@supply_orders_awaiting_shipment')->name('supply_orders_awaiting_shipment');
         Route::get('unsigned-incoming-reports', 'McpController@unsigned_incoming_reports')->name('unsigned_incoming_reports');
+        Route::get('patients-awaiting-rpm-interaction', 'McpController@patients_awaiting_rpm_interaction')->name('patients_awaiting_rpm_interaction');
 
         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');