From e93771df33a081eb98811ebdfa442d0afd7de3aa Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 16 Aug 2026 17:39:29 +0300 Subject: [PATCH] Pedia Dental issue fixes --- .../book_appointments_repo.dart | 5 ++ .../appointment_via_region_viewmodel.dart | 14 ++++ .../search_doctor_by_name.dart | 66 ++++++++++++------- .../book_appointment/select_clinic_page.dart | 21 ++++-- .../book_appointment/select_doctor_page.dart | 6 +- .../widgets/appointment_calendar.dart | 21 ++++-- .../book_appointment/widgets/doctor_card.dart | 29 +++++--- 7 files changed, 122 insertions(+), 40 deletions(-) diff --git a/lib/features/book_appointments/book_appointments_repo.dart b/lib/features/book_appointments/book_appointments_repo.dart index e5200f67..1e0b8739 100644 --- a/lib/features/book_appointments/book_appointments_repo.dart +++ b/lib/features/book_appointments/book_appointments_repo.dart @@ -2,7 +2,9 @@ import 'package:dartz/dartz.dart'; import 'package:hmg_patient_app_new/core/api/api_client.dart'; import 'package:hmg_patient_app_new/core/api_consts.dart'; +import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart'; +import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; import 'package:hmg_patient_app_new/core/utils/date_util.dart'; import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/appointment_nearest_gate_response_model.dart'; @@ -181,6 +183,9 @@ class BookAppointmentsRepoImp implements BookAppointmentsRepo { "IsSearchAppointmnetByClinicID": isContinueDentalPlan ? false : true, "isDentalAllowedBackend": clinicID == 17 ? true : isContinueDentalPlan, "IsGetNearAppointment": isNearest, + "gender": getIt.get().isAuthenticated ? getIt.get().getAuthenticatedUser()!.gender! : 0, + "age": getIt.get().isAuthenticated ? getIt.get().getAuthenticatedUser()!.age! : 0, + "DateofBirth": getIt.get().isAuthenticated ? getIt.get().getAuthenticatedUser()!.dateofBirth! : null, if (isNearest) "SelectedDate": DateUtil.convertDateToString(DateTime.now()), "License": true }; diff --git a/lib/features/my_appointments/appointment_via_region_viewmodel.dart b/lib/features/my_appointments/appointment_via_region_viewmodel.dart index 1144be82..bb4179e1 100644 --- a/lib/features/my_appointments/appointment_via_region_viewmodel.dart +++ b/lib/features/my_appointments/appointment_via_region_viewmodel.dart @@ -161,6 +161,20 @@ class AppointmentViaRegionViewmodel extends ChangeNotifier { page: DentalChiefComplaintsPage(), ), ); + } else { + if (appState.getAuthenticatedUser()!.age! > 12) { + navigationService.push( + CustomPageRoute( + page: DentalChiefComplaintsPage(), + ), + ); + } else { + navigationService.push( + CustomPageRoute( + page: SelectDoctorPage(), + ), + ); + } } } if (clinicId == 253) { diff --git a/lib/presentation/book_appointment/search_doctor_by_name.dart b/lib/presentation/book_appointment/search_doctor_by_name.dart index 165acfbf..4e9f1435 100644 --- a/lib/presentation/book_appointment/search_doctor_by_name.dart +++ b/lib/presentation/book_appointment/search_doctor_by_name.dart @@ -3,15 +3,19 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart'; +import 'package:hmg_patient_app_new/core/app_state.dart'; +import 'package:hmg_patient_app_new/core/dependencies.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/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_view_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/doctor_filter/doctor_filter_view_model.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/presentation/book_appointment/doctor_filter/doctors_filter.dart'; import 'package:hmg_patient_app_new/presentation/book_appointment/doctor_profile_page.dart'; +import 'package:hmg_patient_app_new/presentation/book_appointment/select_doctor_page.dart'; import 'package:hmg_patient_app_new/presentation/book_appointment/widgets/doctor_card.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; @@ -214,28 +218,46 @@ class _SearchDoctorByNameState extends State { bookAppointmentsViewModel: bookAppointmentsViewModel, isDoctorNameSearch: true, ).paddingSymmetrical(16.h, 0.h).onPress(() async { - bookAppointmentsVM.setSelectedDoctor(bookAppointmentsVM.filteredDoctorList[index]); - LoaderBottomSheet.showLoader(); - await bookAppointmentsVM.getDoctorProfile( - onSuccess: (dynamic respData) { - LoaderBottomSheet.hideLoader(); - Navigator.of(context).push( - CustomPageRoute( - page: DoctorProfilePage(isDoctorAllowedToBook: true), - ), - ); - }, - onError: (err) { - LoaderBottomSheet.hideLoader(); - showCommonBottomSheetWithoutHeight( - context, - child: Utils.getErrorWidget(loadingText: err), - callBackFunc: () {}, - isFullScreen: false, - isCloseButtonVisible: true, - ); - }, - ); + if (bookAppointmentsVM.filteredDoctorList[index].clinicID == 17 && getIt.get().getAuthenticatedUser()!.age! < 12) { + bookAppointmentsViewModel.setProjectID(bookAppointmentsVM.filteredDoctorList[index].projectID.toString()); + bookAppointmentsViewModel.setSelectedClinic(GetClinicsListResponseModel( + clinicID: bookAppointmentsVM.filteredDoctorList[index].clinicID, + clinicDescription: bookAppointmentsVM.filteredDoctorList[index].clinicName, + isLiveCareClinicAndOnline: false, + liveCareServiceID: 0, + liveCareClinicID: 0)); + bookAppointmentsViewModel.setIsDoctorsListLoading(true); + Navigator.push( + context, + CustomPageRoute( + page: SelectDoctorPage(), + ), + ); + } else { + bookAppointmentsVM.setSelectedDoctor(bookAppointmentsVM.filteredDoctorList[index]); + LoaderBottomSheet.showLoader(); + await bookAppointmentsVM.getDoctorProfile( + onSuccess: (dynamic respData) { + LoaderBottomSheet.hideLoader(); + Navigator.of(context).push( + CustomPageRoute( + page: DoctorProfilePage(isDoctorAllowedToBook: true), + ), + ); + }, + onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: err), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }, + ); + } + // Column( // children: bookAppointmentsVM.doctorsList[index].map((entry) { // final doctorIndex = entry.key; diff --git a/lib/presentation/book_appointment/select_clinic_page.dart b/lib/presentation/book_appointment/select_clinic_page.dart index bf4b5d58..785ebb62 100644 --- a/lib/presentation/book_appointment/select_clinic_page.dart +++ b/lib/presentation/book_appointment/select_clinic_page.dart @@ -1045,8 +1045,17 @@ class _SelectClinicPageState extends State { //Dental Clinic Flow if (clinic.clinicID == 17) { if (appState.isAuthenticated) { - initDentalAppointmentBookingFlow(int.parse(bookAppointmentsViewModel.currentlySelectedHospitalFromRegionFlow ?? "0")); - return; + if (appState.getAuthenticatedUser()!.age! > 12) { + initDentalAppointmentBookingFlow(int.parse(bookAppointmentsViewModel.currentlySelectedHospitalFromRegionFlow ?? "0")); + return; + } else { + Navigator.push( + context, + CustomPageRoute( + page: SelectDoctorPage(), + ), + ); + } } else { bookAppointmentsViewModel.setIsChiefComplaintsListLoading(true); Navigator.of(context).push( @@ -1174,8 +1183,12 @@ class _SelectClinicPageState extends State { if (bookAppointmentsViewModel.selectedClinic.clinicID == 17) { bookAppointmentsViewModel.setProjectID(id); if (appState.isAuthenticated) { - initDentalAppointment(); - return SizedBox.shrink(); + if (appState.getAuthenticatedUser()!.age! > 12) { + initDentalAppointment(); + return SizedBox.shrink(); + } else { + return SizedBox.shrink(); + } } else { bookAppointmentsViewModel.setIsChiefComplaintsListLoading(true); } diff --git a/lib/presentation/book_appointment/select_doctor_page.dart b/lib/presentation/book_appointment/select_doctor_page.dart index cad4fe0e..661c9a30 100644 --- a/lib/presentation/book_appointment/select_doctor_page.dart +++ b/lib/presentation/book_appointment/select_doctor_page.dart @@ -53,7 +53,11 @@ class _SelectDoctorPageState extends State { bookAppointmentsViewModel.getLiveCareDoctorsList(); } else { if (bookAppointmentsViewModel.selectedClinic.clinicID == 17) { - bookAppointmentsViewModel.getDentalChiefComplaintDoctorsList(); + if (appState.getAuthenticatedUser()!.age! > 12) { + bookAppointmentsViewModel.getDentalChiefComplaintDoctorsList(); + } else { + bookAppointmentsViewModel.getDoctorsList(isNearest: false); + } } else if (bookAppointmentsViewModel.isGetDocForHealthCal) { bookAppointmentsViewModel.getDoctorsListByHealthCal(); } else { diff --git a/lib/presentation/book_appointment/widgets/appointment_calendar.dart b/lib/presentation/book_appointment/widgets/appointment_calendar.dart index bc6e214c..a95989a6 100644 --- a/lib/presentation/book_appointment/widgets/appointment_calendar.dart +++ b/lib/presentation/book_appointment/widgets/appointment_calendar.dart @@ -278,11 +278,22 @@ class _AppointmentCalendarState extends State { bookAppointmentsViewModel.setProjectID(bookAppointmentsViewModel.selectedDoctor.projectID.toString()); bookAppointmentsViewModel.setSelectedClinic(selectedClinic); bookAppointmentsViewModel.setIsChiefComplaintsListLoading(true); - Navigator.of(context).push( - CustomPageRoute( - page: DentalChiefComplaintsPage(), - ), - ); + if(appState.getAuthenticatedUser()!.age! > 12) { + Navigator.of(context).push( + CustomPageRoute( + page: DentalChiefComplaintsPage(), + ), + ); + } else { + bookAppointmentsViewModel.getAppointmentNearestGate(projectID: bookAppointmentsViewModel.selectedDoctor.projectID!, clinicID: bookAppointmentsViewModel.selectedDoctor.clinicID!); + bookAppointmentsViewModel.setSelectedAppointmentDateTime(selectedDate, selectedTime, selectedDateDisplay); + Navigator.of(context).pop(); + Navigator.of(context).push( + CustomPageRoute( + page: ReviewAppointmentPage(), + ), + ); + } } else { bookAppointmentsViewModel.getAppointmentNearestGate(projectID: bookAppointmentsViewModel.selectedDoctor.projectID!, clinicID: bookAppointmentsViewModel.selectedDoctor.clinicID!); bookAppointmentsViewModel.setSelectedAppointmentDateTime(selectedDate, selectedTime, selectedDateDisplay); diff --git a/lib/presentation/book_appointment/widgets/doctor_card.dart b/lib/presentation/book_appointment/widgets/doctor_card.dart index bb5a599d..8a48465a 100644 --- a/lib/presentation/book_appointment/widgets/doctor_card.dart +++ b/lib/presentation/book_appointment/widgets/doctor_card.dart @@ -14,6 +14,7 @@ import 'package:hmg_patient_app_new/features/book_appointments/models/resp_model import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/presentation/book_appointment/dental_chief_complaints_page.dart'; import 'package:hmg_patient_app_new/presentation/book_appointment/laser/laser_appointment.dart'; +import 'package:hmg_patient_app_new/presentation/book_appointment/select_doctor_page.dart'; import 'package:hmg_patient_app_new/presentation/book_appointment/widgets/appointment_calendar.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; @@ -185,14 +186,26 @@ class DoctorCard extends StatelessWidget { if (isDoctorNameSearch && doctorsListResponseModel.clinicID == 17) { GetClinicsListResponseModel selectedClinic = GetClinicsListResponseModel( clinicID: doctorsListResponseModel.clinicID, clinicDescription: doctorsListResponseModel.clinicName, isLiveCareClinicAndOnline: false, liveCareServiceID: 0, liveCareClinicID: 0); - bookAppointmentsViewModel.setProjectID(doctorsListResponseModel.projectID.toString()); - bookAppointmentsViewModel.setSelectedClinic(selectedClinic); - bookAppointmentsViewModel.setIsChiefComplaintsListLoading(true); - Navigator.of(context).push( - CustomPageRoute( - page: DentalChiefComplaintsPage(), - ), - ); + if (getIt.get().getAuthenticatedUser()!.age! > 12) { + bookAppointmentsViewModel.setProjectID(doctorsListResponseModel.projectID.toString()); + bookAppointmentsViewModel.setSelectedClinic(selectedClinic); + bookAppointmentsViewModel.setIsChiefComplaintsListLoading(true); + Navigator.of(context).push( + CustomPageRoute( + page: DentalChiefComplaintsPage(), + ), + ); + } else { + bookAppointmentsViewModel.setProjectID(doctorsListResponseModel.projectID.toString()); + bookAppointmentsViewModel.setSelectedClinic(selectedClinic); + bookAppointmentsViewModel.setIsDoctorsListLoading(true); + Navigator.push( + context, + CustomPageRoute( + page: SelectDoctorPage(), + ), + ); + } } else if (isDoctorNameSearch && doctorsListResponseModel.clinicID == 253) { GetClinicsListResponseModel selectedClinic = GetClinicsListResponseModel( clinicID: doctorsListResponseModel.clinicID, clinicDescription: doctorsListResponseModel.clinicName, isLiveCareClinicAndOnline: false, liveCareServiceID: 0, liveCareClinicID: 0);