From 66ec7b5ca47086776926a8765e7231a976ff5dfa Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 20 Aug 2024 12:11:49 +0300 Subject: [PATCH] Derma package appointment booking fixes --- lib/config/localized_values.dart | 5 +- lib/pages/BookAppointment/BookConfirm.dart | 62 +++++++++---------- .../appointment_services/GetDoctorsList.dart | 16 +++-- lib/uitl/translations_delegate_base.dart | 1 + 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 4c2acf61..1bb1e75b 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1976,8 +1976,9 @@ const Map localizedValues = { "selectHospitalBloodDonation": {"en": "Please select the hospital you want to book an appointment with: ", "ar": "يرجى اختيار المستشفى الذي تريد حجز موعد معه:"}, "wecare": {"en": "We Care", "ar": "نحن نهتم"}, "myinstructions": {"en": "My Instructions", "ar": "تعليماتي"}, - "existingPackage":{"en":"There is an existing package","ar":"هناك حزمة موجودة"}, - "continueOrbookNew":{"en":"do you want to continue with that package? or book new appointment","ar":"هل تريد الاستمرار في هذه الباقة؟ أو حجز موعد جديد"}, + "existingPackage":{"en":"This patient has a package under this clinic,","ar":"هذا المريض لديه حزمة تحت هذه العيادة،"}, + "continueOrbookNew":{"en":"do you want to continue with that package? or book new appointment?","ar":"هل تريد الاستمرار في هذه الباقة؟ أو حجز موعد جديد؟"}, "newAppointment":{"en":"New Appointment","ar":"موعد جديد"}, + "proceedPackage":{"en":"Proceed with package","ar":"المضي قدما في الحزمة"}, }; diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 757b7d23..d33ca7f3 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -212,13 +212,11 @@ class _BookConfirmState extends State { disabledBackgroundColor: new Color(0xFFbcc2c4).withOpacity(0.12), elevation: 0, onPressed: () async { - bool isLiveCareSchedule = await this.sharedPref.getBool( - IS_LIVECARE_APPOINTMENT) ?? false; + bool isLiveCareSchedule = await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT) ?? false; if (isLiveCareSchedule) { insertLiveCareScheduledAppointment(context, widget.doctor); } else { - checkPatientHasDermaPackage( - widget.doctor, projectViewModel.user.patientID!); + checkPatientHasDermaPackage(widget.doctor, projectViewModel.user.patientID!); } }, child: Text(TranslationBase.of(context).bookAppo, style: TextStyle(fontSize: 16.0, letterSpacing: -0.48, color: Colors.white)), @@ -256,7 +254,7 @@ class _BookConfirmState extends State { ); } - cancelAppointment(DoctorList docObject, AppoitmentAllHistoryResultList appo, BuildContext context, {int? invoiceNumber, int? lineItemNo}) async { + cancelAppointment(DoctorList docObject, AppoitmentAllHistoryResultList appo, BuildContext context, {int? invoiceNumber, int? lineItemNo}) async { ConfirmDialog.closeAlertDialog(context); GifLoaderDialogUtils.showMyDialog(context, barrierDismissible: false); DoctorsListService service = new DoctorsListService(); @@ -268,7 +266,7 @@ class _BookConfirmState extends State { if (isLiveCareSchedule != null && isLiveCareSchedule) { insertLiveCareScheduledAppointment(context, widget.doctor); } else { - insertAppointment(context, widget.doctor, widget.initialSlotDuration, invoiceNumber: invoiceNumber, lineItemNo: lineItemNo); + insertAppointment(widget.doctor, widget.initialSlotDuration, invoiceNumber: invoiceNumber, lineItemNo: lineItemNo); } }); } else { @@ -322,55 +320,53 @@ class _BookConfirmState extends State { print(err); }); } - checkPatientHasDermaPackage(DoctorList doctor, int patientID){ + + checkPatientHasDermaPackage(DoctorList doctor, int patientID) { GifLoaderDialogUtils.showMyDialog(context); widget.service - // .insertAppointment(docObject.doctorID!, docObject.clinicID!, docObject.projectID!, widget.selectedTime, widget.selectedDate, initialSlotDuration, context, 'null', null, null, projectViewModel) - .checkPatientHasDermaPackage(patientID!, doctor.clinicID!, doctor.projectID!, doctor.doctorID!, projectViewModel.isArabic ? 1 : 2, context, - ) + .checkPatientHasDermaPackage( + patientID!, + doctor.clinicID!, + doctor.projectID!, + doctor.doctorID!, + projectViewModel.isArabic ? 1 : 2, + context, + ) .then((res) { GifLoaderDialogUtils.hideDialog(context); - if (res['MessageStatus'] == 1 && res['PatientPackageComponent']['Message'] =='Success') { - + if (res['MessageStatus'] == 1 && res['PatientPackageComponent']['Message'] == 'Success') { PatientPackageComponent package = PatientPackageComponent.fromJson(res['PatientPackageComponent']); ConfirmDialog dialog = ConfirmDialog( context: context, - confirmMessage: "${TranslationBase.of(context).existingPackage} , ${package.patientPackageComponents![0].procedureName} , ${ TranslationBase.of(context).continueOrbookNew}", - okText: TranslationBase.of(context).continues, - cancelText:TranslationBase.of(context).newAppointment, + confirmMessage: "${TranslationBase.of(context).existingPackage} ${package.patientPackageComponents![0].procedureName}, ${TranslationBase.of(context).continueOrbookNew}", + okText: TranslationBase.of(context).proceedPackage, + cancelText: TranslationBase.of(context).newAppointment, okFunction: () => { - ConfirmDialog.closeAlertDialog(context), - insertAppointment( - context, widget.doctor, widget.initialSlotDuration, invoiceNumber: package.patientPackageComponents![0].invoiceNo, lineItemNo:package.patientPackageComponents![0].lineItemNo ) }, - cancelFunction: () => { - ConfirmDialog.closeAlertDialog(context), - insertAppointment( - context, widget.doctor, widget.initialSlotDuration) + ConfirmDialog.closeAlertDialog(context), + insertAppointment(widget.doctor, widget.initialSlotDuration, invoiceNumber: package.patientPackageComponents![0].invoiceNo, lineItemNo: package.patientPackageComponents![0].lineItemNo) }, + cancelFunction: () => {insertAppointment(widget.doctor, widget.initialSlotDuration)}, ); dialog.showAlertDialog(context); - } else{ - insertAppointment( - context, widget.doctor, widget.initialSlotDuration); + } else { + insertAppointment(widget.doctor, widget.initialSlotDuration); } - }).onError((error, stackTrace) { - insertAppointment( - context, widget.doctor, widget.initialSlotDuration); + insertAppointment(widget.doctor, widget.initialSlotDuration); }); } - insertAppointment(context, DoctorList docObject, int initialSlotDuration, {int? invoiceNumber, int? lineItemNo} ) async { + insertAppointment(DoctorList docObject, int initialSlotDuration, {int? invoiceNumber, int? lineItemNo}) async { final timeSlot = DocAvailableAppointments.selectedAppoDateTime; String logs = await sharedPref.getString('selectedLogSlots'); List decodedLogs = json.decode(logs); - GifLoaderDialogUtils.showMyDialog(context, barrierDismissible: false); + GifLoaderDialogUtils.showMyDialog(context, barrierDismissible: true); AppoitmentAllHistoryResultList appo; widget.service // .insertAppointment(docObject.doctorID!, docObject.clinicID!, docObject.projectID!, widget.selectedTime, widget.selectedDate, initialSlotDuration, context, 'null', null, null, projectViewModel) .insertAppointment(docObject.doctorID!, docObject.clinicID!, docObject.projectID!, widget.selectedTime, widget.selectedDate, initialSlotDuration, projectViewModel.isArabic ? 1 : 2, context, - null, null, null, projectViewModel, invoiceNumber, lineItemNo!) + null, null, null, projectViewModel, invoiceNumber, lineItemNo) .then((res) { if (res['MessageStatus'] == 1) { AppToast.showSuccessToast(message: TranslationBase.of(context).bookedSuccess); @@ -407,14 +403,14 @@ class _BookConfirmState extends State { confirmMessage: res['ErrorEndUserMessage'], okText: TranslationBase.of(context).confirm, cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => {cancelAppointment(docObject, appo, context, invoiceNumber: invoiceNumber, lineItemNo: lineItemNo!)}, + okFunction: () => {cancelAppointment(docObject, appo, context, invoiceNumber: invoiceNumber, lineItemNo: lineItemNo)}, cancelFunction: () => {}, ); dialog.showAlertDialog(context); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); - AppToast.showErrorToast(message: err); + AppToast.showErrorToast(message: err, localContext: context); }); projectViewModel.analytics.appointment.book_appointment_click_confirm(appointment_type: 'regular', dateTime: timeSlot!, doctor: widget.doctor); } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 02598470..35d9a726 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -28,9 +28,9 @@ class DoctorsListService extends BaseService { AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); - double? lat; - double? long; - String? deviceToken; + double? lat; + double? long; + String? deviceToken; String? tokenID; List selectedBodyPartList = []; @@ -335,7 +335,7 @@ class DoctorsListService extends BaseService { } Future insertAppointment(int docID, int clinicID, int projectID, String selectedTime, String selectedDate, int initialSlotDuration, int languageID, BuildContext context, - [String? procedureID, num? testTypeEnum, num? testProcedureEnum, ProjectViewModel? projectViewModel, int? invoiceNumber, int? lineItemNo]) async { + [String? procedureID, num? testTypeEnum, num? testProcedureEnum, ProjectViewModel? projectViewModel, int? invoiceNumber, int? lineItemNo]) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { @@ -375,8 +375,8 @@ class DoctorsListService extends BaseService { "PatientID": authUser.patientID, "PatientTypeID": authUser.patientType, "PatientType": authUser.patientType, - "InvoiceNo":invoiceNumber, - "LineItemNo":lineItemNo, + "InvoiceNo": invoiceNumber, + "LineItemNo": lineItemNo, // "TokenID":"@dm!n" }; @@ -512,8 +512,6 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } - - Future checkPatientHasDermaPackage(int patientID, int clinicID, int projectID, int doctorID, int languageID, BuildContext context) async { Map request; @@ -521,7 +519,7 @@ class DoctorsListService extends BaseService { var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); authUser = data; } - request = { "PatientID":patientID, "ClinicID":clinicID, "ProjectID": projectID, "LanguageID": languageID}; + request = {"PatientID": patientID, "ClinicID": clinicID, "ProjectID": projectID, "LanguageID": languageID}; //request = { "PatientID":4768732, "ClinicID":1, "ProjectID": 15, "LanguageID": languageID, "TokenID":"@dm!n" }; dynamic localRes; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 83d41027..c01d0451 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2967,6 +2967,7 @@ class TranslationBase { String get existingPackage => localizedValues["existingPackage"][locale.languageCode]; String get continueOrbookNew => localizedValues["continueOrbookNew"][locale.languageCode]; String get newAppointment => localizedValues["newAppointment"][locale.languageCode]; + String get proceedPackage => localizedValues["proceedPackage"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {