Browse Source

Patient calendar pro defaults

Vijayakrishnan 3 years ago
parent
commit
1e0b3dc3b7

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

@@ -369,7 +369,19 @@ class PatientController extends Controller
     }
     }
 
 
     public function calendar(Request $request, Client $patient, Appointment $currentAppointment) {
     public function calendar(Request $request, Client $patient, Appointment $currentAppointment) {
-        return view('app.patient.appointment-calendar', compact('patient', 'currentAppointment'));
+        $pros = [];
+
+        if($this->pro && $this->pro->pro_type != 'ADMIN') {
+            $accessiblePros = ProProAccess::where('owner_pro_id', $this->pro->id);
+            $accessibleProIds = [];
+            foreach($accessiblePros as $accessiblePro){
+                $accessibleProIds[] = $accessiblePro->id;
+            }
+            $accessibleProIds[] = $this->pro->id;
+            $pros = Pro::whereIn('id', $accessibleProIds)->get();
+        }
+
+        return view('app.patient.appointment-calendar', compact('pros', 'patient', 'currentAppointment'));
     }
     }
 
 
     public function programs(Request $request, Client $patient, $filter = '') {
     public function programs(Request $request, Client $patient, $filter = '') {

+ 6 - 1
resources/views/app/patient/appointment-calendar.blade.php

@@ -136,7 +136,7 @@
                         Pro
                         Pro
                     </div>
                     </div>
                     <div class="col-9 font-weight-bold">
                     <div class="col-9 font-weight-bold">
-                        <select id="addApptPro" name="proUid" provider-search required
+                        <select id="addApptPro" name="proUid" {{$pro->pro_type !== 'ADMIN' ? '' : 'provider-search'}} required
                                 v-model="newAppointment.proUid"
                                 v-model="newAppointment.proUid"
                                 :data-pro-uid="newAppointment.proUid"
                                 :data-pro-uid="newAppointment.proUid"
                                 no-auto-pro-suggest-init
                                 no-auto-pro-suggest-init
@@ -729,6 +729,11 @@
                             let endTime = this.timeStr(this.selectedSlot.end);
                             let endTime = this.timeStr(this.selectedSlot.end);
                             this.newAppointment.clientUid = this.client.uid;
                             this.newAppointment.clientUid = this.client.uid;
                             this.newAppointment.proUid = '';
                             this.newAppointment.proUid = '';
+                            @if($pro->is_hcp && $pro->is_enrolled_as_mcp)
+                                this.newAppointment.proUid = '{{$pro->uid}}';
+                            @elseif($patient->mcp)
+                                this.newAppointment.proUid = '{{$patient->mcp->uid}}';
+                            @endif
                             this.newAppointment.referringProUid = '';
                             this.newAppointment.referringProUid = '';
                             this.newAppointment.date = this.dateStr(this.selectedSlot.start);
                             this.newAppointment.date = this.dateStr(this.selectedSlot.start);
                             this.newAppointment.startTime = startTime === '00:00' ? '' : startTime;
                             this.newAppointment.startTime = startTime === '00:00' ? '' : startTime;