Przeglądaj źródła

Patient calendar - default to selected pro in new-appt popup

Vijayakrishnan 3 lat temu
rodzic
commit
aa9737aed8

+ 5 - 0
app/Http/Controllers/HomeController.php

@@ -1954,6 +1954,11 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
         return $pro ? $pro->displayName() : '';
     }
 
+    public function proUid(Request $request, $id) {
+        $pro = Pro::where('id', $id)->first();
+        return $pro ? $pro->uid : '';
+    }
+
     public function unmappedSMS(Request $request, $filter = '')
     {
         $proID = $this->performer()->pro->id;

+ 21 - 7
resources/views/app/patient/appointment-calendar.blade.php

@@ -699,6 +699,7 @@
                         eventTypes: '{{ $currentAppointment ? 'BOTH_ALL' : 'BOTH' }}',
                         calendar: null,
                         proIds: ['{{ $currentAppointment ? $currentAppointment->pro_id : ($oPro ? $oPro->id : $pro->id) }}'],
+                        lastSelectedProUid: '',
                         timezone: '{{ $currentAppointment ? $currentAppointment->timezone : 'EASTERN' }}',
                         today: new Date('{{ date('Y-m-d 00:00:00') }}'),
 
@@ -823,6 +824,14 @@
                                     self.proIds = $(this).val();
                                     localStorage.stagCalendarProIds = JSON.stringify(self.proIds);
                                     self.refreshEvents();
+                                    self.lastSelectedProUid = '';
+                                    @if($pro->pro_type === 'ADMIN')
+                                    if(self.proIds && self.proIds.length) {
+                                        $.get('/pro-uid/' + self.proIds[self.proIds.length - 1], _data => {
+                                            self.lastSelectedProUid = _data;
+                                        });
+                                    }
+                                    @endif
                                 });
 
                             // change from select2 to pro-suggest
@@ -1081,13 +1090,18 @@
                             let endTime = this.timeStr(this.selectedSlot.end);
                             this.newAppointment.clientUid = this.client.uid;
                             this.newAppointment.proUid = '';
-                            @if($oPro)
-                                this.newAppointment.proUid = '{{$oPro->uid}}';
-                            @elseif($pro->is_hcp && $pro->is_enrolled_as_mcp)
-                                this.newAppointment.proUid = '{{$pro->uid}}';
-                            @elseif($patient->mcp)
-                                this.newAppointment.proUid = '{{$patient->mcp->uid}}';
-                            @endif
+                            if(this.lastSelectedProUid) {
+                                this.newAppointment.proUid = this.lastSelectedProUid;
+                            }
+                            else {
+                                @if($oPro)
+                                    this.newAppointment.proUid = '{{$oPro->uid}}';
+                                @elseif($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.date = this.dateStr(this.selectedSlot.start);
                             this.newAppointment.startTime = startTime === '00:00' ? '' : startTime;

+ 1 - 0
routes/web.php

@@ -607,6 +607,7 @@ Route::middleware('pro.auth')->group(function () {
     // Pro suggest
     Route::get('/pro-suggest', 'HomeController@proSuggest');
     Route::get('/pro-display-name/{pro}', 'HomeController@proDisplayName');
+    Route::get('/pro-uid/{id}', 'HomeController@proUid');
 
     // embeddable sections
     Route::get('/embed/{patient}/{section}/{selectable}', 'PatientController@embedSection')->name('embed-section');