|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
@ -87,6 +88,7 @@ class _SearchByDoctorState extends State<SearchByDoctor> {
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if (_isButtonDisabled == false) {
|
|
|
|
|
FocusManager.instance.primaryFocus?.unfocus();
|
|
|
|
|
_searchDoctor(context);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -98,69 +100,58 @@ class _SearchByDoctorState extends State<SearchByDoctor> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDoctorsList(BuildContext context) {
|
|
|
|
|
bool isArabic = context.read<ProjectViewModel>().isArabic;
|
|
|
|
|
int languageID = isArabic ? 1 : 2;
|
|
|
|
|
int languageID = context.read<ProjectViewModel>().isArabic ? 1 : 2;
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
List<DoctorList> doctorsList = [];
|
|
|
|
|
DoctorsListService service = new DoctorsListService();
|
|
|
|
|
var counter = 0;
|
|
|
|
|
var isHmc = false;
|
|
|
|
|
|
|
|
|
|
List<PatientDoctorAppointmentList> _patientDoctorAppointmentListHospital =
|
|
|
|
|
[];
|
|
|
|
|
|
|
|
|
|
service
|
|
|
|
|
.getDoctorsListByName(doctorNameController.text, languageID, context)
|
|
|
|
|
.then((res) async {
|
|
|
|
|
.then((res) {
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
RegionList regionHospitalList = RegionList();
|
|
|
|
|
setState(() {
|
|
|
|
|
if (res['DoctorList'].length != 0) {
|
|
|
|
|
res['DoctorList'].forEach((v) {
|
|
|
|
|
doctorsList.add(new DoctorList.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (res['DoctorList'].length != 0) {
|
|
|
|
|
res['DoctorList'].forEach((v) {
|
|
|
|
|
// var reg = region[counter % 4];
|
|
|
|
|
// counter++;
|
|
|
|
|
doctorsList.add(new DoctorList.fromJson(
|
|
|
|
|
v,
|
|
|
|
|
));
|
|
|
|
|
// isHmc = !isHmc;
|
|
|
|
|
});
|
|
|
|
|
// print('the counter is ${counter}');
|
|
|
|
|
|
|
|
|
|
regionHospitalList = await DoctorMapper.getMappedDoctor(doctorsList,
|
|
|
|
|
isArabic: isArabic);
|
|
|
|
|
var lat = await sharedPref.getDouble(USER_LAT);
|
|
|
|
|
|
|
|
|
|
var lng = await sharedPref.getDouble(USER_LONG);
|
|
|
|
|
var isLocationEnabled =
|
|
|
|
|
(lat != null && lat != 0.0) && (lng != null && lng != 0.0);
|
|
|
|
|
regionHospitalList = await DoctorMapper.sortList(
|
|
|
|
|
isLocationEnabled, regionHospitalList);
|
|
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
// doctorsList.forEach((element) {
|
|
|
|
|
// List<PatientDoctorAppointmentList> doctorByHospital =
|
|
|
|
|
// _patientDoctorAppointmentListHospital.where((elementClinic) => elementClinic.filterName == element.getProjectCompleteName()).toList();
|
|
|
|
|
//
|
|
|
|
|
// if (doctorByHospital.length != 0) {
|
|
|
|
|
// _patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList!.add(element);
|
|
|
|
|
// } else {
|
|
|
|
|
// _patientDoctorAppointmentListHospital.add(PatientDoctorAppointmentList(
|
|
|
|
|
// filterName: element.getProjectCompleteName(),
|
|
|
|
|
// distanceInKMs: element.projectDistanceInKiloMeters.toString(),
|
|
|
|
|
// projectTopName: element.projectTopName,
|
|
|
|
|
// projectBottomName: element.projectBottomName,
|
|
|
|
|
// patientDoctorAppointment: element));
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
} else {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: res['ErrorSearchMsg']);
|
|
|
|
|
}
|
|
|
|
|
doctorsList.forEach((element) {
|
|
|
|
|
List<PatientDoctorAppointmentList> doctorByHospital =
|
|
|
|
|
_patientDoctorAppointmentListHospital
|
|
|
|
|
.where((elementClinic) =>
|
|
|
|
|
elementClinic.filterName ==
|
|
|
|
|
element.getProjectCompleteName())
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
if (doctorByHospital.length != 0) {
|
|
|
|
|
_patientDoctorAppointmentListHospital[
|
|
|
|
|
_patientDoctorAppointmentListHospital
|
|
|
|
|
.indexOf(doctorByHospital[0])]
|
|
|
|
|
.patientDoctorAppointmentList!
|
|
|
|
|
.add(element);
|
|
|
|
|
} else {
|
|
|
|
|
_patientDoctorAppointmentListHospital.add(
|
|
|
|
|
PatientDoctorAppointmentList(
|
|
|
|
|
filterName: element.getProjectCompleteName(),
|
|
|
|
|
distanceInKMs:
|
|
|
|
|
element.projectDistanceInKiloMeters.toString(),
|
|
|
|
|
projectTopName: element.projectTopName,
|
|
|
|
|
projectBottomName: element.projectBottomName,
|
|
|
|
|
patientDoctorAppointment: element));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: res['ErrorSearchMsg']);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
// navigateToSearchResults(context, doctorsList, _patientDoctorAppointmentListHospital);
|
|
|
|
|
navigateToSearchResults(context, regionHospitalList);
|
|
|
|
|
navigateToSearchResults(
|
|
|
|
|
context, doctorsList, _patientDoctorAppointmentListHospital);
|
|
|
|
|
} else {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
|
|
|
|
|
@ -195,16 +186,17 @@ class _SearchByDoctorState extends State<SearchByDoctor> {
|
|
|
|
|
.book_appointment_doctor_search(query: doctorNameController.text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
navigateToSearchResults(context, RegionList regionHospitalList) {
|
|
|
|
|
// Navigator.push(context,
|
|
|
|
|
// FadePage(page: SearchResults(isLiveCareAppointment: false, isDoctorNameSearch: true, doctorsList: docList, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital, isDoctorSearchResult: true,)));
|
|
|
|
|
navigateToSearchResults(context, List<DoctorList> docList,
|
|
|
|
|
List<PatientDoctorAppointmentList> patientDoctorAppointmentListHospital) {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
FadePage(
|
|
|
|
|
page: SearchResultWithTab(
|
|
|
|
|
doctorsList: [],
|
|
|
|
|
patientDoctorAppointmentListHospital: regionHospitalList,
|
|
|
|
|
page: SearchResults(
|
|
|
|
|
isLiveCareAppointment: false,
|
|
|
|
|
isDoctorNameSearch: true,
|
|
|
|
|
doctorsList: docList,
|
|
|
|
|
patientDoctorAppointmentListHospital:
|
|
|
|
|
patientDoctorAppointmentListHospital,
|
|
|
|
|
isDoctorSearchResult: true,
|
|
|
|
|
)));
|
|
|
|
|
}
|
|
|
|
|
|