From 984459d314c06e4fe57232d6ee63b3b3342b27e4 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 30 Jul 2024 16:52:51 +0300 Subject: [PATCH] Walkin appointment implementation contd --- lib/config/config.dart | 10 +-- lib/pages/BookAppointment/BookConfirm.dart | 68 +++++++++++++++++-- lib/pages/BookAppointment/DoctorProfile.dart | 1 + lib/pages/BookAppointment/QRCode.dart | 2 - .../components/DocAvailableAppointments.dart | 2 +- .../waiting_appointment_verification.dart | 22 +++++- .../MyAppointments/AppointmentDetails.dart | 11 +-- lib/pages/ToDoList/ToDo.dart | 1 - .../appointment_services/GetDoctorsList.dart | 13 ++++ 9 files changed, 112 insertions(+), 18 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 2b75fe23..a13acd51 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -333,6 +333,8 @@ var GET_PATIENT_HEALTH_STATS = 'Services/Patients.svc/REST/Med_GetTransactionsSt var SEND_CHECK_IN_NFC_REQUEST = 'Services/Patients.svc/REST/Patient_CheckAppointmentValidation_ForNFC'; +var CHECK_SCANNED_NFC_QR_CODE = 'Services/Patients.svc/REST/Patient_ValidationMachine_ForNFC'; + var HAS_DENTAL_PLAN = 'Services/Doctors.svc/REST/Dental_IsPatientHasOnGoingEstimation'; var LASER_BODY_PARTS = 'Services/Patients.svc/REST/Laser_GetBodyPartsByCategory'; @@ -668,10 +670,10 @@ var GET_DENTAL_INSTRUCTIONS = 'Services/OUTPs.svc/Rest/getProcedureNotification' //PAYFORT var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails"; var addPayFortApplePayResponse = "Services/PayFort_Serv.svc/REST/AddResponse"; -var payFortEnvironment = FortEnvironment.production; -var applePayMerchantId = "merchant.com.hmgwebservices"; -// var payFortEnvironment = FortEnvironment.test; -// var applePayMerchantId = "merchant.com.hmgwebservices.uat"; +// var payFortEnvironment = FortEnvironment.production; +// var applePayMerchantId = "merchant.com.hmgwebservices"; +var payFortEnvironment = FortEnvironment.test; +var applePayMerchantId = "merchant.com.hmgwebservices.uat"; class AppGlobal { static var context; diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index b2ccf085..a5d6b8a2 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/header_model.dart'; +import 'package:diplomaticquarterapp/pages/ToDoList/widgets/paymentDialog.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/routes.dart'; @@ -41,7 +42,10 @@ class BookConfirm extends StatefulWidget { bool isLiveCareAppointment; int initialSlotDuration; - BookConfirm({required this.doctor, required this.selectedDate, required this.isLiveCareAppointment, required this.selectedTime, required this.initialSlotDuration}); + bool isWalkinAppointment = false; + + BookConfirm( + {required this.doctor, required this.selectedDate, required this.isLiveCareAppointment, required this.selectedTime, required this.initialSlotDuration, required this.isWalkinAppointment}); late DoctorsListService service; late PatientShareResponse patientShareResponse; @@ -212,10 +216,14 @@ class _BookConfirmState extends State { elevation: 0, onPressed: () async { bool isLiveCareSchedule = await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT) ?? false; - if (isLiveCareSchedule) { - insertLiveCareScheduledAppointment(context, widget.doctor); + if (widget.isWalkinAppointment) { + getWalkinAppointmentPatientShare(); } else { - insertAppointment(context, widget.doctor, widget.initialSlotDuration); + if (isLiveCareSchedule) { + insertLiveCareScheduledAppointment(context, widget.doctor); + } else { + insertAppointment(context, widget.doctor, widget.initialSlotDuration); + } } }, child: Text(TranslationBase.of(context).bookAppo, style: TextStyle(fontSize: 16.0, letterSpacing: -0.48, color: Colors.white)), @@ -226,6 +234,39 @@ class _BookConfirmState extends State { ); } + openPaymentDialog(AppoitmentAllHistoryResultList appo, PatientShareResponse patientShareResponse) { + showGeneralDialog( + barrierColor: Colors.black.withOpacity(0.5), + transitionBuilder: (context, a1, a2, widget) { + final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0; + return Transform( + transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0), + child: Opacity( + opacity: a1.value, + child: PaymentDialog( + appo: appo, + patientShareResponse: patientShareResponse, + isCashPatient: isCash, + onPaymentMethodSelected: () {}, + ), + ), + ); + }, + transitionDuration: Duration(milliseconds: 500), + barrierDismissible: false, + barrierLabel: '', + context: context, + pageBuilder: (context, animation1, animation2) => SizedBox()).then((value) { + print(value); + if (value != null) { + // navigateToPaymentMethod(context, value as PatientShareResponse, appo); + // projectViewModel.analytics.todoList.to_do_list_confirm_payment_details(appo); + } else { + // projectViewModel.analytics.todoList.to_do_list_cancel_payment_details(appo); + } + }); + } + Widget showInfo(String title, String des) { return Container( child: Row( @@ -253,6 +294,25 @@ class _BookConfirmState extends State { ); } + getWalkinAppointmentPatientShare() { + AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList(); + GifLoaderDialogUtils.showMyDialog(context); + appo.doctorTitle = widget.doctor.doctorTitle; + appo.doctorNameObj = widget.doctor.name; + appo.appointmentDate = DateUtil.convertDateToString(DateTime.now()); + appo.projectName = widget.doctor.projectName; + + widget.service.getLiveCareAppointmentPatientShare("2016068106", 601, 15, projectViewModel.isArabic ? 1 : 2, context).then((res) { + widget.patientShareResponse = new PatientShareResponse.fromJson(res); + GifLoaderDialogUtils.hideDialog(context); + openPaymentDialog(appo, widget.patientShareResponse!); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: err); + print(err); + }); + } + cancelAppointment(DoctorList docObject, AppoitmentAllHistoryResultList appo, BuildContext context) async { ConfirmDialog.closeAlertDialog(context); GifLoaderDialogUtils.showMyDialog(context, barrierDismissible: false); diff --git a/lib/pages/BookAppointment/DoctorProfile.dart b/lib/pages/BookAppointment/DoctorProfile.dart index e5ec30e6..b70a55a8 100644 --- a/lib/pages/BookAppointment/DoctorProfile.dart +++ b/lib/pages/BookAppointment/DoctorProfile.dart @@ -591,6 +591,7 @@ class _DoctorProfileState extends State with TickerProviderStateM selectedDate: DocAvailableAppointments.selectedDate!, selectedTime: DocAvailableAppointments.selectedTime!, initialSlotDuration: DocAvailableAppointments.initialSlotDuration!, + isWalkinAppointment: false, ), ), ); diff --git a/lib/pages/BookAppointment/QRCode.dart b/lib/pages/BookAppointment/QRCode.dart index a96e8dc6..d78c3388 100644 --- a/lib/pages/BookAppointment/QRCode.dart +++ b/lib/pages/BookAppointment/QRCode.dart @@ -384,9 +384,7 @@ class _QRCodeState extends State { sendNfcCheckInRequest(String nfcId, int checkInBy) { GifLoaderDialogUtils.showMyDialog(context); - DoctorsListService service = new DoctorsListService(); - service.sendCheckinNfcRequest(widget!.patientShareResponse!.appointmentNo!, nfcId, widget.patientShareResponse!.projectID!, checkInBy, context).then((res) { print(res); diff --git a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart index c18e5d9a..ad5372f6 100644 --- a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart +++ b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart @@ -208,7 +208,7 @@ class _DocAvailableAppointmentsState extends State wit openTimeSlotsPickerForDate(DateTime dateStart, List freeSlots) { dayEvents.clear(); DateTime dateStartObj = new DateTime(dateStart.year, dateStart.month, dateStart.day, 0, 0, 0, 0, 0); - if (isWaitingAppointmentAvailable) { + if (isWaitingAppointmentAvailable && DateUtils.isSameDay(dateStart, DateTime.now())) { dayEvents.add(TimeSlot(isoTime: TranslationBase.of(context).waitingAppointment, start: DateTime.now(), end: DateTime.now(), vidaDate: "")); } freeSlots.forEach((v) { diff --git a/lib/pages/BookAppointment/waiting_appointment/waiting_appointment_verification.dart b/lib/pages/BookAppointment/waiting_appointment/waiting_appointment_verification.dart index 0b806ace..4fa8ef3d 100644 --- a/lib/pages/BookAppointment/waiting_appointment/waiting_appointment_verification.dart +++ b/lib/pages/BookAppointment/waiting_appointment/waiting_appointment_verification.dart @@ -2,6 +2,7 @@ import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:diplomaticquarterapp/core/model/privilege/ProjectDetailListModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/BookConfirm.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; @@ -220,6 +221,22 @@ class _WaitingAppointmentVerificationState extends State value.rawContent)); if (onlineCheckInQRCode != "") { - navigateToBookConfirm(context); + checkScannedNFCAndQRCode(onlineCheckInQRCode); } else {} } } diff --git a/lib/pages/MyAppointments/AppointmentDetails.dart b/lib/pages/MyAppointments/AppointmentDetails.dart index 7d552c4f..93473473 100644 --- a/lib/pages/MyAppointments/AppointmentDetails.dart +++ b/lib/pages/MyAppointments/AppointmentDetails.dart @@ -307,15 +307,18 @@ class _AppointmentDetailsState extends State with SingleTick Future navigateToBookConfirm(context) async { Navigator.push( - context, - FadePage( - page: BookConfirm( + context, + FadePage( + page: BookConfirm( doctor: getDoctorObject(), isLiveCareAppointment: widget.appo.isLiveCareAppointment!, selectedDate: DocAvailableAppointments.selectedDate!, selectedTime: DocAvailableAppointments.selectedTime!, initialSlotDuration: 0, - ))); + isWalkinAppointment: false, + ), + ), + ); } void getDoctorRatingsDetails() { diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index 91092bb3..b9c42d05 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -1114,7 +1114,6 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { projectViewModel.analytics.todoList.to_do_list_cancel_payment_details(appo); } }); - projectViewModel.analytics.todoList.to_do_list_pay_now(appo); } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index aaf30b97..7f13dfdf 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -1548,6 +1548,19 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } + Future checkScannedNFCAndQRCode(String nfcCode, int projectId) async { + Map request; + + request = {"NFC_Code": nfcCode, "ProjectID": projectId}; + dynamic localRes; + await baseAppClient.post(CHECK_SCANNED_NFC_QR_CODE, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + Future checkIfHasDentalPlan(int projectID, BuildContext context) async { Map request;