diff --git a/assets/images/svg/HMC.svg b/assets/images/svg/HMC.svg index ab082893..a127cd98 100644 --- a/assets/images/svg/HMC.svg +++ b/assets/images/svg/HMC.svg @@ -1,9 +1,8 @@ - - - - - - - - + + + diff --git a/assets/images/svg/HMG.svg b/assets/images/svg/HMG.svg index 0c59d4ba..7b199bf5 100644 --- a/assets/images/svg/HMG.svg +++ b/assets/images/svg/HMG.svg @@ -1,12 +1,8 @@ - - - - - - - - - - - + + + diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index efcd2053..d0314911 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -2146,11 +2146,16 @@ const Map localizedValues = { "selectRegion": {"en": "Select Region", "ar": "اختر المنطقة"}, "selectFacitlity": {"en": "Select Facility", "ar": "اختر المنشأة"}, "selectDoctor": {"en": "Select Doctor", "ar": "اختر الطبيب"}, - "hmgHospital": {"en": "HMG Hospital", "ar": "مستشفى HMG"}, - "hmcHospital": {"en": "HMG Medical Center", "ar": "مركز إتش إم جي الطبي"}, - "hmcHospitalCount": { - "en": "@ HMG Medical Center", - "ar": "@ مركز إتش إم جي الطبي" - }, - "hmgHospitalCount": {"en": "@ HMG Hospital", "ar": "@ مستشفى HMG"}, + "hmgHospital": {"en": "Hospital", "ar": "المستشفيات "}, + "hmcHospital": {"en": "Medical Center", "ar": "المراكز الطبية"}, + "hmcHospitalCountSingle": { + "en": "@ Medical Center", + "ar": "المراكز الطبية @" + }, + "hmgHospitalCountSingle": {"en": "@ Hospital", "ar": "المستشفيات @"}, + "hmcHospitalCountPlural": { + "en": "@ Medical Centers", + "ar": "المراكز الطبية @" + }, + "hmgHospitalCountPlural": {"en": "@ Hospitals", "ar": "المستشفيات @"}, }; diff --git a/lib/core/model/hospitals/hospitals_model.dart b/lib/core/model/hospitals/hospitals_model.dart index 56a70511..5fa1677f 100644 --- a/lib/core/model/hospitals/hospitals_model.dart +++ b/lib/core/model/hospitals/hospitals_model.dart @@ -15,6 +15,11 @@ class HospitalsModel { dynamic mainProjectID; bool? projectOutSA; bool? usingInDoctorApp; + bool? isHMC; + String? region; + String? regionArabic; + String? regionEnglish; + String? regionID; HospitalsModel( {this.desciption, @@ -32,7 +37,13 @@ class HospitalsModel { this.longitude, this.mainProjectID, this.projectOutSA, - this.usingInDoctorApp}); + this.usingInDoctorApp, + this.isHMC, + this.region, + this.regionArabic, + this.regionEnglish, + this.regionID, + }); HospitalsModel.fromJson(Map json) { desciption = json['Desciption']; @@ -51,6 +62,16 @@ class HospitalsModel { mainProjectID = json['MainProjectID']; projectOutSA = json['ProjectOutSA']; usingInDoctorApp = json['UsingInDoctorApp']; + this.isHMC = json["IsHMC"]; + this.regionArabic = json['RegionNameN']; + this.regionEnglish = json['RegionName']; + } + + String? getRegionName(bool isArabic) { + if (isArabic) { + return regionArabic; + } + return regionEnglish; } Map toJson() { diff --git a/lib/models/Appointments/DoctorListResponse.dart b/lib/models/Appointments/DoctorListResponse.dart index 70576a40..afecab8a 100644 --- a/lib/models/Appointments/DoctorListResponse.dart +++ b/lib/models/Appointments/DoctorListResponse.dart @@ -1,3 +1,5 @@ +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; + class DoctorList { int? clinicID; dynamic appointmentNo; @@ -229,9 +231,21 @@ class PatientDoctorAppointmentList { List? patientDoctorAppointmentList = []; String? projectTopName = ""; String? projectBottomName = ""; + List hospitalList = []; - PatientDoctorAppointmentList({this.filterName, this.distanceInKMs, this.projectTopName, this.projectBottomName, DoctorList? patientDoctorAppointment}) { - patientDoctorAppointmentList!.add(patientDoctorAppointment!); + PatientDoctorAppointmentList( + {this.filterName, + this.distanceInKMs, + this.projectTopName, + this.projectBottomName, + DoctorList? patientDoctorAppointment, + HospitalsModel? model}) { + if (model != null) { + hospitalList.add(model); + } + if (patientDoctorAppointment != null) { + patientDoctorAppointmentList!.add(patientDoctorAppointment!); + } } } diff --git a/lib/pages/BookAppointment/DentalComplaints.dart b/lib/pages/BookAppointment/DentalComplaints.dart index 44546b11..62a9ddea 100644 --- a/lib/pages/BookAppointment/DentalComplaints.dart +++ b/lib/pages/BookAppointment/DentalComplaints.dart @@ -26,8 +26,13 @@ class DentalComplaints extends StatefulWidget { SearchInfo searchInfo; Function? onSelectedMethod; bool isDoctorNameSearch; + bool isFromHospitalSearchPage; - DentalComplaints({required this.searchInfo, this.onSelectedMethod, this.isDoctorNameSearch = false}); + DentalComplaints( + {required this.searchInfo, + this.onSelectedMethod, + this.isDoctorNameSearch = false, + this.isFromHospitalSearchPage = false}); @override _DentalComplaintsState createState() => _DentalComplaintsState(); @@ -75,6 +80,12 @@ class _DentalComplaintsState extends State { languageID: languageID, isDoctorNameSearch: widget.isDoctorNameSearch, onSelectedMethod: widget.onSelectedMethod, + isFromHospitalSearchPage: widget.isFromHospitalSearchPage, + onDoctorFetched: widget.isFromHospitalSearchPage + ? (doctorsList) { + Navigator.pop(context, doctorsList); + } + : null, )..logAnalytics = () { final info = widget.searchInfo; locator() diff --git a/lib/pages/BookAppointment/SearchResultsByRegion.dart b/lib/pages/BookAppointment/SearchResultsByRegion.dart index effbb7f0..a1666ffc 100644 --- a/lib/pages/BookAppointment/SearchResultsByRegion.dart +++ b/lib/pages/BookAppointment/SearchResultsByRegion.dart @@ -304,7 +304,7 @@ class RegionTitle extends StatelessWidget { Row( children: [ Text( - "${TranslationBase.of(context).hmgHospitalCount.replaceAll("@", hmgCount)} ,", + "${TranslationBase.of(context).HospitalString(num.parse(hmgCount)).replaceAll("@", hmgCount)} ,", style: TextStyle( fontSize: 14, color: Color(0xFFD02127), @@ -314,7 +314,7 @@ class RegionTitle extends StatelessWidget { width: 8, ), Text( - "${TranslationBase.of(context).hmcHospitalCount.replaceAll("@", hmcCount)}", + "${TranslationBase.of(context).MedicalCenterString(num.parse(hmcCount)).replaceAll("@", hmcCount)}", style: TextStyle( fontSize: 14, color: Color(0xFF40ACC9), @@ -368,8 +368,8 @@ class HospitalTitle extends StatelessWidget { ), Text( isHMC - ? "${TranslationBase.of(context).hmcHospitalCount.replaceAll("@", itemCount)}" - : "${TranslationBase.of(context).hmgHospitalCount.replaceAll("@", itemCount)}", + ? "${TranslationBase.of(context).MedicalCenterString(num.parse(itemCount)).replaceAll("@", itemCount)}" + : "${TranslationBase.of(context).HospitalString(num.parse(itemCount)).replaceAll("@", itemCount)}", style: TextStyle( fontSize: 12, color: Colors.black, fontWeight: FontWeight.w600), ), diff --git a/lib/pages/BookAppointment/components/search_by_hospital_name.dart b/lib/pages/BookAppointment/components/search_by_hospital_name.dart index eb9bd9e5..bca54daf 100644 --- a/lib/pages/BookAppointment/components/search_by_hospital_name.dart +++ b/lib/pages/BookAppointment/components/search_by_hospital_name.dart @@ -1,17 +1,13 @@ -import 'package:auto_size_text/auto_size_text.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResultsByRegion.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/components/LaserClinic.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/SearchResultWithTab.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/SearchResultWithTabForHospital.dart'; import 'package:diplomaticquarterapp/services/appointment_services/doctor_response_mapper.dart'; -import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/location_util.dart'; -import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import '../../../config/size_config.dart'; import '../../../core/model/hospitals/hospitals_model.dart'; import '../../../core/viewModels/project_view_model.dart'; import '../../../models/Appointments/DoctorListResponse.dart'; @@ -26,7 +22,6 @@ import '../../../uitl/translations_delegate_base.dart'; import '../../../widgets/transitions/fade_page.dart'; import '../../livecare/livecare_home.dart'; import '../DentalComplaints.dart'; -import '../dialog/clinic_list_dialog.dart'; import 'LiveCareBookAppointment.dart'; class SearchByHospital extends StatefulWidget { @@ -37,6 +32,7 @@ class SearchByHospital extends StatefulWidget { class _SearchByHospitalState extends State { HospitalsModel? selectedHospital; bool nearestAppo = false; + RegionList? hospitalList; String? selectedClinicName; List projectsList = []; @@ -64,161 +60,168 @@ class _SearchByHospitalState extends State { @override Widget build(BuildContext context) { AppGlobal.context = context; - - return Column( - children: [ - Padding( - padding: const EdgeInsets.only(left: 6, right: 6, top: 16), - child: Row( - children: [ - Checkbox( - activeColor: CustomColors.accentColor, - value: nearestAppo, - onChanged: (bool? value) { - nearestAppo = value ?? false; - setState(() {}); - }, - ), - 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)), - ], - ), - ), - mHeight(8), - InkWell( - onTap: () { - openDropdown(projectDropdownKey); - }, - child: Container( - width: double.infinity, - decoration: containerRadius(Colors.white, 12), - margin: EdgeInsets.only(left: 20, right: 20), - padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12), - child: Row( - children: [ - Flexible( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).selectHospital, - style: TextStyle( - fontSize: 11, - letterSpacing: -0.44, - fontWeight: FontWeight.w600, - ), - ), - Container( - height: 18, - width: double.infinity, - child: DropdownButtonHideUnderline( - child: DropdownButton( - key: projectDropdownKey, - hint: Text(TranslationBase.of(context).selectHospital), - value: selectedHospital, - iconSize: 0, - isExpanded: true, - style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black), - items: projectsList.map((HospitalsModel item) { - return DropdownMenuItem( - value: item, - child: AutoSizeText( - item.name!, - maxLines: 1, - minFontSize: 10, - style: TextStyle( - fontSize: SizeConfig.textMultiplier! * 1.6, - fontWeight: FontWeight.w600, - letterSpacing: -0.39, - height: 0.8, - ), - ), - // Text('${item.name!}'), - ); - }).toList(), - onChanged: (HospitalsModel? newValue) { - getClinicWrtHospital(newValue); - setState(() { - selectedHospital = newValue; - }); - }, - ), - ), - ), - ], - ), - ), - Icon(Icons.keyboard_arrow_down), - ], - )), - ), - if (clinicIds?.isNotEmpty == true) ...[ - mHeight(8), - InkWell( - onTap: () { - showClickListDialog(context, clinicIds ?? List.empty(), onSelection: (ListClinicCentralized clincs) { - selectedClinic = clincs; - Navigator.pop(context); - setState(() { - dropdownTitle = clincs.clinicDescription!; - dropdownValue = clincs.clinicID.toString() + "-" + clincs.isLiveCareClinicAndOnline.toString() + "-" + clincs.liveCareClinicID.toString() + "-" + clincs.liveCareServiceID.toString(); - }); - getDoctorsList(context); - - context.read().analytics.appointment.book_appointment_select_clinic(appointment_type: 'regular', clinic: clincs.clinicDescription); - }); - }, - child: Container( - width: double.infinity, - decoration: containerRadius(Colors.white, 12), - margin: EdgeInsets.only(left: 20, right: 20), - padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 8), - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).selectClinic, - style: TextStyle( - fontSize: 11, - letterSpacing: -0.44, - fontWeight: FontWeight.w600, - ), - ), - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 2), - child: Text( - dropdownTitle, - style: TextStyle( - fontSize: 13, - letterSpacing: -0.44, - fontWeight: FontWeight.w600, - ), - ), - ), - ], - ), - ), - Icon(Icons.keyboard_arrow_down), - ], - ), - ), + return (hospitalList != null) + ? SearchResultWithTabForHospital( + patientDoctorAppointmentListHospital: hospitalList!, + doctorsList: [], + isDoctorSearchResult: false, + isLiveCareAppointment: false, ) - ] - ], - ); + : SizedBox.shrink(); + // return Column( + // children: [ + // Padding( + // padding: const EdgeInsets.only(left: 6, right: 6, top: 16), + // child: Row( + // children: [ + // Checkbox( + // activeColor: CustomColors.accentColor, + // value: nearestAppo, + // onChanged: (bool? value) { + // nearestAppo = value ?? false; + // setState(() {}); + // }, + // ), + // 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)), + // ], + // ), + // ), + // mHeight(8), + // InkWell( + // onTap: () { + // openDropdown(projectDropdownKey); + // }, + // child: Container( + // width: double.infinity, + // decoration: containerRadius(Colors.white, 12), + // margin: EdgeInsets.only(left: 20, right: 20), + // padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12), + // child: Row( + // children: [ + // Flexible( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // TranslationBase.of(context).selectHospital, + // style: TextStyle( + // fontSize: 11, + // letterSpacing: -0.44, + // fontWeight: FontWeight.w600, + // ), + // ), + // Container( + // height: 18, + // width: double.infinity, + // child: DropdownButtonHideUnderline( + // child: DropdownButton( + // key: projectDropdownKey, + // hint: Text(TranslationBase.of(context).selectHospital), + // value: selectedHospital, + // iconSize: 0, + // isExpanded: true, + // style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black), + // items: projectsList.map((HospitalsModel item) { + // return DropdownMenuItem( + // value: item, + // child: AutoSizeText( + // item.name!, + // maxLines: 1, + // minFontSize: 10, + // style: TextStyle( + // fontSize: SizeConfig.textMultiplier! * 1.6, + // fontWeight: FontWeight.w600, + // letterSpacing: -0.39, + // height: 0.8, + // ), + // ), + // // Text('${item.name!}'), + // ); + // }).toList(), + // onChanged: (HospitalsModel? newValue) { + // getClinicWrtHospital(newValue); + // setState(() { + // selectedHospital = newValue; + // }); + // }, + // ), + // ), + // ), + // ], + // ), + // ), + // Icon(Icons.keyboard_arrow_down), + // ], + // )), + // ), + // if (clinicIds?.isNotEmpty == true) ...[ + // mHeight(8), + // InkWell( + // onTap: () { + // showClickListDialog(context, clinicIds ?? List.empty(), onSelection: (ListClinicCentralized clincs) { + // selectedClinic = clincs; + // Navigator.pop(context); + // setState(() { + // dropdownTitle = clincs.clinicDescription!; + // dropdownValue = clincs.clinicID.toString() + "-" + clincs.isLiveCareClinicAndOnline.toString() + "-" + clincs.liveCareClinicID.toString() + "-" + clincs.liveCareServiceID.toString(); + // }); + // getDoctorsList(context); + // + // context.read().analytics.appointment.book_appointment_select_clinic(appointment_type: 'regular', clinic: clincs.clinicDescription); + // }); + // }, + // child: Container( + // width: double.infinity, + // decoration: containerRadius(Colors.white, 12), + // margin: EdgeInsets.only(left: 20, right: 20), + // padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 8), + // child: Row( + // children: [ + // Expanded( + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // TranslationBase.of(context).selectClinic, + // style: TextStyle( + // fontSize: 11, + // letterSpacing: -0.44, + // fontWeight: FontWeight.w600, + // ), + // ), + // Padding( + // padding: const EdgeInsets.only(top: 4, bottom: 2), + // child: Text( + // dropdownTitle, + // style: TextStyle( + // fontSize: 13, + // letterSpacing: -0.44, + // fontWeight: FontWeight.w600, + // ), + // ), + // ), + // ], + // ), + // ), + // Icon(Icons.keyboard_arrow_down), + // ], + // ), + // ), + // ) + // ] + // ], + // ); } void openDropdown(GlobalKey key) { @@ -263,16 +266,17 @@ class _SearchByHospitalState extends State { ClinicListService service = new ClinicListService(); List projectsListLocal = []; service.getProjectsList(languageID, context).then((res) { - GifLoaderDialogUtils.hideDialog(context); - if (res['MessageStatus'] == 1) { - setState(() { + setState(() async { res['ListProject'].forEach((v) { projectsListLocal.add(new HospitalsModel.fromJson(v)); }); projectsList = projectsListLocal; + hospitalList = await DoctorMapper.getMappedHospitals(projectsList); }); + GifLoaderDialogUtils.hideDialog(context); } else {} + GifLoaderDialogUtils.hideDialog(context); locationUtils.getCurrentLocation(); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); diff --git a/lib/pages/BookAppointment/search_result/ResultByClinic.dart b/lib/pages/BookAppointment/search_result/ResultByClinic.dart new file mode 100644 index 00000000..9c532140 --- /dev/null +++ b/lib/pages/BookAppointment/search_result/ResultByClinic.dart @@ -0,0 +1,287 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/SearchInfoModel.dart'; +import 'package:diplomaticquarterapp/models/Clinics/ClinicListResponse.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/DentalComplaints.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/components/LaserClinic.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/components/LiveCareBookAppointment.dart'; +import 'package:diplomaticquarterapp/pages/livecare/livecare_home.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/doctor_response_mapper.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../config/shared_pref_kay.dart'; +import '../../../models/Appointments/DoctorListResponse.dart'; +import '../../../services/authentication/auth_provider.dart'; +import '../../../theme/colors.dart'; +import '../../../uitl/gif_loader_dialog_utils.dart'; + +class ResultByClinic extends StatefulWidget { + HospitalsModel? selectedValue; + Function(RegionList) onClinicSelected; + + ResultByClinic( + {super.key, this.selectedValue, required this.onClinicSelected}); + + @override + State createState() => _ResultByClinicState(); +} + +class _ResultByClinicState extends State { + List? clinicIds = List.empty(); + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback( + (_) => getClinicWrtHospital(widget.selectedValue)); + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Expanded( + child: ListView.builder( + itemBuilder: (_, index) => InkWell( + onTap: () { + getDoctorsList( + context, + "${clinicIds?[index].clinicID.toString() ?? ''}-${clinicIds?[index].isLiveCareClinicAndOnline!.toString()}-${clinicIds?[index].liveCareClinicID.toString()}-${clinicIds?[index].liveCareServiceID.toString()}", + clinicIds?[index].clinicDescription!, + widget.selectedValue, + clinicIds?[index]); + }, + child: Material( + color: CustomColors.white, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 16, vertical: 24), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + clinicIds?[index].clinicDescription ?? '', + style: TextStyle( + fontSize: 22, + color: Colors.black, + fontWeight: FontWeight.w700), + ), + ], + ), + ), + Padding( + padding: EdgeInsets.all(8), + child: Center( + child: Icon( + Icons.arrow_forward_ios, + color: CustomColors.black, + size: 16, + ), + ), + ), + ], + )), + ), + ), + itemCount: clinicIds?.length ?? 0, + )) + ], + ); + } + + getDoctorsList( + BuildContext context, + String? dropdownValue, + String? dropdownTitle, + HospitalsModel? selectedHospital, + ListClinicCentralized? selectedClinic) { + SearchInfo searchInfo = new SearchInfo(); + if (dropdownValue != null) if (dropdownValue!.split("-")[0] == "17") { + searchInfo.ProjectID = + int.parse(selectedHospital?.mainProjectID.toString() ?? ""); + searchInfo.ClinicID = int.parse(dropdownValue!.split("-")[0]); + searchInfo.hospital = selectedHospital; + searchInfo.clinic = selectedClinic; + searchInfo.date = DateTime.now(); + + if (context.read().isLogin) { + if (context.read().user.age! > 12) { + navigateToDentalComplaints(context, searchInfo); + } else { + callDoctorsSearchAPI(17); + } + } else { + navigateToDentalComplaints(context, searchInfo); + } + } else if (dropdownValue!.split("-")[0] == "253") { + navigateToLaserClinic(context); + // callDoctorsSearchAPI(); + } else if (dropdownValue!.split("-")[1] == "true" + // && authProvider.isLogin && + // authUser.patientType == 1 + ) { + Navigator.push( + context, + FadePage( + page: LiveCareBookAppointment( + clinicName: dropdownTitle, + liveCareClinicID: dropdownValue!.split("-")[2], + liveCareServiceID: dropdownValue!.split("-")[3]), + ), + ).then((value) { + print("navigation return "); + if (value == "false") return; + + // setState(() { + // }); + if (value == "livecare") { + Navigator.push(context, FadePage(page: LiveCareHome())); + } + if (value == "schedule") { + callDoctorsSearchAPI(int.parse(dropdownValue!.split("-")[0])); + } + }); + setState(() {}); + } else { + callDoctorsSearchAPI(int.parse(dropdownValue!.split("-")[0])); + } + } + + Future navigateToLaserClinic(BuildContext context) async { + Navigator.push( + context, + FadePage( + page: LaserClinic(selectedHospital: widget.selectedValue!), + ), + ).then((value) {}); + } + + Future navigateToDentalComplaints( + BuildContext context, SearchInfo searchInfo) async { + Navigator.push( + context, + FadePage( + page: DentalComplaints( + searchInfo: searchInfo, + isFromHospitalSearchPage: true, + ), + ), + ).then((value) { + if (value is RegionList) { + widget.onClinicSelected(value); + } + }); + } + + callDoctorsSearchAPI(int clinicID) { + var isArabic = context.read().isArabic; + int languageID = isArabic ? 1 : 2; + GifLoaderDialogUtils.showMyDialog(context); + List doctorsList = []; + List arr = []; + List arrDistance = []; + List result; + int numAll; + List _patientDoctorAppointmentListHospital = + []; + + DoctorsListService service = new DoctorsListService(); + service + .getDoctorsList( + clinicID, + widget.selectedValue?.mainProjectID.toString() != "" + ? int.parse( + widget.selectedValue?.mainProjectID.toString() ?? "-1") + : 0, + false, + 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); + widget.onClinicSelected(regionHospitalList); + setState(() {}); + } 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); + }); + } + + void getClinicWrtHospital(HospitalsModel? newValue) async { + AppGlobal.context = context; + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService service = new ClinicListService(); + List projectsListLocal = []; + clinicIds = List.empty(); + List clinicId = []; + try { + Map res = await service.getClinicByHospital( + projectID: newValue?.mainProjectID.toString() ?? ""); + GifLoaderDialogUtils.hideDialog(context); + if (res['MessageStatus'] == 1) { + List list = res['ListClinic']; + + if (list.isEmpty) { + AppToast.showErrorToast( + message: TranslationBase.of(context).NoClinicFound, + ); + } + res['ListClinic'].forEach((v) { + clinicId.add(ListClinicCentralized.fromJson(v)); + }); + clinicIds = clinicId; + setState(() {}); + } else { + AppToast.showErrorToast( + message: TranslationBase.of(context).NoClinicFound, + ); + } + } catch (e) { + print("the error is $e"); + AppToast.showErrorToast( + message: TranslationBase.of(context).NoClinicFound, + ); + GifLoaderDialogUtils.hideDialog(context); + } + } +} diff --git a/lib/pages/BookAppointment/search_result/ResultByFacility.dart b/lib/pages/BookAppointment/search_result/ResultByFacility.dart index 37113341..d9dd0a52 100644 --- a/lib/pages/BookAppointment/search_result/ResultByFacility.dart +++ b/lib/pages/BookAppointment/search_result/ResultByFacility.dart @@ -44,7 +44,7 @@ class ResultByFacility extends StatelessWidget { if (patientDoctorAppointmentListHospital .registeredDoctorMap?[selectedRegion]?.hmcSize == 0) return; - onFacilitySelected(false); + onFacilitySelected(true); }, child: HospitalTitle( iconUrl: 'assets/images/svg/HMC.svg', @@ -108,23 +108,24 @@ class HospitalTitle extends StatelessWidget { children: [ Text( isHMC - ? "${TranslationBase.of(context).hmcHospitalCount.replaceAll("@", itemCount)}" - : "${TranslationBase.of(context).hmgHospitalCount.replaceAll("@", itemCount)}", + ? "${TranslationBase.of(context).MedicalCenterString(num.parse(itemCount)).replaceAll("@", itemCount)}" + : "${TranslationBase.of(context).HospitalString(num.parse(itemCount)).replaceAll("@", itemCount)}", style: TextStyle( fontSize: 12, color: Colors.black, fontWeight: FontWeight.w600), ), Visibility( - visible: nearest != double.infinity, + visible: nearest != double.infinity && + nearest != "0" && + nearest != 0, child: Row( children: [ SizedBox( width: 8, ), - Icon( - Icons.location_on, - color: Colors.black, + SvgPicture.asset( + 'assets/images/svg/location.svg', ), SizedBox( width: 8, diff --git a/lib/pages/BookAppointment/search_result/ResultByHospital.dart b/lib/pages/BookAppointment/search_result/ResultByHospital.dart index b7682e3e..5f7547f6 100644 --- a/lib/pages/BookAppointment/search_result/ResultByHospital.dart +++ b/lib/pages/BookAppointment/search_result/ResultByHospital.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/models/Appointments/OBGyneProcedureListResp import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; typedef OnHospitalSelected = Function(String, int); @@ -118,9 +119,8 @@ class HospitalBodyWidget extends StatelessWidget { "0"), child: Row( children: [ - Icon( - Icons.location_on, - color: Colors.black, + SvgPicture.asset( + 'assets/images/svg/location.svg', ), SizedBox( width: 8, diff --git a/lib/pages/BookAppointment/search_result/ResultByRegion.dart b/lib/pages/BookAppointment/search_result/ResultByRegion.dart index 11d6b68c..920ae513 100644 --- a/lib/pages/BookAppointment/search_result/ResultByRegion.dart +++ b/lib/pages/BookAppointment/search_result/ResultByRegion.dart @@ -3,6 +3,8 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + typedef OnRegionSelected = Function(String); class ResultByRegion extends StatelessWidget { List doctorsList = []; @@ -98,19 +100,35 @@ class RegionTitle extends StatelessWidget { ), Row( children: [ - Text( - "${TranslationBase.of(context).hmgHospitalCount.replaceAll("@", hmgCount)} ,", - style: TextStyle( + SvgPicture.asset( + 'assets/images/svg/HMG.svg', + width: 10, + height: 10, + ), + SizedBox( + width: 8, + ), + Text( + "${TranslationBase.of(context).HospitalString(num.parse(hmgCount)).replaceAll("@", hmgCount)} ,", + style: TextStyle( fontSize: 14, color: Color(0xFFD02127), fontWeight: FontWeight.w600), ), - SizedBox( + SizedBox( + width: 8, + ), + SvgPicture.asset( + 'assets/images/svg/HMC.svg', + width: 10, + height: 10, + ), + SizedBox( width: 8, ), Text( - "${TranslationBase.of(context).hmcHospitalCount.replaceAll("@", hmcCount)}", - style: TextStyle( + "${TranslationBase.of(context).MedicalCenterString(num.parse(hmcCount)).replaceAll("@", hmcCount)}", + style: TextStyle( fontSize: 14, color: Color(0xFF40ACC9), fontWeight: FontWeight.w600), diff --git a/lib/pages/BookAppointment/search_result/SearchResultWithTab.dart b/lib/pages/BookAppointment/search_result/SearchResultWithTab.dart index d1d15e5b..573f78e5 100644 --- a/lib/pages/BookAppointment/search_result/SearchResultWithTab.dart +++ b/lib/pages/BookAppointment/search_result/SearchResultWithTab.dart @@ -25,13 +25,17 @@ class SearchResultWithTab extends StatefulWidget { OBGyneProcedureListResponse? obGyneProcedureListResponse; bool isDoctorSearchResult; + bool isForHospital; + SearchResultWithTab({required this.doctorsList, required this.patientDoctorAppointmentListHospital, this.isObGyneAppointment = false, this.isDoctorNameSearch = false, required this.isLiveCareAppointment, required this.isDoctorSearchResult, - this.obGyneProcedureListResponse}); + this.obGyneProcedureListResponse, + this.isForHospital = false, + }); @override State createState() => _SearchResultWithTabState(); @@ -43,6 +47,7 @@ class _SearchResultWithTabState extends State { String selectedRegion = ""; bool isHMCSelected = false; int selectedHospitalIndex = -1; + ScrollController scrollController = ScrollController(); @override void initState() { @@ -52,6 +57,7 @@ class _SearchResultWithTabState extends State { changePageViewIndex(pageIndex) { _controller.jumpToPage(pageIndex); + scrollController.jumpTo(pageIndex); } @@ -74,10 +80,15 @@ class _SearchResultWithTabState extends State { Container( width: double.infinity, padding: EdgeInsets.only(left: 20, right: 20, top: 12), - child: Row( - children: [ - Expanded( - child: showProgress( + child: SizedBox( + height: 100, + child: ListView( + scrollDirection: Axis.horizontal, + controller: scrollController, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( title: TranslationBase.of(context).selectRegion, status: _currentIndex == 0 ? TranslationBase.of(context).inPrgress @@ -94,10 +105,12 @@ class _SearchResultWithTabState extends State { _currentIndex = 0; changePageViewIndex(0); }); - }), - ), - Expanded( - child: showProgress( + }, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( title: TranslationBase.of(context).selectFacitlity, status: _currentIndex == 1 ? TranslationBase.of(context).inPrgress @@ -115,10 +128,12 @@ class _SearchResultWithTabState extends State { _currentIndex = 1; changePageViewIndex(1); }); - }), - ), - Expanded( - child: showProgress( + }, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( title: TranslationBase.of(context).selectBranch, status: _currentIndex == 2 ? TranslationBase.of(context).inPrgress @@ -136,26 +151,60 @@ class _SearchResultWithTabState extends State { _currentIndex = 2; changePageViewIndex(2); }); - }), - ), - showProgress( - title: TranslationBase.of(context).selectDoctor, - status: _currentIndex == 3 - ? TranslationBase.of(context).inPrgress - : TranslationBase.of(context).locked, - color: _currentIndex == 3 - ? CustomColors.orange - : _currentIndex > 4 - ? CustomColors.green - : CustomColors.grey2, - isNeedBorder: false, - onTap: () { - setState(() { - _currentIndex = 3; - changePageViewIndex(3); - }); - }), - ], + }, + ), + ), + (widget.isForHospital) + ? SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( + title: + TranslationBase.of(context).selectClinic, + status: _currentIndex == 3 + ? TranslationBase.of(context).inPrgress + : TranslationBase.of(context).locked, + color: _currentIndex == 3 + ? CustomColors.orange + : _currentIndex > 4 + ? CustomColors.green + : CustomColors.grey2, + isNeedBorder: false, + onTap: () { + setState(() { + _currentIndex = 3; + changePageViewIndex(3); + }); + }, + ), + ) + : SizedBox.shrink(), + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( + title: TranslationBase.of(context).selectDoctor, + status: _currentIndex == + ((widget.isForHospital) ? 4 : 3) + ? TranslationBase.of(context).inPrgress + : TranslationBase.of(context).locked, + color: _currentIndex == + ((widget.isForHospital) ? 4 : 3) + ? CustomColors.orange + : _currentIndex == + ((widget.isForHospital) ? 5 : 4) + ? CustomColors.green + : CustomColors.grey2, + isNeedBorder: false, + onTap: () { + setState(() { + _currentIndex = + ((widget.isForHospital) ? 4 : 3); + changePageViewIndex(_currentIndex); + }); + }, + ), + ), + ], + ), ), ), mHeight(24), @@ -189,7 +238,7 @@ class _SearchResultWithTabState extends State { selectedRegion: selectedRegion, onFacilitySelected: (isHMCSelected) { setState(() { - isHMCSelected = isHMCSelected; + this.isHMCSelected = isHMCSelected; _currentIndex = 2; changePageViewIndex(2); }); @@ -200,12 +249,15 @@ class _SearchResultWithTabState extends State { paitientDoctorAppointmentList: (isHMCSelected) ? widget.patientDoctorAppointmentListHospital .registeredDoctorMap![selectedRegion]! - .hmgDoctorList ?? [] - : widget.patientDoctorAppointmentListHospital - .registeredDoctorMap?[selectedRegion] - ?.hmcDoctorList ?? [], - isHMCSelected: isHMCSelected, - isLiveCareAppointment: widget.isLiveCareAppointment, + .hmcDoctorList ?? + [] + : widget + .patientDoctorAppointmentListHospital + .registeredDoctorMap?[selectedRegion] + ?.hmgDoctorList ?? + [], + isHMCSelected: isHMCSelected, + isLiveCareAppointment: widget.isLiveCareAppointment, isDoctorSearchResult: widget.isDoctorSearchResult, onHospitalSelected: (hospital, index) { setState(() { @@ -218,7 +270,7 @@ class _SearchResultWithTabState extends State { (selectedRegion != '' && selectedHospitalIndex != -1) ? ResultByDoctor( doctorsList: widget.doctorsList, - patientDoctorAppointmentListHospital: (isHMCSelected) + patientDoctorAppointmentListHospital: (!isHMCSelected) ? widget .patientDoctorAppointmentListHospital .registeredDoctorMap![selectedRegion]! @@ -470,10 +522,7 @@ class RegionTitle extends StatelessWidget { Row( children: [ Text( - "${TranslationBase - .of(context) - .hmgHospitalCount - .replaceAll("@", hmgCount)} ,", + "${TranslationBase.of(context).HospitalString(num.parse(hmgCount)).replaceAll("@", hmgCount)} ,", style: TextStyle( fontSize: 14, color: Color(0xFFD02127), @@ -483,10 +532,7 @@ class RegionTitle extends StatelessWidget { width: 8, ), Text( - "${TranslationBase - .of(context) - .hmcHospitalCount - .replaceAll("@", hmcCount)}", + "${TranslationBase.of(context).MedicalCenterString(num.parse(hmcCount)).replaceAll("@", hmcCount)}", style: TextStyle( fontSize: 14, color: Color(0xFF40ACC9), @@ -539,14 +585,8 @@ class HospitalTitle extends StatelessWidget { ), Text( isHMC - ? "${TranslationBase - .of(context) - .hmcHospitalCount - .replaceAll("@", itemCount)}" - : "${TranslationBase - .of(context) - .hmgHospitalCount - .replaceAll("@", itemCount)}", + ? "${TranslationBase.of(context).MedicalCenterString(num.parse(itemCount)).replaceAll("@", itemCount)}" + : "${TranslationBase.of(context).HospitalString(num.parse(itemCount)).replaceAll("@", itemCount)}", style: TextStyle( fontSize: 12, color: Colors.black, fontWeight: FontWeight.w600), ), diff --git a/lib/pages/BookAppointment/search_result/SearchResultWithTabForHospital.dart b/lib/pages/BookAppointment/search_result/SearchResultWithTabForHospital.dart new file mode 100644 index 00000000..7fe5b539 --- /dev/null +++ b/lib/pages/BookAppointment/search_result/SearchResultWithTabForHospital.dart @@ -0,0 +1,701 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; +import 'package:diplomaticquarterapp/models/Appointments/OBGyneProcedureListResponse.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByClinic.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByDoctors.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByFacility.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByHospital.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/search_result/ResultByRegion.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/widgets/others/app_expandable_notifier.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; + +class SearchResultWithTabForHospital extends StatefulWidget { + List doctorsList = []; + RegionList patientDoctorAppointmentListHospital; + bool isLiveCareAppointment; + bool isObGyneAppointment; + bool isDoctorNameSearch; + OBGyneProcedureListResponse? obGyneProcedureListResponse; + bool isDoctorSearchResult; + + bool isForHospital; + + SearchResultWithTabForHospital({ + required this.doctorsList, + required this.patientDoctorAppointmentListHospital, + this.isObGyneAppointment = false, + this.isDoctorNameSearch = false, + required this.isLiveCareAppointment, + required this.isDoctorSearchResult, + this.obGyneProcedureListResponse, + this.isForHospital = true, + }); + + @override + State createState() => + _SearchResultWithTabForHospitalState(); +} + +class _SearchResultWithTabForHospitalState + extends State { + int _currentIndex = 0; + late PageController _controller; + String selectedRegion = ""; + HospitalsModel? selectedHospital; + bool isHMCSelected = false; + int selectedHospitalIndex = -1; + ScrollController scrollController = ScrollController(); + RegionList? doctorList; + + @override + void initState() { + super.initState(); + _controller = new PageController(); + } + + changePageViewIndex(pageIndex) { + _controller.jumpToPage(pageIndex); + scrollController.jumpTo(pageIndex.toDouble()); + } + + @override + Widget build(BuildContext context) { + return SizedBox( + child: widget.patientDoctorAppointmentListHospital.registeredDoctorMap + ?.isNotEmpty == + true + ? SizedBox( + height: SizeConfig.realScreenHeight! * .9, + width: SizeConfig.realScreenWidth, + child: Column(children: [ + Container( + width: double.infinity, + padding: EdgeInsets.only(left: 20, right: 20, top: 12), + child: SizedBox( + height: 100, + child: ListView( + scrollDirection: Axis.horizontal, + controller: scrollController, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( + title: TranslationBase.of(context).selectRegion, + status: _currentIndex == 0 + ? TranslationBase.of(context).inPrgress + : _currentIndex > 0 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: _currentIndex == 0 + ? CustomColors.orange + : CustomColors.green, + onTap: () { + setState(() { + selectedHospitalIndex = -1; + selectedRegion = ""; + doctorList = null; + _currentIndex = 0; + changePageViewIndex(0); + }); + }, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( + title: TranslationBase.of(context).selectFacitlity, + status: _currentIndex == 1 + ? TranslationBase.of(context).inPrgress + : _currentIndex > 1 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: _currentIndex == 1 + ? CustomColors.orange + : _currentIndex > 1 + ? CustomColors.green + : CustomColors.grey2, + onTap: () { + setState(() { + selectedHospitalIndex = -1; + doctorList = null; + _currentIndex = 1; + changePageViewIndex(1); + }); + }, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( + title: TranslationBase.of(context).selectBranch, + status: _currentIndex == 2 + ? TranslationBase.of(context).inPrgress + : _currentIndex > 1 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: _currentIndex == 2 + ? CustomColors.orange + : _currentIndex > 2 + ? CustomColors.green + : CustomColors.grey2, + onTap: () { + setState(() { + selectedHospitalIndex = -1; + doctorList = null; + _currentIndex = 2; + changePageViewIndex(2); + }); + }, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( + title: TranslationBase.of(context).selectClinic, + status: _currentIndex == 3 + ? TranslationBase.of(context).inPrgress + : _currentIndex > 3 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: _currentIndex == 3 + ? CustomColors.orange + : _currentIndex > 3 + ? CustomColors.green + : CustomColors.grey2, + onTap: () { + setState(() { + _currentIndex = 3; + doctorList = null; + changePageViewIndex(3); + }); + }, + ), + ), + SizedBox( + width: MediaQuery.of(context).size.width / 4, + child: showProgress( + title: TranslationBase.of(context).selectDoctor, + status: _currentIndex == + ((widget.isForHospital) ? 4 : 3) + ? TranslationBase.of(context).inPrgress + : TranslationBase.of(context).locked, + color: _currentIndex == + ((widget.isForHospital) ? 4 : 3) + ? CustomColors.orange + : _currentIndex == + ((widget.isForHospital) ? 5 : 4) + ? CustomColors.green + : CustomColors.grey2, + isNeedBorder: false, + onTap: () { + setState(() { + _currentIndex = + ((widget.isForHospital) ? 4 : 3); + changePageViewIndex(_currentIndex); + }); + }, + ), + ), + ], + ), + ), + ), + mHeight(24), + Expanded( + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: _controller, + onPageChanged: (index) { + setState(() { + _currentIndex = index; + }); + }, + scrollDirection: Axis.horizontal, + children: [ + ResultByRegion( + doctorsList: widget.doctorsList, + patientDoctorAppointmentListHospital: + widget.patientDoctorAppointmentListHospital, + onRegionSelected: (key) { + setState(() { + selectedRegion = key; + _currentIndex = 1; + changePageViewIndex(1); + }); + }), + (selectedRegion != "") + ? ResultByFacility( + doctorsList: widget.doctorsList, + patientDoctorAppointmentListHospital: + widget.patientDoctorAppointmentListHospital, + selectedRegion: selectedRegion, + onFacilitySelected: (isHMCSelected) { + setState(() { + this.isHMCSelected = isHMCSelected; + _currentIndex = 2; + changePageViewIndex(2); + }); + }, + ) + : SizedBox.shrink(), + (selectedRegion != '') + ? ResultByHospital( + doctorsList: widget.doctorsList, + paitientDoctorAppointmentList: (isHMCSelected) + ? widget + .patientDoctorAppointmentListHospital + .registeredDoctorMap![selectedRegion]! + .hmcDoctorList ?? + [] + : widget + .patientDoctorAppointmentListHospital + .registeredDoctorMap?[selectedRegion] + ?.hmgDoctorList ?? + [], + isHMCSelected: isHMCSelected, + isLiveCareAppointment: + widget.isLiveCareAppointment, + isDoctorSearchResult: widget.isDoctorSearchResult, + onHospitalSelected: (hospitalName, index) { + setState(() { + selectedHospitalIndex = index; + selectedHospital = (!isHMCSelected) + ? widget + .patientDoctorAppointmentListHospital + .registeredDoctorMap![selectedRegion]! + .hmgDoctorList![selectedHospitalIndex] + .hospitalList + .first + : widget + .patientDoctorAppointmentListHospital + .registeredDoctorMap![selectedRegion]! + .hmcDoctorList![selectedHospitalIndex] + .hospitalList + .first; + _currentIndex = 3; + changePageViewIndex(3); + }); + }) + : SizedBox.shrink(), + (selectedHospital != null && + selectedRegion != '' && + selectedHospitalIndex != -1) + ? ResultByClinic( + onClinicSelected: (doctorList) { + setState(() { + this.doctorList = doctorList; + _currentIndex = 4; + changePageViewIndex(4); + }); + }, + selectedValue: selectedHospital) + : SizedBox.shrink(), + (selectedRegion != '' && + selectedHospitalIndex != -1 && + doctorList != null) + ? ResultByDoctor( + doctorsList: widget.doctorsList, + patientDoctorAppointmentListHospital: + (!isHMCSelected) + ? doctorList! + .registeredDoctorMap![ + selectedRegion]! + .hmgDoctorList! + .first + .patientDoctorAppointmentList ?? + [] + : doctorList! + .registeredDoctorMap?[ + selectedRegion] + ?.hmcDoctorList! + .first + .patientDoctorAppointmentList ?? + [], + isLiveCareAppointment: + widget.isLiveCareAppointment, + isDoctorSearchResult: widget.isDoctorSearchResult, + isObGyneAppointment: widget.isObGyneAppointment, + isDoctorNameSearch: widget.isDoctorNameSearch) + : SizedBox.shrink(), + ], + ), + ), + ]), + ) + : getNoDataWidget(context), + ); + } + + String getTitle() { + switch (_currentIndex) { + case 0: + return TranslationBase.of(context).selectRegion; + case 1: + return TranslationBase.of(context).selectFacitlity; + case 2: + return TranslationBase.of(context).selectBranch; + case 3: + return TranslationBase.of(context).selectClinic; + case 4: + return TranslationBase.of(context).selectDoctor; + } + return ""; + } + + Widget showProgress( + {String? title, + String? status, + Color? color, + bool isNeedBorder = true, + Function()? onTap}) { + return InkWell( + onTap: () { + if (status == TranslationBase.of(context).completed) { + onTap?.call(); + } + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 26, + height: 26, + decoration: containerRadius(color!, 200), + child: Icon( + Icons.done, + color: Colors.white, + size: 16, + ), + ), + if (isNeedBorder) + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: mDivider(Colors.grey), + )), + ], + ), + mHeight(8), + Text( + title!, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + letterSpacing: -0.44, + ), + ), + mHeight(2), + Container( + padding: EdgeInsets.all(5), + decoration: containerRadius(color!.withOpacity(0.2), 4), + child: Text( + status!, + style: TextStyle( + fontSize: 8, + fontWeight: FontWeight.w600, + letterSpacing: -0.32, + color: color, + ), + ), + ), + ], + ) + ], + ), + ); + } +} + +class HospitalBodyWidget extends StatelessWidget { + final List? + patientDoctorAppointmentListHospital; + final bool isLiveCareAppointment; + final bool isObGyneAppointment; + final bool isDoctorNameSearch; + final bool isDoctorSearchResult; + final OBGyneProcedureListResponse? obGyneProcedureListResponse; + + const HospitalBodyWidget({ + super.key, + this.patientDoctorAppointmentListHospital, + required this.isLiveCareAppointment, + required this.isObGyneAppointment, + required this.isDoctorNameSearch, + required this.isDoctorSearchResult, + this.obGyneProcedureListResponse, + }); + + @override + Widget build(BuildContext context) { + return ListView.separated( + addAutomaticKeepAlives: true, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: patientDoctorAppointmentListHospital?.length ?? 0, + separatorBuilder: (context, index) { + return Container( + height: 12, + margin: EdgeInsets.only(left: 21, right: 21), + ); + }, + itemBuilder: (context, index) { + return AppExpandableNotifier( + applyBackgroundColor: false, + widgetColor: CustomColors.appBackgroudGrey2Color, + title: (patientDoctorAppointmentListHospital?[index].distanceInKMs != + "0") + ? patientDoctorAppointmentListHospital![index].filterName! + + " - " + + patientDoctorAppointmentListHospital![index].distanceInKMs! + + " " + + TranslationBase.of(context).km + : patientDoctorAppointmentListHospital![index].filterName, + projectTitleTop: + patientDoctorAppointmentListHospital![index].projectTopName, + projectTitleBottom: (patientDoctorAppointmentListHospital![index] + .distanceInKMs != + "0") + ? patientDoctorAppointmentListHospital![index] + .projectBottomName + .toString() + + " - " + + patientDoctorAppointmentListHospital![index].distanceInKMs! + + " " + + TranslationBase.of(context).km + : patientDoctorAppointmentListHospital![index] + .projectBottomName + .toString(), + isTitleSingleLine: false, + isDoctorSearchResult: isDoctorSearchResult, + isExpand: + patientDoctorAppointmentListHospital?.length == 1 ? true : false, + bodyWidget: ListView.separated( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + padding: + EdgeInsets.only(bottom: 10, top: 10, left: 21, right: 21), + itemBuilder: (context, _index) { + // print("the index of patientDoctorAppointmentList is ${_index}"); + // print("the index of parent is ${index}"); + final doctor = patientDoctorAppointmentListHospital![index] + .patientDoctorAppointmentList![_index]; + // print('the doctor is ${doctor.toJson()}'); + return DoctorView( + doctor: doctor, + isLiveCareAppointment: isLiveCareAppointment, + isObGyneAppointment: isObGyneAppointment, + isDoctorNameSearch: isDoctorNameSearch, + obGyneProcedureListResponse: obGyneProcedureListResponse, + isShowDate: false, + onTap: () { + context + .read() + .analytics + .appointment + .book_appointment_select_doctor( + appointment_type: 'regular', doctor: doctor); + }); + }, + separatorBuilder: (context, index) => SizedBox(height: 14), + itemCount: patientDoctorAppointmentListHospital?[index] + .patientDoctorAppointmentList + ?.length ?? + 0), + ); + }, + ); + } +} + +class RegionTitle extends StatelessWidget { + final String title; + final String hmcCount; + final String hmgCount; + + const RegionTitle( + {super.key, + required this.title, + required this.hmcCount, + required this.hmgCount}); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: TextStyle( + fontSize: 22, color: Colors.black, fontWeight: FontWeight.w700), + ), + SizedBox( + height: 8, + ), + Row( + children: [ + Text( + "${TranslationBase.of(context).HospitalString(num.parse(hmgCount)).replaceAll("@", hmgCount)} ,", + style: TextStyle( + fontSize: 14, + color: Color(0xFFD02127), + fontWeight: FontWeight.w600), + ), + SizedBox( + width: 8, + ), + Text( + "${TranslationBase.of(context).MedicalCenterString(num.parse(hmcCount)).replaceAll("@", hmcCount)}", + style: TextStyle( + fontSize: 14, + color: Color(0xFF40ACC9), + fontWeight: FontWeight.w600), + ), + ], + ), + ], + ), + ); + } +} + +class HospitalTitle extends StatelessWidget { + final String title; + final String iconUrl; + final bool isHMC; + final String itemCount; + + const HospitalTitle( + {super.key, + required this.title, + required this.iconUrl, + required this.isHMC, + required this.itemCount}); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + SvgPicture.asset(iconUrl), + SizedBox( + width: 8, + ), + Text( + title, + style: TextStyle( + fontSize: 18, + color: isHMC ? Color(0xFF40ACC9) : Color(0xFFD02127), + fontWeight: FontWeight.w600), + ), + ], + ), + SizedBox( + height: 6, + ), + Text( + isHMC + ? "${TranslationBase.of(context).MedicalCenterString(num.parse(itemCount)).replaceAll("@", itemCount)}" + : "${TranslationBase.of(context).HospitalString(num.parse(itemCount)).replaceAll("@", itemCount)}", + style: TextStyle( + fontSize: 12, color: Colors.black, fontWeight: FontWeight.w600), + ), + ], + ), + ); + } +} + +///todo the current content of the application +/// return AppExpandableNotifier( +// paddingValue: 10, +// applyBackgroundToOnlyHeader: true, +// completeHeaderColor: CustomColors.appBackgroudGrey2Color, +// headerWidget: RegionTitle( +// title: key, +// hmcCount: +// "${widget.patientDoctorAppointmentListHospital.registeredDoctorMap?[key]?.hmcSize ?? 0}", +// hmgCount: +// "${widget.patientDoctorAppointmentListHospital.registeredDoctorMap?[key]?.hmgSize ?? 0}", +// ), +// showDropDownIconWithCustomHeader: true, +// isTitleSingleLine: false, +// isDoctorSearchResult: widget.isDoctorSearchResult, +// widgetColor: Color(0xFFF8F8F8), +// bodyWidget: Column( +// children: [ +// Padding( +// padding: const EdgeInsets.all(8.0), +// child: AppExpandableNotifier( +// paddingValue: 8, +// applyBackgroundColor: false, +// applyBackgroundToOnlyHeader: true, +// completeHeaderColor: Colors.white, +// headerRadius: BorderRadius.circular(16), +// headerWidget: HospitalTitle( +// iconUrl: 'assets/images/svg/HMG.svg', +// title: TranslationBase.of(context).hmgHospital, +// isHMC: false, +// itemCount: +// "${widget.patientDoctorAppointmentListHospital.registeredDoctorMap?[key]?.hmgSize ?? 0}", +// ), +// showDropDownIconWithCustomHeader: true, +// bodyWidget: HospitalBodyWidget( +// patientDoctorAppointmentListHospital: +// widget.patientDoctorAppointmentListHospital +// .registeredDoctorMap?[key]?.hmgDoctorList, +// isLiveCareAppointment: widget.isLiveCareAppointment, +// isObGyneAppointment: widget.isObGyneAppointment, +// isDoctorNameSearch: widget.isDoctorNameSearch, +// isDoctorSearchResult: widget.isDoctorSearchResult, +// ), +// ), +// ), +// Padding( +// padding: const EdgeInsets.only( +// bottom: 8.0, left: 8, right: 8), +// child: AppExpandableNotifier( +// paddingValue: 8, +// applyBackgroundColor: false, +// applyBackgroundToOnlyHeader: true, +// completeHeaderColor: Colors.white, +// headerRadius: BorderRadius.circular(16), +// headerWidget: HospitalTitle( +// iconUrl: 'assets/images/svg/HMC.svg', +// title: TranslationBase.of(context).hmcHospital, +// isHMC: true, +// itemCount: +// "${widget.patientDoctorAppointmentListHospital.registeredDoctorMap?[key]?.hmcSize ?? 0}", +// ), +// showDropDownIconWithCustomHeader: true, +// bodyWidget: HospitalBodyWidget( +// patientDoctorAppointmentListHospital: +// widget.patientDoctorAppointmentListHospital +// .registeredDoctorMap?[key]?.hmcDoctorList, +// isLiveCareAppointment: widget.isLiveCareAppointment, +// isObGyneAppointment: widget.isObGyneAppointment, +// isDoctorNameSearch: widget.isDoctorNameSearch, +// isDoctorSearchResult: widget.isDoctorSearchResult, +// ), +// ), +// ), +// ], +// )); diff --git a/lib/pages/BookAppointment/widgets/DentalComplaintCard.dart b/lib/pages/BookAppointment/widgets/DentalComplaintCard.dart index 8f18a016..8d664dc5 100644 --- a/lib/pages/BookAppointment/widgets/DentalComplaintCard.dart +++ b/lib/pages/BookAppointment/widgets/DentalComplaintCard.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/DentalChiefComplaintsModel.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/doctor_response_mapper.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -16,8 +17,15 @@ class DentalComplaintCard extends StatefulWidget { var languageID; Function? onSelectedMethod; bool isDoctorNameSearch; + bool isFromHospitalSearchPage; + Function(RegionList)? onDoctorFetched; - DentalComplaintCard({required this.listDentalChiefComplain, this.languageID, this.onSelectedMethod, this.isDoctorNameSearch = false}); + DentalComplaintCard({required this.listDentalChiefComplain, + this.languageID, + this.onSelectedMethod, + this.isDoctorNameSearch = false, + this.isFromHospitalSearchPage = false, + this.onDoctorFetched}); @override _DentalComplaintCardState createState() => _DentalComplaintCardState(); @@ -33,6 +41,9 @@ class _DentalComplaintCardState extends State { // if(widget.isDoctorNameSearch) { // widget.onSelectedMethod(); // } else { + // if (widget.isFromHospitalSearchPage) { + // getChiefComplaintsDoctorMappedList(); + // } else getChiefComplaintsList(); // } }, @@ -110,4 +121,41 @@ class _DentalComplaintCardState extends State { Future navigateToSearchResults(context, List docList, List patientDoctorAppointmentListHospital) async { Navigator.push(context, FadePage(page: SearchResults(doctorsList: docList, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital, isLiveCareAppointment: false, isDoctorSearchResult: true,))); } + + void getChiefComplaintsDoctorMappedList() { + var isArabic = context.read().isArabic; + int languageID = + Provider.of(context, listen: false).isArabic ? 1 : 2; + List doctorsList = []; + List _patientDoctorAppointmentListHospital = + []; + + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService service = new ClinicListService(); + service + .getChiefComplaintDoctorList(widget.listDentalChiefComplain!.iD!, + widget.listDentalChiefComplain.projectID!, languageID, context) + .then((res) async { + GifLoaderDialogUtils.hideDialog(context); + if (res['MessageStatus'] == 1) { + RegionList regionHospitalList = RegionList(); + print(res['List_DentalDoctorChiefComplaintMapping']); + setState(() async { + doctorsList.clear(); + res['List_DentalDoctorChiefComplaintMapping'].forEach((v) { + doctorsList.add(new DoctorList.fromJson(v)); + }); + + regionHospitalList = await DoctorMapper.getMappedDoctor(doctorsList, + isArabic: isArabic); + widget.onDoctorFetched?.call(regionHospitalList); + }); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } } diff --git a/lib/services/appointment_services/doctor_response_mapper.dart b/lib/services/appointment_services/doctor_response_mapper.dart index c9c0b1de..9a12804e 100644 --- a/lib/services/appointment_services/doctor_response_mapper.dart +++ b/lib/services/appointment_services/doctor_response_mapper.dart @@ -1,6 +1,7 @@ import 'dart:math'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; @@ -117,4 +118,92 @@ class DoctorMapper{ unsorted.registeredDoctorMap = sortedMap; return unsorted; } + + static Future getMappedHospitals( + List hospitalList, { + bool isArabic = false, + }) async { + final regionList = RegionList(); + final sharedPref = AppSharedPreferences(); + + for (final hospital in hospitalList) { + final region = hospital.getRegionName(isArabic); + if (region == null) continue; + + final regionData = regionList.registeredDoctorMap?.putIfAbsent( + region, + () => PatientDoctorAppointmentListByRegion(), + ); + + List? targetList = hospital.isHMC == true + ? regionData?.hmcDoctorList + : regionData?.hmgDoctorList; + + List existingEntry = targetList + ?.where( + (entry) => entry.filterName == hospital.legalName, + ) + .toList() ?? + []; + + if (existingEntry.isNotEmpty) { + existingEntry.first.hospitalList.add(hospital); + } else { + final newEntry = PatientDoctorAppointmentList( + filterName: hospital.legalName, + distanceInKMs: hospital.distanceInKilometers?.toString(), + projectTopName: hospital.name, + projectBottomName: hospital.legalName, + model: hospital); + + final distance = hospital.distanceInKilometers; + + if (distance != null) { + if (regionData!.distance > distance) { + regionData.distance = distance; + } + + if (hospital.isHMC == true && distance < regionData.hmcDistance) { + regionData.hmcDistance = distance; + } else if (distance < regionData.hmgDistance) { + regionData.hmgDistance = distance; + } + } else if (await sharedPref.getDouble(USER_LAT) != null && + await sharedPref.getDouble(USER_LONG) != null && + hospital.latitude != null && + hospital.longitude != null) { + final lat = await sharedPref.getDouble(USER_LAT); + final long = await sharedPref.getDouble(USER_LONG); + + double calculatedDistance = calculateDistance( + lat, + long, + double.parse(hospital.latitude!), + double.parse(hospital.longitude!), + ).abs(); + + if (regionData!.distance > calculatedDistance) { + regionData.distance = calculatedDistance; + } + + if (hospital.isHMC == true && + calculatedDistance < regionData.hmcDistance) { + regionData.hmcDistance = calculatedDistance; + } else if (calculatedDistance < regionData.hmgDistance) { + regionData.hmgDistance = calculatedDistance; + } + + print("Calculated distance: $calculatedDistance"); + } + + targetList?.add(newEntry); + } + + regionData?.hmcSize = regionData.hmcDoctorList?.length ?? 0; + regionData?.hmgSize = regionData.hmgDoctorList?.length ?? 0; + regionList.registeredDoctorMap?[region] = regionData; + } + + return regionList; + } } \ No newline at end of file diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index b183b98c..bd942a06 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -3273,12 +3273,36 @@ class TranslationBase { String get selectDoctor => localizedValues["selectDoctor"][locale.languageCode]; String get hmgHospital => localizedValues["hmgHospital"][locale.languageCode]; String get hmcHospital => localizedValues["hmcHospital"][locale.languageCode]; - String get hmcHospitalCount => localizedValues["hmcHospitalCount"][locale.languageCode]; - String get hmgHospitalCount => localizedValues["hmgHospitalCount"][locale.languageCode]; + + String get hmcHospitalCountSingle => + localizedValues["hmcHospitalCountSingle"][locale.languageCode]; + + String get hmgHospitalCountSingle => + localizedValues["hmgHospitalCountSingle"][locale.languageCode]; + + String get hmcHospitalCountPlural => + localizedValues["hmcHospitalCountPlural"][locale.languageCode]; + + String get hmgHospitalCountPlural => + localizedValues["hmgHospitalCountPlural"][locale.languageCode]; String get nearest => localizedValues["nearest"][locale.languageCode]; String get kilometerUnit => localizedValues["kilometerUnit"][locale.languageCode]; + + String HospitalString(num value) { + if (value == 1 || value == 0) + return localizedValues["hmgHospitalCountSingle"][locale + .languageCode]; else + return localizedValues["hmgHospitalCountPlural"][locale.languageCode]; + } + + String MedicalCenterString(num value) { + if (value == 1 || value == 0) + return localizedValues["hmcHospitalCountSingle"][locale + .languageCode]; else + return localizedValues["hmcHospitalCountPlural"][locale.languageCode]; + } } class TranslationBaseDelegate extends LocalizationsDelegate {