|  |  | @ -29,6 +29,8 @@ import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart'; |  |  |  | import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import 'package:location/location.dart' show Location; |  |  |  | import 'package:location/location.dart' show Location; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import 'models/resp_models/get_livecare_clinics_response_model.dart'; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | class BookAppointmentsViewModel extends ChangeNotifier { |  |  |  | class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |   int selectedTabIndex = 0; |  |  |  |   int selectedTabIndex = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -37,6 +39,8 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |   bool isDoctorProfileLoading = false; |  |  |  |   bool isDoctorProfileLoading = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |   bool isDoctorSearchByNameStarted = false; |  |  |  |   bool isDoctorSearchByNameStarted = false; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   bool isLiveCareSchedule = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   int initialSlotDuration = 0; |  |  |  |   int initialSlotDuration = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   LocationUtils locationUtils; |  |  |  |   LocationUtils locationUtils; | 
			
		
	
	
		
		
			
				
					|  |  | @ -44,12 +48,17 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |   List<GetClinicsListResponseModel> clinicsList = []; |  |  |  |   List<GetClinicsListResponseModel> clinicsList = []; | 
			
		
	
		
		
			
				
					
					|  |  |  |   List<GetClinicsListResponseModel> _filteredClinicsList = []; |  |  |  |   List<GetClinicsListResponseModel> _filteredClinicsList = []; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   List<GetLiveCareClinicsResponseModel> liveCareClinicsList = []; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   List<GetClinicsListResponseModel> get filteredClinicsList => _filteredClinicsList; |  |  |  |   List<GetClinicsListResponseModel> get filteredClinicsList => _filteredClinicsList; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   List<DoctorsListResponseModel> doctorsList = []; |  |  |  |   List<DoctorsListResponseModel> doctorsList = []; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   List<DoctorsListResponseModel> liveCareDoctorsList = []; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   GetClinicsListResponseModel selectedClinic = GetClinicsListResponseModel(); |  |  |  |   GetClinicsListResponseModel selectedClinic = GetClinicsListResponseModel(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   DoctorsListResponseModel selectedDoctor = DoctorsListResponseModel(); |  |  |  |   DoctorsListResponseModel selectedDoctor = DoctorsListResponseModel(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   GetLiveCareClinicsResponseModel selectedLiveCareClinic = GetLiveCareClinicsResponseModel(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   late DoctorsProfileResponseModel doctorsProfileResponseModel; |  |  |  |   late DoctorsProfileResponseModel doctorsProfileResponseModel; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -78,7 +87,9 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |   bool shouldLoadSpecificClinic = false; |  |  |  |   bool shouldLoadSpecificClinic = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |   String? currentlySelectedHospitalFromRegionFlow; |  |  |  |   String? currentlySelectedHospitalFromRegionFlow; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   BookAppointmentsViewModel({required this.bookAppointmentsRepo, required this.errorHandlerService, required this.navigationService, required this.myAppointmentsViewModel, required this.locationUtils}) {; |  |  |  |   BookAppointmentsViewModel( | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       {required this.bookAppointmentsRepo, required this.errorHandlerService, required this.navigationService, required this.myAppointmentsViewModel, required this.locationUtils}) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ; | 
			
		
	
		
		
			
				
					
					|  |  |  |     initBookAppointmentViewModel(); |  |  |  |     initBookAppointmentViewModel(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -101,8 +112,10 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |     isClinicsListLoading = true; |  |  |  |     isClinicsListLoading = true; | 
			
		
	
		
		
			
				
					
					|  |  |  |     isDoctorsListLoading = true; |  |  |  |     isDoctorsListLoading = true; | 
			
		
	
		
		
			
				
					
					|  |  |  |     isDoctorProfileLoading = true; |  |  |  |     isDoctorProfileLoading = true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     isLiveCareSchedule = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |     clinicsList.clear(); |  |  |  |     clinicsList.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     doctorsList.clear(); |  |  |  |     doctorsList.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     liveCareClinicsList.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     // getLocation(); |  |  |  |     // getLocation(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     notifyListeners(); |  |  |  |     notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
	
		
		
			
				
					|  |  | @ -154,6 +167,16 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |     notifyListeners(); |  |  |  |     notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   setIsLiveCareSchedule(bool value) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     isLiveCareSchedule = value; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   setLiveCareSelectedClinic(GetLiveCareClinicsResponseModel clinic) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     selectedLiveCareClinic = clinic; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   void onTabChanged(int index) { |  |  |  |   void onTabChanged(int index) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     selectedTabIndex = index; |  |  |  |     selectedTabIndex = index; | 
			
		
	
		
		
			
				
					
					|  |  |  |     notifyListeners(); |  |  |  |     notifyListeners(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -161,10 +184,11 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   /// this function will decide which clinic api to be called |  |  |  |   /// this function will decide which clinic api to be called | 
			
		
	
		
		
			
				
					
					|  |  |  |   /// either api for region flow or the select clinic api |  |  |  |   /// either api for region flow or the select clinic api | 
			
		
	
		
		
			
				
					
					|  |  |  |   Future<void> getClinics() async |  |  |  |   Future<void> getClinics() async { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   { |  |  |  |     if (shouldLoadSpecificClinic) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     if(shouldLoadSpecificClinic) { |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       getRegionSelectedClinics(); |  |  |  |       getRegionSelectedClinics(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } else if (isLiveCareSchedule) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       getLiveCareScheduleClinics(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } else { |  |  |  |     } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |       getAllClinics(); |  |  |  |       getAllClinics(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -191,11 +215,58 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |     ); |  |  |  |     ); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   Future<void> getLiveCareScheduleClinics({Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     liveCareClinicsList.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     final result = await bookAppointmentsRepo.getLiveCareScheduleClinics(_appState.getAuthenticatedUser()!.age!, _appState.getAuthenticatedUser()!.gender!); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     result.fold( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       (failure) async => await errorHandlerService.handleError(failure: failure), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       (apiResponse) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (apiResponse.messageStatus == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } else if (apiResponse.messageStatus == 1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           liveCareClinicsList = apiResponse.data!; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           isClinicsListLoading = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           initializeFilteredList(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           if (onSuccess != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             onSuccess(apiResponse); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   Future<void> getLiveCareDoctorsList({Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     doctorsList.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     final result = | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         await bookAppointmentsRepo.getLiveCareDoctorsList(selectedLiveCareClinic.serviceID!, _appState.getAuthenticatedUser()!.age!, _appState.getAuthenticatedUser()!.gender!, onError: onError); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     result.fold( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       (failure) async { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         onError!("No doctors found for the search criteria".needTranslation); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       (apiResponse) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (apiResponse.messageStatus == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } else if (apiResponse.messageStatus == 1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           liveCareDoctorsList = apiResponse.data!; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           isDoctorsListLoading = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           // initializeFilteredList(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           if (onSuccess != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             onSuccess(apiResponse); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   //TODO: Make the API dynamic with parameters for ProjectID, isNearest, languageID, doctorId, doctorName |  |  |  |   //TODO: Make the API dynamic with parameters for ProjectID, isNearest, languageID, doctorId, doctorName | 
			
		
	
		
		
			
				
					
					|  |  |  |   Future<void> getDoctorsList( |  |  |  |   Future<void> getDoctorsList( | 
			
		
	
		
		
			
				
					
					|  |  |  |       {int projectID = 0, bool isNearest = false, int doctorId = 0, String doctorName = "", isContinueDentalPlan = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { |  |  |  |       {int projectID = 0, bool isNearest = false, int doctorId = 0, String doctorName = "", isContinueDentalPlan = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
			
		
	
		
		
			
				
					
					|  |  |  |     doctorsList.clear(); |  |  |  |     doctorsList.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     projectID = currentlySelectedHospitalFromRegionFlow != null?int.parse(currentlySelectedHospitalFromRegionFlow!):projectID; |  |  |  |     projectID = currentlySelectedHospitalFromRegionFlow != null ? int.parse(currentlySelectedHospitalFromRegionFlow!) : projectID; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     final result = await bookAppointmentsRepo.getDoctorsList(selectedClinic.clinicID ?? 0, projectID, isNearest, doctorId, doctorName); |  |  |  |     final result = await bookAppointmentsRepo.getDoctorsList(selectedClinic.clinicID ?? 0, projectID, isNearest, doctorId, doctorName); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     result.fold( |  |  |  |     result.fold( | 
			
		
	
	
		
		
			
				
					|  |  | @ -238,7 +309,6 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |     ); |  |  |  |     ); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   //TODO: Handle the cases for LiveCare Schedule |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   Future<void> getDoctorFreeSlots({bool isBookingForLiveCare = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { |  |  |  |   Future<void> getDoctorFreeSlots({bool isBookingForLiveCare = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
			
		
	
		
		
			
				
					
					|  |  |  |     docFreeSlots.clear(); |  |  |  |     docFreeSlots.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     DateTime date; |  |  |  |     DateTime date; | 
			
		
	
	
		
		
			
				
					|  |  | @ -281,6 +351,50 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |     ); |  |  |  |     ); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   Future<void> getLiveCareDoctorFreeSlots({bool isBookingForLiveCare = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     docFreeSlots.clear(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     DateTime date; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     final DateFormat formatter = DateFormat('HH:mm'); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     final DateFormat dateFormatter = DateFormat('yyyy-MM-dd'); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     Map<DateTime, List> _eventsParsed; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     final result = await bookAppointmentsRepo.getLiveCareDoctorFreeSlots( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         selectedDoctor.clinicID ?? 0, selectedLiveCareClinic.serviceID ?? 0, selectedDoctor.projectID ?? 0, selectedDoctor.doctorID ?? 0, isBookingForLiveCare, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         onError: onError); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     result.fold( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       (failure) async { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         print(failure); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       (apiResponse) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (apiResponse.messageStatus == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           onError!(apiResponse.errorMessage ?? "Unknown error occurred"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } else if (apiResponse.messageStatus == 1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           if (apiResponse.data['PatientER_DoctorFreeSlots'] == null || apiResponse.data['PatientER_DoctorFreeSlots'].isEmpty) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             onError!("No free slots available".tr()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             return; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           initialSlotDuration = apiResponse.data["InitialSlotDuration"]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           freeSlotsResponse = apiResponse.data['PatientER_DoctorFreeSlots']; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           freeSlotsResponse.forEach((element) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             // date = (isLiveCareSchedule != null && isLiveCareSchedule) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //     ? DateUtil.convertStringToDate(element) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             //     : | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             date = DateUtil.convertStringToDateSaudiTimezone(element, int.parse(selectedDoctor.projectID.toString())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             slotsList.add(FreeSlot(date, ['slot'])); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             docFreeSlots.add(TimeSlot(isoTime: formatter.format(date), start: new DateTime(date.year, date.month, date.day, 0, 0, 0, 0), end: date, vidaDate: element)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           }); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           if (onSuccess != null) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             onSuccess(apiResponse); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   Future<void> cancelAppointment({required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async { |  |  |  |   Future<void> cancelAppointment({required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
			
		
	
		
		
			
				
					
					|  |  |  |     final result = await bookAppointmentsRepo.cancelAppointment(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel); |  |  |  |     final result = await bookAppointmentsRepo.cancelAppointment(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -419,22 +533,21 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |     final result = await bookAppointmentsRepo.getProjectList(); |  |  |  |     final result = await bookAppointmentsRepo.getProjectList(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     result.fold( |  |  |  |     result.fold( | 
			
		
	
		
		
			
				
					
					|  |  |  |           (failure) async => |  |  |  |       (failure) async => await errorHandlerService.handleError(failure: failure), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       await errorHandlerService.handleError(failure: failure), |  |  |  |       (apiResponse) async { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           (apiResponse) async { |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         if (apiResponse.messageStatus == 2) { |  |  |  |         if (apiResponse.messageStatus == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |           // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); |  |  |  |           // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else if (apiResponse.messageStatus == 1) { |  |  |  |         } else if (apiResponse.messageStatus == 1) { | 
			
		
	
		
		
			
				
					
					|  |  |  |           var projectList = apiResponse.data!; |  |  |  |           var projectList = apiResponse.data!; | 
			
		
	
		
		
			
				
					
					|  |  |  |           hospitalList = await DoctorMapper.getMappedHospitals(projectList, |  |  |  |           hospitalList = await DoctorMapper.getMappedHospitals( | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             projectList, | 
			
		
	
		
		
			
				
					
					|  |  |  |             isArabic: _appState.isArabic(), |  |  |  |             isArabic: _appState.isArabic(), | 
			
		
	
		
		
			
				
					
					|  |  |  |             lat: _appState.userLat, |  |  |  |             lat: _appState.userLat, | 
			
		
	
		
		
			
				
					
					|  |  |  |             lng: _appState.userLong, |  |  |  |             lng: _appState.userLong, | 
			
		
	
		
		
			
				
					
					|  |  |  |           ); |  |  |  |           ); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |           var isLocationEnabled = (_appState.userLat != 0) && (_appState.userLong != 0); |  |  |  |           var isLocationEnabled = (_appState.userLat != 0) && (_appState.userLong != 0); | 
			
		
	
		
		
			
				
					
					|  |  |  |           hospitalList = |  |  |  |           hospitalList = await DoctorMapper.sortList(isLocationEnabled, hospitalList!); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           await DoctorMapper.sortList(isLocationEnabled, hospitalList!); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |           isRegionListLoading = false; |  |  |  |           isRegionListLoading = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |           filteredHospitalList = hospitalList; |  |  |  |           filteredHospitalList = hospitalList; | 
			
		
	
	
		
		
			
				
					|  |  | @ -450,22 +563,21 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   void filterHospitalListByString(String? value, String? selectedRegionId, bool isHMG) { |  |  |  |   void filterHospitalListByString(String? value, String? selectedRegionId, bool isHMG) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     if(value ==null || value.isEmpty){ |  |  |  |     if (value == null || value.isEmpty) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       filteredHospitalList = hospitalList; |  |  |  |       filteredHospitalList = hospitalList; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } else { |  |  |  |     } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |       filteredHospitalList = RegionList(); |  |  |  |       filteredHospitalList = RegionList(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       var list = isHMG |  |  |  |       var list = isHMG ? hospitalList?.registeredDoctorMap![selectedRegionId]!.hmgDoctorList : hospitalList?.registeredDoctorMap![selectedRegionId]!.hmcDoctorList; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           ? hospitalList?.registeredDoctorMap![selectedRegionId]!.hmgDoctorList |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |           : hospitalList?.registeredDoctorMap![selectedRegionId]!.hmcDoctorList; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       if(list != null && list.isEmpty){ notifyListeners(); return;} |  |  |  |       if (list != null && list.isEmpty) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       var filteredList = list!.where((element) => |  |  |  |       var filteredList = list!.where((element) => element.filterName!.toLowerCase().contains(value.toLowerCase())).toList(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           element.filterName!.toLowerCase().contains(value.toLowerCase()) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       ).toList(); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       var regionData = PatientDoctorAppointmentListByRegion(); |  |  |  |       var regionData = PatientDoctorAppointmentListByRegion(); | 
			
		
	
		
		
			
				
					
					|  |  |  |       if(isHMG){ |  |  |  |       if (isHMG) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         regionData.hmgDoctorList = filteredList; |  |  |  |         regionData.hmgDoctorList = filteredList; | 
			
		
	
		
		
			
				
					
					|  |  |  |         regionData.hmgSize = filteredList.length; |  |  |  |         regionData.hmgSize = filteredList.length; | 
			
		
	
		
		
			
				
					
					|  |  |  |       } else { |  |  |  |       } else { | 
			
		
	
	
		
		
			
				
					|  |  | @ -473,9 +585,7 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |         regionData.hmcSize = filteredList.length; |  |  |  |         regionData.hmcSize = filteredList.length; | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       filteredHospitalList?.registeredDoctorMap = { |  |  |  |       filteredHospitalList?.registeredDoctorMap = {selectedRegionId!: regionData}; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         selectedRegionId! : regionData |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       }; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |     notifyListeners(); |  |  |  |     notifyListeners(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
	
		
		
			
				
					|  |  | @ -498,12 +608,12 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |     currentlySelectedHospitalFromRegionFlow = mainProjectID; |  |  |  |     currentlySelectedHospitalFromRegionFlow = mainProjectID; | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   Future<void> getRegionSelectedClinics() async{ |  |  |  |   Future<void> getRegionSelectedClinics() async { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     final result = await bookAppointmentsRepo.getClinicsWithRespectToClinicId(currentlySelectedHospitalFromRegionFlow??""); |  |  |  |     final result = await bookAppointmentsRepo.getClinicsWithRespectToClinicId(currentlySelectedHospitalFromRegionFlow ?? ""); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     result.fold( |  |  |  |     result.fold( | 
			
		
	
		
		
			
				
					
					|  |  |  |           (failure) async => await errorHandlerService.handleError(failure: failure), |  |  |  |       (failure) async => await errorHandlerService.handleError(failure: failure), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |           (apiResponse) { |  |  |  |       (apiResponse) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         if (apiResponse.messageStatus == 2) { |  |  |  |         if (apiResponse.messageStatus == 2) { | 
			
		
	
		
		
			
				
					
					|  |  |  |           // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); |  |  |  |           // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else if (apiResponse.messageStatus == 1) { |  |  |  |         } else if (apiResponse.messageStatus == 1) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -515,12 +625,12 @@ class BookAppointmentsViewModel extends ChangeNotifier { | 
			
		
	
		
		
			
				
					
					|  |  |  |       }, |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |     ); |  |  |  |     ); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |   void resetFilterList(){ |  |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   void resetFilterList() { | 
			
		
	
		
		
			
				
					
					|  |  |  |     filteredHospitalList = hospitalList; |  |  |  |     filteredHospitalList = hospitalList; | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |   void getLocation() { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   void getLocation(){ |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     locationUtils.getLocation(); |  |  |  |     locationUtils.getLocation(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |