|
|
|
|
@ -331,6 +331,42 @@ class BookAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void filterDoctors(String query) {
|
|
|
|
|
if (query.isEmpty) {
|
|
|
|
|
filteredDoctorList = List.from(doctorsList);
|
|
|
|
|
// _groupDoctorsList();
|
|
|
|
|
setIsNearestAppointmentSelected(isNearestAppointmentSelected);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
filteredDoctorList = doctorsList.where((doctor) {
|
|
|
|
|
final name = (doctor.name ?? '').toLowerCase();
|
|
|
|
|
final clinicName = (doctor.clinicName ?? '').toLowerCase();
|
|
|
|
|
final projectName = (doctor.projectName ?? '').toLowerCase();
|
|
|
|
|
final q = query.toLowerCase();
|
|
|
|
|
return name.contains(q) || clinicName.contains(q) || projectName.contains(q);
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
// Re-group filtered list
|
|
|
|
|
final clinicMap = <String, List<DoctorsListResponseModel>>{};
|
|
|
|
|
final hospitalMap = <String, List<DoctorsListResponseModel>>{};
|
|
|
|
|
|
|
|
|
|
for (var doctor in filteredDoctorList) {
|
|
|
|
|
final clinicKey = (doctor.clinicName ?? 'Unknown').trim();
|
|
|
|
|
clinicMap.putIfAbsent(clinicKey, () => []).add(doctor);
|
|
|
|
|
|
|
|
|
|
final hospitalKey = (doctor.projectName ?? 'Unknown').trim();
|
|
|
|
|
hospitalMap.putIfAbsent(hospitalKey, () => []).add(doctor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
doctorsListByClinic = clinicMap.values.toList();
|
|
|
|
|
doctorsListByHospital = hospitalMap.values.toList();
|
|
|
|
|
doctorsListGrouped = isSortByClinic ? doctorsListByClinic : doctorsListByHospital;
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void filterClinics(String? query) {
|
|
|
|
|
if (query!.isEmpty) {
|
|
|
|
|
_filteredClinicsList = List.from(clinicsList);
|
|
|
|
|
|