|
|
|
|
@ -70,6 +70,10 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
FacilitySelection currentlySelectedFacility = FacilitySelection.ALL;
|
|
|
|
|
bool isRegionListLoading = false;
|
|
|
|
|
|
|
|
|
|
///this will be used to call the clinic call when navigating from my REGION SELECTION to book appointment screen
|
|
|
|
|
bool shouldLoadSpecificClinic = false;
|
|
|
|
|
String? currentlySelectedHospitalFromRegionFlow;
|
|
|
|
|
|
|
|
|
|
BookAppointmentsViewModel({required this.bookAppointmentsRepo, required this.errorHandlerService, required this.navigationService, required this.myAppointmentsViewModel});
|
|
|
|
|
|
|
|
|
|
void initializeFilteredList() {
|
|
|
|
|
@ -109,7 +113,7 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
clinicsList.clear();
|
|
|
|
|
}
|
|
|
|
|
isClinicsListLoading = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setSelectedClinic(GetClinicsListResponseModel clinic) {
|
|
|
|
|
@ -148,7 +152,18 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getClinics({Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
/// this function will decide which clinic api to be called
|
|
|
|
|
/// either api for region flow or the select clinic api
|
|
|
|
|
Future<void> getClinics() async
|
|
|
|
|
{
|
|
|
|
|
if(shouldLoadSpecificClinic) {
|
|
|
|
|
getRegionSelectedClinics();
|
|
|
|
|
} else {
|
|
|
|
|
getAllClinics();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getAllClinics({Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await bookAppointmentsRepo.getClinics();
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
@ -173,6 +188,7 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
Future<void> getDoctorsList(
|
|
|
|
|
{int projectID = 0, bool isNearest = false, int doctorId = 0, String doctorName = "", isContinueDentalPlan = false, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
doctorsList.clear();
|
|
|
|
|
projectID = currentlySelectedHospitalFromRegionFlow != null?int.parse(currentlySelectedHospitalFromRegionFlow!):projectID;
|
|
|
|
|
final result = await bookAppointmentsRepo.getDoctorsList(selectedClinic.clinicID ?? 0, projectID, isNearest, doctorId, doctorName);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
@ -391,6 +407,7 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getRegionMappedProjectList() async {
|
|
|
|
|
//todo handle the case in the location is switch on
|
|
|
|
|
if(hospitalList != null && hospitalList!.registeredDoctorMap != null && hospitalList!.registeredDoctorMap!.isNotEmpty){
|
|
|
|
|
filteredHospitalList = hospitalList;
|
|
|
|
|
return;
|
|
|
|
|
@ -469,4 +486,33 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
isLocationEnabled().then((value) => isLocationAvaiable = value);
|
|
|
|
|
return isLocationAvaiable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setLoadSpecificClinic(bool status) {
|
|
|
|
|
shouldLoadSpecificClinic = status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setProjectID(String? mainProjectID) {
|
|
|
|
|
currentlySelectedHospitalFromRegionFlow = mainProjectID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getRegionSelectedClinics() async{
|
|
|
|
|
final result = await bookAppointmentsRepo.getClinicsWithRespectToClinicId(currentlySelectedHospitalFromRegionFlow??"");
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
clinicsList = apiResponse.data!;
|
|
|
|
|
isClinicsListLoading = false;
|
|
|
|
|
initializeFilteredList();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
void resetFilterList(){
|
|
|
|
|
filteredHospitalList = hospitalList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|