Răsfoiți Sursa

Popup matrix: New Patients Awaiting Visit

Vijayakrishnan 3 ani în urmă
părinte
comite
2922352f53

+ 6 - 2
app/Http/Controllers/McpController.php

@@ -90,8 +90,12 @@ class McpController extends Controller
 
 
     public function new_patients_awaiting_visit(Request $request){
-        $data = [];
-        // SELECT * FROM client WHERE mcp_pro_id = :me.id AND has_mcp_done_onboarding_visit != 'YES'
+        $data = [
+            'records' => Client::where('mcp_pro_id', $this->performer->pro->id)
+                ->where('has_mcp_done_onboarding_visit', '!=', 'YES')
+                ->orderBy('created_at')
+                ->get()
+        ];
         return view('app.mcp.new_patients_awaiting_visit', $data);
     }
     public function notes_pending_signature(Request $request){

+ 35 - 0
app/Models/Client.php

@@ -285,6 +285,29 @@ class Client extends Model
         return false;
     }
 
+    public function lastMcpAppointment()
+    {
+        if ($this->mcp) {
+            return Appointment::where('client_id', $this->id)
+                ->where('pro_id', $this->mcp->id)
+                ->where('start_time', '<', date('Y-m-d'))
+                ->orderBy('start_time', 'asc')
+                ->first();
+        }
+        return false;
+    }
+
+    public function lastMeasurementOfType($_type) {
+        return Measurement::where('client_id', $this->id)
+            ->whereNotNull('bdt_measurement_id')
+            ->whereNotNull('ts')
+            ->where('is_cellular_zero', false)
+            ->where('is_removed', false)
+            ->where('label', '=', $_type)
+            ->orderBy('ts', 'desc')
+            ->first();
+    }
+
     public function appointments()
     {
         return $this->hasMany(Appointment::class, 'client_id', 'id')
@@ -777,4 +800,16 @@ ORDER BY m.ts DESC
         if(!$coverage) return 'NO';
         return $coverage->getStatus();
     }
+
+    public function getMcpAssignedOn() {
+        $change = ClientProChange::where('client_id', $this->id)
+            ->where('new_pro_id', $this->mcp_pro_id)
+            ->where('responsibility_type', 'MCP')
+            ->orderBy('created_at', 'DESC')
+            ->first();
+        if(!!$change) {
+            return friendlier_date($change->created_at);
+        }
+        return '-';
+    }
 }

+ 0 - 1
public/css/style.css

@@ -1056,7 +1056,6 @@ body .node input[type="number"] {
     width: calc(100vw - 4rem);
 }
 .stag-popup.tall>form, .stag-popup.tall>.stag-popup-content {
-    height: 100%;
     min-height: 500px;
 }
 .stag-popup.narrow>form, .stag-popup.narrow>.stag-popup-content {

+ 46 - 7
resources/views/app/mcp/new_patients_awaiting_visit.blade.php

@@ -1,19 +1,58 @@
-@extends ('layouts/template')
-
-@section('content')
     <div class="p-3 mcp-theme-1" id="patients-list">
         <div class="card">
 
-            <div class="card-header px-3 py-2 d-flex align-items-center">
+            <div class="card-header px-3 py-2 d-flex align-items-center border-bottom-0">
                 <strong class="mr-4">
                     <i class="fas fa-user-injured"></i>
                     New Patients Awaiting Visit
                 </strong>
             </div>
 
-            <div class="card-body p-0">
-
+            <div class="card-body p-0 border-top-0 pb-0">
+                <table class="table table-sm table-striped mb-0">
+                    <thead>
+                    <tr>
+                        <th class="border-bottom-0">Chart #</th>
+                        <th class="border-bottom-0">Name (F.I. LAST)</th>
+                        <th class="border-bottom-0">DOB</th>
+                        <th class="border-bottom-0">Gender</th>
+                        <th class="border-bottom-0">BMI</th>
+                        <th class="border-bottom-0">Insurance</th>
+                        <th class="border-bottom-0">Last Visit</th>
+                        <th class="border-bottom-0">Next Appt.</th>
+                        <th class="border-bottom-0">Status</th>
+                        <th class="border-bottom-0">CCM</th>
+                        <th class="border-bottom-0">RPM</th>
+                        <th class="border-bottom-0">Last Weight-In</th>
+                        <th class="border-bottom-0">Last BP</th>
+                        <th class="border-bottom-0">Assigned On</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach($records as $row)
+                        <tr>
+                            <td class="border-bottom-0">
+                                <a target="_blank" native href="{{route('patients.view.dashboard', $row)}}">
+                                    {{$row->chart_number}}
+                                </a>
+                            </td>
+                            <td class="border-bottom-0">{{implode(' ', [$row->name_first, $row->name_last])}}</td>
+                            <td class="border-bottom-0">{{$row->dob}}</td>
+                            <td class="border-bottom-0">{{$row->sex}}</td>
+                            <td class="border-bottom-0">{{$row->usual_bmi}}</td>
+                            <td class="border-bottom-0">{{$row->Insurance}}</td>
+                            <td class="border-bottom-0">{{$row->lastMcpAppointment() ? $row->lastMcpAppointment()->start_date : '-'}}</td>
+                            <td class="border-bottom-0">{{$row->nextMcpAppointment() ? $row->nextMcpAppointment()->start_date : '-'}}</td>
+                            <td class="border-bottom-0">{{$row->nextMcpAppointment() ? $row->nextMcpAppointment()->status : '-'}}</td>
+                            <td class="border-bottom-0">{{$row->is_enrolled_in_cm ? 'Yes' : 'No'}}</td>
+                            <td class="border-bottom-0">{{$row->is_enrolled_in_rm ? 'Yes' : 'No'}}</td>
+                            <td class="border-bottom-0">{{$row->lastMeasurementOfType('Wt. (lbs.)') ? $row->lastMeasurementOfType('Wt. (lbs.)') : '-'}}</td>
+                            <td class="border-bottom-0">{{$row->lastMeasurementOfType('BP') ? $row->lastMeasurementOfType('BP') : '-'}}</td>
+                            <td class="border-bottom-0">{{$row->getMcpAssignedOn()}}</td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
             </div>
         </div>
     </div>
-@endsection