Browse Source

Appointments calendar updates

Vijayakrishnan 3 years ago
parent
commit
dac5d82a66

+ 2 - 5
app/Http/Controllers/AppointmentController.php

@@ -29,10 +29,7 @@ class AppointmentController extends Controller
         }
 
         if(empty($request->get('proIds'))) {
-            $proIds = [];
-            if($performerPro && $performerPro->pro_type !== 'ADMIN') {
-                $proIds = [$performerPro->id];
-            }
+            $proIds = [$performerPro->id];
         }
         else {
             $proIds = explode(',', $request->get('proIds'));
@@ -63,7 +60,7 @@ class AppointmentController extends Controller
                 ->where(function ($query) use ($proIds, $clientId) {
                     $query
                         ->whereIn('pro_id', $proIds)
-                        ->orWhere('client_id', '=', $clientId)
+                        ->orWhere('client_id', $clientId)
                         ->orWhereRaw('client_id IN (SELECT shadow_client_id FROM pro WHERE id IN (' . implode(',', $proIds) . '))');
                 });
             $appointments = $appointments->get();

+ 13 - 1
app/Http/Controllers/PatientController.php

@@ -423,7 +423,19 @@ class PatientController extends Controller
             $pros = Pro::whereIn('id', $accessibleProIds)->get();
         }
 
-        return view('app.patient.appointment-calendar', compact('pros',  'patient', 'currentAppointment'));
+        $dateLastWeek = date_sub(date_create(), date_interval_create_from_date_string("14 days"));
+        $dateLastWeek = date_format($dateLastWeek, "Y-m-d");
+        $appointments = Appointment::where('client_id', $patient->id)
+            ->orderBy('raw_date', 'desc')->orderBy('raw_start_time', 'desc')
+            ->where('raw_date', '>=', $dateLastWeek)
+            ->get();
+        $appointmentProIDs = $appointments->map(function($_item) {
+            return $_item->pro_id;
+        });
+        $appointmentPros = Pro::whereIn('id', $appointmentProIDs)->get();
+
+        return view('app.patient.appointment-calendar',
+            compact('pros', 'patient', 'currentAppointment', 'appointments', 'appointmentPros'));
     }
 
     public function programs(Request $request, Client $patient, $filter = '') {

+ 53 - 0
resources/views/app/patient/appointment-calendar.blade.php

@@ -61,6 +61,59 @@
     }
     ?>
 
+    {{-- appts list --}}
+    <div class="">
+        <div class="d-flex align-items-end pb-3">
+            <h4 class="font-weight-bold m-0 font-size-16">{{ $patient->displayName() }}'s Appointments</h4>
+        </div>
+        <table class="table table-striped table-sm table-bordered mb-4">
+            @if($appointments && count($appointments))
+                <thead class="bg-light">
+                <tr>
+                    <th class="text-secondary border-bottom-0">Date & Time</th>
+                    <th class="text-secondary border-bottom-0">Pro</th>
+                    <th class="text-secondary border-bottom-0">Title</th>
+                    <th class="text-secondary border-bottom-0">Description</th>
+                    <th class="text-secondary border-bottom-0">Status</th>
+                    <th class="text-secondary border-bottom-0">Confirmation</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($appointments as $appointment)
+                    <tr>
+                        <td>
+                            <a href="/patients/view/{{$patient->uid}}/calendar/{{$appointment->uid}}" class="text-nowrap">
+                                {{friendlier_date_time($appointment->raw_date . ' ' . $appointment->raw_start_time)}}
+                            </a>
+                        </td>
+                        <td>{{ $appointment->pro->displayName() }}</pre></td>
+                        <td>{{ $appointment->title }}</td>
+                        <td>{{ $appointment->description }}</td>
+                        <td>
+                            {{ $appointment->status }}
+                            @if($appointment->status_memo)
+                                <hr>
+                                {{$appointment->status_memo}}
+                            @endif
+                        </td>
+                        <td>
+                            @if($appointment->status !== 'CANCELLED' && $appointment->status !== 'COMPLETED')
+                                @include('app.patient.partials.appointment-confirmation')
+                            @endif
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            @else
+                <tbody>
+                <tr>
+                    <td class="text-secondary p-3">No recent or upcoming appointments</td>
+                </tr>
+                </tbody>
+            @endif
+        </table>
+    </div>
+
     <div id="calendarApp">
         <div class="d-flex align-items-center mb-2">
             <h4 class="font-weight-bold m-0 font-size-16">