Wd: Nearest appointemtn added in search by hospital

dev_v3.13.6_search_hospital_by_region
Syed Taha Alam 6 months ago
parent fff45cd3a8
commit 303e9114a3

@ -25,7 +25,7 @@ import '../../../uitl/gif_loader_dialog_utils.dart';
class ResultByClinic extends StatefulWidget { class ResultByClinic extends StatefulWidget {
HospitalsModel? selectedValue; HospitalsModel? selectedValue;
Function(RegionList) onClinicSelected; Function(RegionList, int?) onClinicSelected;
ResultByClinic({super.key, this.selectedValue, required this.onClinicSelected}); ResultByClinic({super.key, this.selectedValue, required this.onClinicSelected});
@ -165,7 +165,7 @@ class _ResultByClinicState extends State<ResultByClinic> {
), ),
).then((value) { ).then((value) {
if (value is RegionList) { if (value is RegionList) {
widget.onClinicSelected(value); widget.onClinicSelected(value,null);
} }
}); });
} }
@ -202,7 +202,7 @@ class _ResultByClinicState extends State<ResultByClinic> {
var lng = await sharedPref.getDouble(USER_LONG); var lng = await sharedPref.getDouble(USER_LONG);
var isLocationEnabled = (lat != null && lat != 0.0) && (lng != null && lng != 0.0); var isLocationEnabled = (lat != null && lat != 0.0) && (lng != null && lng != 0.0);
regionHospitalList = await DoctorMapper.sortList(isLocationEnabled, regionHospitalList); regionHospitalList = await DoctorMapper.sortList(isLocationEnabled, regionHospitalList);
widget.onClinicSelected(regionHospitalList); widget.onClinicSelected(regionHospitalList, clinicID);
setState(() {}); setState(() {});
} else { } else {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);

@ -1,7 +1,11 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/models/Appointments/OBGyneProcedureListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/OBGyneProcedureListResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/DoctorView.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/DoctorView.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -13,7 +17,10 @@ class ResultByDoctor extends StatefulWidget {
final bool isObGyneAppointment; final bool isObGyneAppointment;
final bool isDoctorNameSearch; final bool isDoctorNameSearch;
final bool isDoctorSearchResult; final bool isDoctorSearchResult;
final bool showNearestAppointment;
final bool nearestAppointmentDoctors;
final OBGyneProcedureListResponse? obGyneProcedureListResponse; final OBGyneProcedureListResponse? obGyneProcedureListResponse;
final Function(bool)? refreshDoctorList;
ResultByDoctor({ ResultByDoctor({
required this.doctorsList, required this.doctorsList,
@ -22,7 +29,10 @@ class ResultByDoctor extends StatefulWidget {
required this.isObGyneAppointment, required this.isObGyneAppointment,
required this.isDoctorNameSearch, required this.isDoctorNameSearch,
required this.isDoctorSearchResult, required this.isDoctorSearchResult,
this.showNearestAppointment = false,
this.nearestAppointmentDoctors = false,
this.obGyneProcedureListResponse, this.obGyneProcedureListResponse,
this.refreshDoctorList
}); });
@override @override
@ -30,12 +40,53 @@ class ResultByDoctor extends StatefulWidget {
} }
class _ResultByDoctorState extends State<ResultByDoctor> { class _ResultByDoctorState extends State<ResultByDoctor> {
bool nearestAppo = false;
@override
void initState() {
nearestAppo = widget.nearestAppointmentDoctors;
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return Column(
child: widget.patientDoctorAppointmentListHospital?.isNotEmpty == true children: [
? Padding(
padding: const EdgeInsets.all(12.0), Visibility(
visible: widget.showNearestAppointment,
child: Padding(
padding: const EdgeInsets.only(left: 6, right: 6,),
child: Row(
children: <Widget>[
Checkbox(
activeColor: CustomColors.accentColor,
value: nearestAppo,
onChanged: (bool? value) {
setState(() {
nearestAppo = value ?? false;
});
widget.refreshDoctorList?.call(nearestAppo);
},
),
AutoSizeText(
TranslationBase.of(context).nearestAppo.trim(),
maxLines: 1,
minFontSize: 10,
style: TextStyle(
fontSize: SizeConfig.textMultiplier! * 1.4,
fontWeight: FontWeight.w600,
letterSpacing: -0.39,
height: 0.8,
),
),
// Text(TranslationBase.of(context).nearestAppo, style: TextStyle(fontSize: 14.0, letterSpacing: -0.56)),
],
),
),
),
widget.patientDoctorAppointmentListHospital?.isNotEmpty == true
? Expanded(
child: ListView.separated( child: ListView.separated(
addAutomaticKeepAlives: true, addAutomaticKeepAlives: true,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
@ -50,21 +101,25 @@ class _ResultByDoctorState extends State<ResultByDoctor> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
final doctor = widget.patientDoctorAppointmentListHospital![index]; final doctor = widget.patientDoctorAppointmentListHospital![index];
return DoctorView( return Padding(
doctor: doctor, padding: const EdgeInsets.symmetric(horizontal: 12.0),
isLiveCareAppointment: widget.isLiveCareAppointment, child: DoctorView(
isObGyneAppointment: widget.isObGyneAppointment, doctor: doctor,
isDoctorNameSearch: widget.isDoctorNameSearch, isLiveCareAppointment: widget.isLiveCareAppointment,
obGyneProcedureListResponse: widget.obGyneProcedureListResponse, isObGyneAppointment: widget.isObGyneAppointment,
isShowDate: false, isDoctorNameSearch: widget.isDoctorNameSearch,
onTap: () { obGyneProcedureListResponse: widget.obGyneProcedureListResponse,
context.read<ProjectViewModel>().analytics.appointment.book_appointment_select_doctor(appointment_type: 'regular', doctor: doctor); isShowDate: false,
}); onTap: () {
context.read<ProjectViewModel>().analytics.appointment.book_appointment_select_doctor(appointment_type: 'regular', doctor: doctor);
}),
);
}, },
itemCount: widget.patientDoctorAppointmentListHospital?.length ?? 0, itemCount: widget.patientDoctorAppointmentListHospital?.length ?? 0,
), ),
) )
: getNoDataWidget(context), : getNoDataWidget(context),
],
); );
} }

@ -9,7 +9,11 @@ import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultB
import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByHospital.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByHospital.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByRegion.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByRegion.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/DoctorView.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/DoctorView.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/services/appointment_services/doctor_response_mapper.dart';
import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart';
@ -17,6 +21,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../../config/shared_pref_kay.dart';
import '../../../core/service/client/base_app_client.dart';
class SearchResultWithTabForHospital extends StatefulWidget { class SearchResultWithTabForHospital extends StatefulWidget {
List<DoctorList> doctorsList = []; List<DoctorList> doctorsList = [];
RegionList patientDoctorAppointmentListHospital; RegionList patientDoctorAppointmentListHospital;
@ -54,6 +61,8 @@ class _SearchResultWithTabForHospitalState
int selectedHospitalIndex = -1; int selectedHospitalIndex = -1;
ScrollController scrollController = ScrollController(); ScrollController scrollController = ScrollController();
RegionList? doctorList; RegionList? doctorList;
bool nearestAppointment= false;
int clinicId = -1;
@override @override
void initState() { void initState() {
@ -135,6 +144,8 @@ class _SearchResultWithTabForHospitalState
doctorList = null; doctorList = null;
_currentIndex = 0; _currentIndex = 0;
changePageViewIndex(0); changePageViewIndex(0);
nearestAppointment = false;
clinicId = -1;
}); });
}, },
), ),
@ -159,6 +170,9 @@ class _SearchResultWithTabForHospitalState
doctorList = null; doctorList = null;
_currentIndex = 1; _currentIndex = 1;
changePageViewIndex(1); changePageViewIndex(1);
nearestAppointment = false;
clinicId = -1;
}); });
}, },
), ),
@ -183,6 +197,9 @@ class _SearchResultWithTabForHospitalState
doctorList = null; doctorList = null;
_currentIndex = 2; _currentIndex = 2;
changePageViewIndex(2); changePageViewIndex(2);
nearestAppointment = false;
clinicId = -1;
}); });
}, },
), ),
@ -203,9 +220,12 @@ class _SearchResultWithTabForHospitalState
: CustomColors.grey2, : CustomColors.grey2,
onTap: () { onTap: () {
setState(() { setState(() {
_currentIndex = 3;
doctorList = null; doctorList = null;
changePageViewIndex(3); changePageViewIndex(3);
_currentIndex = 3;
nearestAppointment= false;
clinicId = -1;
}); });
}, },
), ),
@ -350,11 +370,14 @@ class _SearchResultWithTabForHospitalState
selectedRegion != '' && selectedRegion != '' &&
selectedHospitalIndex != -1) selectedHospitalIndex != -1)
? ResultByClinic( ? ResultByClinic(
onClinicSelected: (doctorList) { onClinicSelected: (doctorList, clinicId) {
setState(() { setState(() {
this.nearestAppointment = false;
this.doctorList = doctorList; this.doctorList = doctorList;
_currentIndex = 4; _currentIndex = 4;
changePageViewIndex(4); changePageViewIndex(4);
if(clinicId != null)
this.clinicId = clinicId;
}); });
}, },
selectedValue: selectedHospital) selectedValue: selectedHospital)
@ -384,7 +407,19 @@ class _SearchResultWithTabForHospitalState
widget.isLiveCareAppointment, widget.isLiveCareAppointment,
isDoctorSearchResult: widget.isDoctorSearchResult, isDoctorSearchResult: widget.isDoctorSearchResult,
isObGyneAppointment: widget.isObGyneAppointment, isObGyneAppointment: widget.isObGyneAppointment,
isDoctorNameSearch: widget.isDoctorNameSearch) isDoctorNameSearch: widget.isDoctorNameSearch,
showNearestAppointment: clinicId != -1 ,
nearestAppointmentDoctors: nearestAppointment,
refreshDoctorList: (isNearestAppointmentChecked){
setState(() {
// changePageViewIndex(3);
// _currentIndex = 3;
nearestAppointment= false;
});
callDoctorsSearchAPI(clinicId, isNearestAppointmentChecked);
},
)
: SizedBox.shrink(), : SizedBox.shrink(),
], ],
), ),
@ -395,6 +430,62 @@ class _SearchResultWithTabForHospitalState
); );
} }
callDoctorsSearchAPI(int clinicID, bool nearestAppointment) {
var isArabic = context.read<ProjectViewModel>().isArabic;
int languageID = isArabic ? 1 : 2;
GifLoaderDialogUtils.showMyDialog(context);
List<DoctorList> doctorsList = [];
List<String> arr = [];
List<String> arrDistance = [];
List<String> result;
int numAll;
List<PatientDoctorAppointmentList> _patientDoctorAppointmentListHospital = [];
DoctorsListService service = new DoctorsListService();
service
.getDoctorsList(clinicID, selectedHospital?.mainProjectID.toString() != "" ? int.parse(selectedHospital?.mainProjectID.toString() ?? "-1") : 0, nearestAppointment, languageID, null)
.then((res) async {
GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) {
RegionList regionHospitalList = RegionList();
if (res['DoctorList'].length != 0) {
res['DoctorList'].forEach((v) {
doctorsList.add(new DoctorList.fromJson(
v,
));
});
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(() {
this.doctorList = regionHospitalList;
_currentIndex = 4;
changePageViewIndex(4);
this.nearestAppointment = nearestAppointment;
});
} else {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: res['ErrorSearchMsg']);
}
GifLoaderDialogUtils.hideDialog(context);
// navigateToSearchResults(context, doctorsList, _patientDoctorAppointmentListHospital);
} else {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
AppToast.showErrorToast(message: err, localContext: context);
});
}
String getTitle() { String getTitle() {
switch (_currentIndex) { switch (_currentIndex) {
case 0: case 0:

Loading…
Cancel
Save