|
|
|
@ -1,8 +1,10 @@
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/core/cache_consts.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/doctor_response_mapper.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
|
|
@ -13,6 +15,8 @@ import 'package:hmg_patient_app_new/features/book_appointments/models/resp_model
|
|
|
|
import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/doctors_list_response_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/doctors_list_response_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/get_clinic_list_response_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/get_clinic_list_response_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/book_appointments/models/timeslots.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/book_appointments/models/timeslots.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/facility_selection.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/doctor_list_api_response.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
@ -21,6 +25,7 @@ import 'package:hmg_patient_app_new/services/error_handler_service.dart';
|
|
|
|
import 'package:hmg_patient_app_new/services/navigation_service.dart';
|
|
|
|
import 'package:hmg_patient_app_new/services/navigation_service.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.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;
|
|
|
|
|
|
|
|
|
|
|
|
class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
int selectedTabIndex = 0;
|
|
|
|
int selectedTabIndex = 0;
|
|
|
|
@ -60,6 +65,10 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
MyAppointmentsViewModel myAppointmentsViewModel;
|
|
|
|
MyAppointmentsViewModel myAppointmentsViewModel;
|
|
|
|
|
|
|
|
|
|
|
|
late AppState _appState;
|
|
|
|
late AppState _appState;
|
|
|
|
|
|
|
|
RegionList? hospitalList;
|
|
|
|
|
|
|
|
RegionList? filteredHospitalList;
|
|
|
|
|
|
|
|
FacilitySelection currentlySelectedFacility = FacilitySelection.ALL;
|
|
|
|
|
|
|
|
bool isRegionListLoading = false;
|
|
|
|
|
|
|
|
|
|
|
|
BookAppointmentsViewModel({required this.bookAppointmentsRepo, required this.errorHandlerService, required this.navigationService, required this.myAppointmentsViewModel});
|
|
|
|
BookAppointmentsViewModel({required this.bookAppointmentsRepo, required this.errorHandlerService, required this.navigationService, required this.myAppointmentsViewModel});
|
|
|
|
|
|
|
|
|
|
|
|
@ -380,4 +389,84 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> getRegionMappedProjectList() async {
|
|
|
|
|
|
|
|
if(hospitalList != null && hospitalList!.registeredDoctorMap != null && hospitalList!.registeredDoctorMap!.isNotEmpty){
|
|
|
|
|
|
|
|
filteredHospitalList = hospitalList;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
isRegionListLoading = true;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
final result = await bookAppointmentsRepo.getProjectList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
|
|
|
(failure) async =>
|
|
|
|
|
|
|
|
await errorHandlerService.handleError(failure: failure),
|
|
|
|
|
|
|
|
(apiResponse) async {
|
|
|
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
|
|
|
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
|
|
|
|
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
|
|
|
|
var projectList = apiResponse.data!;
|
|
|
|
|
|
|
|
hospitalList = await DoctorMapper.getMappedHospitals(projectList,
|
|
|
|
|
|
|
|
isArabic: false);
|
|
|
|
|
|
|
|
var lat = await Utils.getNumFromPrefs(CacheConst.userLat);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lng = await Utils.getNumFromPrefs(CacheConst.userLong);
|
|
|
|
|
|
|
|
var isLocationEnabled = (lat != 0) && (lng != 0);
|
|
|
|
|
|
|
|
hospitalList =
|
|
|
|
|
|
|
|
await DoctorMapper.sortList(isLocationEnabled, hospitalList!);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isRegionListLoading = false;
|
|
|
|
|
|
|
|
filteredHospitalList = hospitalList;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setSelectedFacility(FacilitySelection selection) {
|
|
|
|
|
|
|
|
currentlySelectedFacility = selection;
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void filterHospitalListByString(String? value, String? selectedRegionId, bool isHMG) {
|
|
|
|
|
|
|
|
if(value ==null || value.isEmpty){
|
|
|
|
|
|
|
|
filteredHospitalList = hospitalList;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
filteredHospitalList = RegionList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var list = isHMG
|
|
|
|
|
|
|
|
? hospitalList?.registeredDoctorMap![selectedRegionId]!.hmgDoctorList
|
|
|
|
|
|
|
|
: hospitalList?.registeredDoctorMap![selectedRegionId]!.hmcDoctorList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(list != null && list.isEmpty){ notifyListeners(); return;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var filteredList = list!.where((element) =>
|
|
|
|
|
|
|
|
element.filterName!.toLowerCase().contains(value.toLowerCase())
|
|
|
|
|
|
|
|
).toList();
|
|
|
|
|
|
|
|
var regionData = PatientDoctorAppointmentListByRegion();
|
|
|
|
|
|
|
|
if(isHMG){
|
|
|
|
|
|
|
|
regionData.hmgDoctorList = filteredList;
|
|
|
|
|
|
|
|
regionData.hmgSize = filteredList.length;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
regionData.hmcDoctorList = filteredList;
|
|
|
|
|
|
|
|
regionData.hmcSize = filteredList.length;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filteredHospitalList?.registeredDoctorMap = {
|
|
|
|
|
|
|
|
selectedRegionId! : regionData
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<bool> isLocationEnabled() async{
|
|
|
|
|
|
|
|
return await Location().serviceEnabled();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool getLocationStatus() {
|
|
|
|
|
|
|
|
bool isLocationAvaiable = false;
|
|
|
|
|
|
|
|
isLocationEnabled().then((value) => isLocationAvaiable = value);
|
|
|
|
|
|
|
|
return isLocationAvaiable;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|