import 'dart:developer'; import 'dart:io'; import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/enum/PayfortEnums.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/OBGyneProcedureListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart'; import 'package:diplomaticquarterapp/models/anicllary-orders/ancillary_order_list_model.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart'; import 'package:diplomaticquarterapp/pages/Blood/blood_donation_appointment_terms_conditions.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/QRCode.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.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/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart'; import 'package:diplomaticquarterapp/services/payfort_services/payfort_project_details_resp_model.dart'; import 'package:diplomaticquarterapp/services/payfort_services/payfort_view_model.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:diplomaticquarterapp/widgets/my_rich_text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_countdown_timer/countdown_timer_controller.dart'; import 'package:flutter_countdown_timer/current_remaining_time.dart'; import 'package:flutter_countdown_timer/flutter_countdown_timer.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; class ToDo extends StatefulWidget { PatientShareResponse? patientShareResponse; var languageID; // MyInAppBrowser? browser; bool? isShowAppBar = true; Function()? onBackClick; bool? isFromMyAppointments; AppoitmentAllHistoryResultList? appointment; ToDo({required this.isShowAppBar, this.onBackClick, this.isFromMyAppointments = false, this.appointment}); @override _ToDoState createState() => _ToDoState(); } class _ToDoState extends State with SingleTickerProviderStateMixin { AppSharedPreferences sharedPref = AppSharedPreferences(); List imagesInfo = []; late ToDoCountProviderModel toDoProvider; late CountdownTimerController controller; late ProjectViewModel projectViewModel; late TabController _tabController; String selectedPaymentMethod = ""; String selectedInstallments = ""; late String tamaraPaymentStatus; late String tamaraOrderID; bool dataLoaded = false; bool isInsured = false; bool isEligible = false; bool isCash = false; MyInAppBrowser? browser; List appoList = []; List ancillaryLists = []; List obGyneAppoList = []; String? transID; @override void initState() { widget.patientShareResponse = new PatientShareResponse(); _tabController = TabController(length: 2, vsync: this); WidgetsBinding.instance.addPostFrameCallback((_) { getPatientAppointmentHistory(); getAncillaryOrders(); }); super.initState(); imagesInfo .add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/todo/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/todo/ar/0.png')); int endTime = DateTime.now().millisecondsSinceEpoch + 1000 * 30; controller = CountdownTimerController(endTime: endTime); } @override void dispose() { super.dispose(); // getToDoCount(); _tabController.dispose(); } @override Widget build(BuildContext context) { toDoProvider = Provider.of(context); projectViewModel = Provider.of(context); return AppScaffold( appBarTitle: TranslationBase.of(context).todoList, imagesInfo: imagesInfo, isShowAppBar: widget.isShowAppBar!, isShowDecPage: true, showNewAppBar: true, showNewAppBarTitle: true, icon: "assets/images/new/bottom_nav/todo.svg", description: TranslationBase.of(context).infoTodo, onTap: widget!.onBackClick, backgroundColor: CustomColors.appBackgroudGrey2Color, body: Column( children: [ TabBar( controller: _tabController, indicatorWeight: 3.0, indicatorSize: TabBarIndicatorSize.tab, labelColor: Color(0xff2B353E), unselectedLabelColor: Color(0xff575757), labelPadding: EdgeInsets.only(top: 15, bottom: 13, left: 20, right: 20), labelStyle: TextStyle( fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins', fontSize: 16, fontWeight: FontWeight.w600, letterSpacing: -0.48, ), unselectedLabelStyle: TextStyle( fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins', fontSize: 16, fontWeight: FontWeight.w600, letterSpacing: -0.48, ), tabs: [Text(TranslationBase.of(context).appointments), Text(TranslationBase.of(context).orders)], onTap: (index) { if (index == 1) { getOBGyneOrdersList(); } }, ), Expanded( child: TabBarView( physics: BouncingScrollPhysics(), controller: _tabController, children: [ SingleChildScrollView( child: Column( children: [ Container( margin: EdgeInsets.only(top: 12), child: AppExpandableNotifier( isExpand: true, hasCounter: true, counter: appoList.length.toString(), title: TranslationBase.of(context).appointments, bodyWidget: appoList.length != 0 ? ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), padding: EdgeInsets.all(0.0), itemCount: appoList.length, itemBuilder: (context, index) { return Container( width: double.infinity, margin: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0), decoration: cardRadius(12), padding: EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( flex: 2, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(top: 4.0), child: appoList[index].clinicID == 265 ? Container( margin: EdgeInsets.only(left: 5.0, right: 5.0), child: SvgPicture.asset("assets/images/new/CoronaIcon.svg", width: 35.0, height: 35.0), ) : appoList[index].isLiveCareAppointment! ? SvgPicture.asset("assets/images/new/virtual.svg") : SvgPicture.asset("assets/images/new/hospital-visit.svg"), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: Text( appoList[index].clinicID == 265 ? TranslationBase.of(context).covidTestTodo : appoList[index].isLiveCareAppointment! ? TranslationBase.of(context).liveCareAppo : TranslationBase.of(context).walkinAppo, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48)), ), Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: CountdownTimer( controller: new CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + (appoList[index].remaniningHoursTocanPay! * 1000) * 60), widgetBuilder: (_, CurrentRemainingTime? time) { return time != null ? Text( '${time.days != null ? time.days : "0"}:${time.hours != null ? time.hours.toString().length == 1 ? "0" + time.hours.toString() : time.hours : "00"}:${time.min}:${time.sec} \n' + TranslationBase.of(context).upcomingTimeLeft, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: CustomColors.accentColor, letterSpacing: -0.48)) : Container(); }, ), ), ], ), ], ), ), Expanded( child: Container( child: InkWell( onTap: () { performNextAction(appoList[index]); }, child: Container( padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), decoration: BoxDecoration( color: getNextActionButtonColor(appoList[index].nextAction), border: Border.all(color: Colors.white, width: 1), borderRadius: BorderRadius.circular(6), ), child: Text( getNextActionText(appoList[index].nextAction), textAlign: TextAlign.center, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.4), ), ), ), ), ), ], ), Padding( padding: const EdgeInsets.only(top: 8.0), child: Text( appoList[index].doctorTitle! + " " + appoList[index].doctorNameObj!, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), ), ), Row( mainAxisSize: MainAxisSize.min, children: [ LargeAvatar( name: appoList[index].doctorTitle! + " " + appoList[index].doctorNameObj!, url: appoList[index].doctorImageURL, width: 52, height: 52, ), SizedBox(width: 11), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ MyRichText(TranslationBase.of(context).clinic + ": ", appoList[index].clinicName!, projectViewModel.isArabic), // MyRichText(TranslationBase.of(context).appointmentDate + ": ", // DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(appoList[index].appointmentDate)) + " " + appoList[index].startTime.substring(0, 5), projectViewModel.isArabic), // Timezone changes appoList[index].isLiveCareAppointment! ? MyRichText( TranslationBase.of(context).appointmentDate + ": ", DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(appoList[index].appointmentDate)) + " " + DateUtil.convertStringToDate(appoList[index].appointmentDate).toString().split(" ")[1].substring(0, 5), projectViewModel.isArabic) : MyRichText( TranslationBase.of(context).appointmentDate + ": ", DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(appoList[index].appointmentDate)) + " " + appoList[index].startTime!.substring(0, 5), projectViewModel.isArabic), MyRichText(TranslationBase.of(context).branch, appoList[index].projectName!, projectViewModel.isArabic), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: [ RatingBar( initialRating: appoList[index].actualDoctorRate.toDouble(), itemSize: 16.0, glowColor: Color(0XFFD02127), unratedColor: Color(0XFFD02127), ignoreGestures: true, ratingWidget: RatingWidget( full: Icon( Icons.star, color: CustomColors.accentColor, ), half: Icon( Icons.star_half, color: CustomColors.accentColor, ), empty: Icon( Icons.star, color: CustomColors.accentColor, ), ), tapOnlyMode: true, allowHalfRating: true, onRatingUpdate: (double value) {}, // : Icons.star_half, // ic: Icons.star, // emptyIcon: Icons.star_border, itemBuilder: (BuildContext context, int index) { }, ), ], ), ], ), ), ], ), Padding( padding: const EdgeInsets.only(top: 12.0), child: Text( getNextActionDescription(appoList[index].nextAction), style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 25 / 16), ), ), InkWell( onTap: () { navigateToAppointmentDetails(context, appoList[index]); }, child: Padding( padding: const EdgeInsets.only(top: 0.0), child: Text( TranslationBase.of(context).moreDetails, style: TextStyle( fontSize: 10, fontWeight: FontWeight.w600, color: CustomColors.accentColor, letterSpacing: -0.48, height: 25 / 16, decoration: TextDecoration.underline), ), ), ), ], ), ); }, ) : getNoDataWidget(context), ), ), Container( margin: EdgeInsets.only(top: 12), child: AppExpandableNotifier( isExpand: true, hasCounter: true, counter: (ancillaryLists.isNotEmpty) ? ancillaryLists[0].ancillaryOrderList!.length.toString() : "0", title: TranslationBase.of(context).anicllaryOrders, bodyWidget: ancillaryLists.length != 0 ? Container( padding: EdgeInsets.all(12), child: ListView.separated( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), reverse: true, itemBuilder: (context, index) { return DoctorCard( onTap: () => ancillaryOrdersDetails(ancillaryLists[0].ancillaryOrderList![index], ancillaryLists[0].projectID), isInOutPatient: true, name: TranslationBase.of(context).dr.toString() + " " + (ancillaryLists[0].ancillaryOrderList![index].doctorName ?? ""), billNo: ancillaryLists[0].ancillaryOrderList![index].orderNo.toString(), profileUrl: "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", subName: ancillaryLists[0].projectName, isLiveCareAppointment: false, date: DateUtil.convertStringToDate(ancillaryLists[0].ancillaryOrderList![index].orderDate), isSortByClinic: true, ); }, itemCount: ancillaryLists[0].ancillaryOrderList!.length, separatorBuilder: (context, index) => SizedBox(height: 14), ), ) : getNoDataWidget(context), )), ], ), ), Container( child: obGyneAppoList.length != 0 ? ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, physics: ScrollPhysics(), padding: EdgeInsets.all(0.0), itemCount: obGyneAppoList.length, itemBuilder: (context, index) { return Container( width: double.infinity, margin: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0), decoration: cardRadius(12), padding: EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(top: 0.0), child: Container( margin: EdgeInsets.only(left: 5.0, right: 5.0), child: SvgPicture.asset("assets/images/new/ultrasound.svg", width: 20.0, height: 20.0), ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: Text(TranslationBase.of(context).walkinAppo, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48)), ), ], ), ], ), Container( child: InkWell( onTap: () { getOBGyneDoctorsList(obGyneAppoList[index].projectID!, obGyneAppoList[index].setupID!, obGyneAppoList[index]); }, child: Container( padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), decoration: BoxDecoration( color: CustomColors.green, border: Border.all(color: Colors.white, width: 1), borderRadius: BorderRadius.circular(6), ), child: Text( TranslationBase.of(context).bookNow, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.4), ), ), ), ), ], ), Padding( padding: const EdgeInsets.only(top: 8.0), child: Text( TranslationBase.of(context).dr + " " + obGyneAppoList[index].doctorName!, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), ), ), Row( mainAxisSize: MainAxisSize.min, children: [ LargeAvatar( name: TranslationBase.of(context).dr + " " + obGyneAppoList[index].doctorName!, url: "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", width: 52, height: 52, ), SizedBox(width: 11), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ MyRichText(TranslationBase.of(context).clinic + ": ", obGyneAppoList[index].clinicDescription!, projectViewModel.isArabic), MyRichText( TranslationBase.of(context).orderDate + ": ", DateUtil.getDayMonthYearHourMinuteDateFormatted(DateUtil.convertStringToDate(obGyneAppoList[index].orderDate)).split(" ")[0], projectViewModel.isArabic), MyRichText(TranslationBase.of(context).branch, obGyneAppoList[index].projectDescription!, projectViewModel.isArabic), ], ), ), ], ), ], ), ); }, ) : getNoDataWidget(context), ), ], ), ), SizedBox( height: 20.0, ), ], ), ); } String getNextActionImage(nextAction) { switch (nextAction) { case 0: return "No Action"; break; case 10: return "assets/images/new-design/confirm_button.png"; break; case 15: return projectViewModel.isArabic ? "assets/images/new-design/pay_online_button_arabic_disabled.png" : "assets/images/new-design/pay_online_button_disabled.png"; break; case 20: return projectViewModel.isArabic ? "assets/images/new-design/pay_online_button_arabic.png" : "assets/images/new-design/pay_online_button.png"; break; case 30: return "assets/images/new-design/NFCIcon_option2.png"; break; case 40: return "assets/images/new-design/video_call_instruction.png"; break; case 50: return "assets/images/new-design/confirm_button.png"; break; case 60: return "assets/images/new-design/waiting_for_doctor.png"; break; case 90: return "assets/images/new-design/NFCIcon_option2.png"; break; default: return ""; } } performNextAction(AppoitmentAllHistoryResultList appo) { switch (appo.nextAction) { case 0: // getAppoQR(context, appo); break; case 10: confirmAppointment(appo); break; case 15: AppToast.showErrorToast(message: TranslationBase.of(context).upcomingPaymentPending); break; case 20: getPatientShare(context, appo); // checkPatientNphiesEligibility(context, appo); break; case 30: getAppoQR(context, appo); break; case 40: openInstructions(appo); break; case 50: confirmAppointment(appo); break; case 60: break; case 90: getAppoQR(context, appo); break; } } openInstructions(AppoitmentAllHistoryResultList appo) { if (appo.clinicID == 134) { Navigator.of(context).push(FadePage(page: BloodDonationAppointmentTermsConditions())); } } Color getNextActionButtonColor(nextAction) { switch (nextAction) { case 0: return CustomColors.accentColor; break; case 10: return CustomColors.green; break; case 15: return CustomColors.grey2; break; case 20: return CustomColors.green; break; case 30: return CustomColors.accentColor; break; case 40: return CustomColors.green; break; case 50: return CustomColors.green; break; case 60: return CustomColors.orange; break; case 90: return CustomColors.accentColor; break; default: return CustomColors.green; } } String getNextActionText(nextAction) { switch (nextAction) { case 0: return "No Action"; break; case 10: return TranslationBase.of(context).confirm; break; case 15: return TranslationBase.of(context).pendingPayment; break; case 20: return TranslationBase.of(context).payNow; break; case 30: return TranslationBase.of(context).viewQR; break; case 40: return TranslationBase.of(context).instruction; break; case 50: return TranslationBase.of(context).confirmLiveCare; break; case 60: return TranslationBase.of(context).waitingForDoctor; break; case 90: return TranslationBase.of(context).checkinOptions; break; default: return ""; } } String getNextActionDescription(nextAction) { switch (nextAction) { case 0: return "No Action"; break; case 10: return TranslationBase.of(context).upcomingConfirm; break; case 15: return TranslationBase.of(context).upcomingPaymentPending; break; case 20: return TranslationBase.of(context).upcomingPaymentNow; break; case 30: return TranslationBase.of(context).upcomingQRNFC; break; case 90: return TranslationBase.of(context).upcomingQRNFC; break; case 40: return TranslationBase.of(context).upcomingVirtual; break; case 50: return TranslationBase.of(context).upcomingLivecare; break; case 60: return TranslationBase.of(context).waitingForDoctor; break; default: return ""; } } getLanguageID() async { var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); setState(() { widget.languageID = languageID; }); } String getDate(String date) { DateTime dateObj = DateUtil.convertStringToDate(date); return DateUtil.getWeekDay(dateObj.weekday) + ", " + dateObj.day.toString() + " " + DateUtil.getMonth(dateObj.month) + " " + dateObj.year.toString() + " " + dateObj.hour.toString() + ":" + getMinute(dateObj); } String getMinute(DateTime dateObj) { if (dateObj.minute == 0) { return dateObj.minute.toString() + "0"; } else { return dateObj.minute.toString(); } } String getDoctorSpeciality(List docSpecial) { String docSpeciality = ""; docSpecial.forEach((v) { docSpeciality = docSpeciality + v + "\n"; }); return docSpeciality; } Future navigateToAppointmentDetails(context, AppoitmentAllHistoryResultList appo) async { GAnalytics.APPOINTMENT_DETAIL_FLOW_TYPE = 'todo list'; Navigator.push(context, FadePage(page: AppointmentDetails(appo: appo, parentIndex: appo.patientStatusType == 42 ? 1 : 0))).then((value) { getPatientAppointmentHistory(); }); projectViewModel.analytics.todoList.to_do_list_more_details(appo); } getOBGyneOrdersList() { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service.getOBGyneOrdersList(context).then((res) { obGyneAppoList.clear(); GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { setState(() { if (res['HIS_OBGYNEProcedureGet_List'].length != 0) { obGyneAppoList.clear(); res['HIS_OBGYNEProcedureGet_List'].forEach((v) { obGyneAppoList.add(new OBGyneProcedureListResponse.fromJson(v)); }); } else { // Navigator.of(context).popAndPushNamed(HOME); } }); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); }); } getOBGyneDoctorsList(int projectID, String setupID, OBGyneProcedureListResponse obGyneProcedureListResponse) { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); List doctorsList = []; List _patientDoctorAppointmentListHospital = []; service.getOBGyneDoctorsList(projectID, setupID, projectViewModel.isArabic ? 1 : 2, context).then((res) { GifLoaderDialogUtils.hideDialog(context); print(res['HIS_ObgyneUltrasoundDoctorsList'][0]); if (res['MessageStatus'] == 1) { setState(() { if (res['HIS_ObgyneUltrasoundDoctorsList'].length != 0) { res['HIS_ObgyneUltrasoundDoctorsList'].forEach((v) { doctorsList.add(new DoctorList.fromJson(v)); }); print(doctorsList.length); doctorsList.forEach((element) { List doctorByHospital = _patientDoctorAppointmentListHospital.where((elementClinic) => elementClinic.filterName == element.projectName).toList(); if (doctorByHospital.length != 0) { _patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList!.add(element); } else { _patientDoctorAppointmentListHospital .add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: element.projectDistanceInKiloMeters.toString(), patientDoctorAppointment: element)); } }); navigateToSearchResults(context, doctorsList, _patientDoctorAppointmentListHospital, obGyneProcedureListResponse); } else { // Navigator.of(context).popAndPushNamed(HOME); } }); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); }); } navigateToSearchResults(context, List docList, List patientDoctorAppointmentListHospital, OBGyneProcedureListResponse obGyneProcedureListResponse) { Navigator.push( context, FadePage( page: SearchResults( isLiveCareAppointment: false, isObGyneAppointment: true, doctorsList: docList, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital, obGyneProcedureListResponse: obGyneProcedureListResponse))); } getAncillaryOrders() { DoctorsListService service = new DoctorsListService(); service.getAncillaryOrders().then((res) { if (res['MessageStatus'] == 1) { if (res['AncillaryOrderList'].length != 0) { res['AncillaryOrderList'].forEach((v) { ancillaryLists.add(new AncillaryOrdersListModel.fromJson(v)); }); } // if (res['AncillaryOrderList'].length != 0) { // res['AncillaryOrderList'].forEach((item) { // ancillaryLists.add(AncillaryOrdersListModel.fromJson(item)); // }); // } // dataLoaded = true; // if (widget.isFromMyAppointments) { // performNextAction(widget.appointment); // widget.isFromMyAppointments = false; // } setState(() {}); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } }).catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); err != null ?? AppToast.showErrorToast(message: err); }); } getPatientAppointmentHistory() async { int languageID = projectViewModel.isArabic ? 1 : 2; GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service.getPatientAppointmentHistory(true, languageID, context).then((res) { appoList.clear(); GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { if (res['AppoimentAllHistoryResultList'].length != 0) { appoList.clear(); res['AppoimentAllHistoryResultList'].forEach((v) { appoList.add(new AppoitmentAllHistoryResultList.fromJson(v)); }); } // if (res['AncillaryOrderList'].length != 0) { // res['AncillaryOrderList'].forEach((item) { // ancillaryLists.add(AncillaryOrdersListModel.fromJson(item)); // }); // } dataLoaded = true; if (widget.isFromMyAppointments!) { performNextAction(widget.appointment!); widget.isFromMyAppointments = false; } setState(() {}); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } }).catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); err != null ?? AppToast.showErrorToast(message: err); }); getToDoCount(); } getToDoCount() { toDoProvider.setState(0, 0, true, "0"); ClinicListService service = new ClinicListService(); service.getActiveAppointmentNo(context).then((res) { if (res['MessageStatus'] == 1) { toDoProvider.setState(res['AppointmentActiveNumber'], res['AncillaryOrderListCount'], true, "0"); } else {} }).catchError((err) { print(err); }); } checkPatientNphiesEligibility(context, AppoitmentAllHistoryResultList appo) { DoctorsListService service = new DoctorsListService(); GifLoaderDialogUtils.showMyDialog(context); service.checkPatientNphiesEligibility(appo.projectID).then((res) { GifLoaderDialogUtils.hideDialog(context); if (res["isNphiesMatchedWithVida"]) { getPatientShare(context, appo); // getToDoCount(); } else { ConfirmDialog dialog = new ConfirmDialog( isDissmissable: false, context: context, confirmMessage: res['ErrorEndUserMessage'], okText: "Update insurance", cancelText: "Continue as cash", okFunction: () => {openUpdateInsurance()}, cancelFunction: () => {continueAsCash(appo)}); dialog.showAlertDialog(context); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); }); } void openUpdateInsurance() { Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); Navigator.push(context, FadePage(page: InsuranceUpdate())); } void continueAsCash(AppoitmentAllHistoryResultList appo) { DoctorsListService service = new DoctorsListService(); GifLoaderDialogUtils.showMyDialog(context); service.convertPatientToCash(appo.projectID!).then((res) { GifLoaderDialogUtils.hideDialog(context); if (res["MessageStatus"] == 1) { getPatientShare(context, appo); // getToDoCount(); } else { AppToast.showErrorToast(message: res["ErrorEndUserMessage"]); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); }); } getPatientShare(context, AppoitmentAllHistoryResultList appo) { int languageID = projectViewModel.isArabic ? 1 : 2; String errorMsg = ""; DoctorsListService service = new DoctorsListService(); if (appo.isLiveCareAppointment!) { getLiveCareAppointmentPatientShare(context, service, appo); } else { GifLoaderDialogUtils.showMyDialog(context); service.getPatientShare(appo.appointmentNo.toString(), appo.clinicID, appo.projectID, languageID, context).then((res) { GifLoaderDialogUtils.hideDialog(context); if (res['OnlineCheckInAppointments'].length != 0) { widget.patientShareResponse = new PatientShareResponse.fromJson(res['OnlineCheckInAppointments'][0]); } isInsured = res["IsInsured"]; isEligible = res["IsEligible"]; isCash = res["IsCash"]; if (isCash) { openPaymentDialog(appo, widget.patientShareResponse!); } else { if (isInsured && isEligible) { openPaymentDialog(appo, widget.patientShareResponse!); } else { if (isInsured && !isEligible) { errorMsg = TranslationBase.of(context).invalidEligibility; } else { errorMsg = TranslationBase.of(context).invalidInsurance; } ConfirmDialog dialog = new ConfirmDialog( isDissmissable: false, context: context, confirmMessage: errorMsg, okText: TranslationBase.of(context).updateInsuranceText, cancelText: TranslationBase.of(context).continueCash, okFunction: () => {openUpdateInsurance()}, cancelFunction: () => {continueAsCash(appo)}); dialog.showAlertDialog(context); } } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); print(err); }); } } getLiveCareAppointmentPatientShare(context, DoctorsListService service, AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); service.getLiveCareAppointmentPatientShare(appo.appointmentNo.toString(), appo.clinicID, appo.projectID, projectViewModel.isArabic ? 1 : 2, context).then((res) { GifLoaderDialogUtils.hideDialog(context); widget.patientShareResponse = new PatientShareResponse.fromJson(res); openPaymentDialog(appo, widget.patientShareResponse!); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); print(err); }); } getAppoQR(context, AppoitmentAllHistoryResultList appo) { // GifLoaderDialogUtils.showMyDialog(context); PatientShareResponse patientShareResponse = new PatientShareResponse(); patientShareResponse.doctorNameObj = appo.doctorNameObj; patientShareResponse.doctorSpeciality = appo.doctorSpeciality; patientShareResponse.projectName = appo.projectName; patientShareResponse.appointmentDate = appo.appointmentDate; patientShareResponse.appointmentNo = appo.appointmentNo; patientShareResponse.clinicID = appo.clinicID; patientShareResponse.projectID = appo.projectID; patientShareResponse.isFollowup = appo.isFollowup; // FlutterNfcKit.nfcAvailability.then((value) { // if (value == NFCAvailability.available) { // PatientShareResponse patientShareResponse = new PatientShareResponse(); patientShareResponse.doctorNameObj = appo.doctorNameObj; patientShareResponse.doctorSpeciality = appo.doctorSpeciality; patientShareResponse.projectName = appo.projectName; patientShareResponse.appointmentDate = appo.appointmentDate; patientShareResponse.appointmentNo = appo.appointmentNo; patientShareResponse.clinicID = appo.clinicID; patientShareResponse.projectID = appo.projectID; patientShareResponse.isFollowup = appo.isFollowup; navigateToQR(context, "", patientShareResponse, appo); projectViewModel.analytics.todoList.to_do_list_check_in(appo); // } else { // Utils.showErrorToast(TranslationBase.of(context).NFCNotSupported); // } // }); projectViewModel.analytics.todoList.to_do_list_check_in(appo); DoctorsListService service = new DoctorsListService(); service.generateAppointmentQR(patientShareResponse, context).then((res) {}).catchError((err) { print(err); }); } Future navigateToQR(context, String appoQR, PatientShareResponse patientShareResponse, AppoitmentAllHistoryResultList appintment) async { Navigator.push(context, FadePage(page: QRCode(patientShareResponse: patientShareResponse, appoQR: appoQR, appointment: appintment))).then((value) { getPatientAppointmentHistory(); }); } 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) { 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); } }); projectViewModel.analytics.todoList.to_do_list_pay_now(appo); } openPayment(List paymentMethod, AuthenticatedUser authenticatedUser, num amount, PatientShareResponse patientShareResponse, AppoitmentAllHistoryResultList appo) { browser = new MyInAppBrowser(onExitCallback: onBrowserExit, appo: appo, onLoadStartCallback: onBrowserLoadStart, context: context); transID = Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo); browser?.openPaymentBrowser( amount, "Appointment check in", transID!, appo.projectID.toString(), authenticatedUser.emailAddress!, paymentMethod[0]!, authenticatedUser.patientType, authenticatedUser.firstName!, authenticatedUser.patientID, authenticatedUser, browser!, appo.isLiveCareAppointment ?? false, "2", appo.isLiveCareAppointment! ? widget.patientShareResponse!.clinicID.toString() : "", context, appo.appointmentDate, appo.appointmentNo, appo.clinicID, appo.doctorID, paymentMethod[1]); } onBrowserLoadStart(String url) { print("onBrowserLoadStart"); print(url); if (selectedPaymentMethod == "TAMARA") { if (Platform.isAndroid) { Uri uri = new Uri.dataFromString(url); tamaraPaymentStatus = uri.queryParameters['status']!; tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!; } else { Uri uri = new Uri.dataFromString(url); tamaraPaymentStatus = uri.queryParameters['paymentStatus']!; tamaraOrderID = uri.queryParameters['orderId']!; } } // if(selectedPaymentMethod != "TAMARA") { MyInAppBrowser.successURLS.forEach((element) { if (url.contains(element)) { browser?.close(); MyInAppBrowser.isPaymentDone = true; return; } }); // } // if(selectedPaymentMethod != "TAMARA") { MyInAppBrowser.errorURLS.forEach((element) { if (url.contains(element)) { browser?.close(); MyInAppBrowser.isPaymentDone = false; return; } }); // } } onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { print("onBrowserExit Called!!!!"); if (selectedPaymentMethod == "TAMARA") { checkTamaraPaymentStatus(transID!, appo); // if (tamaraPaymentStatus != null && tamaraPaymentStatus.toLowerCase() == "approved") { // updateTamaraRequestStatus("success", "14", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo); // } else { // updateTamaraRequestStatus("Failed", "00", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo); // } } else { checkPaymentStatus(appo); } } checkTamaraPaymentStatus(String orderID, AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service.getTamaraPaymentStatus(orderID).then((res) { GifLoaderDialogUtils.hideDialog(context); if (res["status"].toString().toLowerCase() == "success") { updateTamaraRequestStatus("success", "14", orderID, res["tamara_order_id"], int.parse(selectedInstallments!), appo); } else { updateTamaraRequestStatus("Failed", "00", transID!, tamaraOrderID != null ? tamaraOrderID : "", int.parse(selectedInstallments), appo); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); print(err); }); } addAdvancedNumberRequestTamara(String advanceNumber, String paymentReference, String appointmentID, AppoitmentAllHistoryResultList appo) { DoctorsListService service = new DoctorsListService(); service.addAdvancedNumberRequest(advanceNumber, paymentReference, appointmentID, context).then((res) {}).catchError((err) { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); print(err); }); } updateTamaraRequestStatus(String responseMessage, String status, String clientRequestID, String tamaraOrderID, int selectedInstallments, AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); try { DoctorsListService service = new DoctorsListService(); service.updateTamaraRequestStatus(responseMessage, status, clientRequestID, tamaraOrderID, selectedInstallments).then((res) { GifLoaderDialogUtils.hideDialog(context); if (tamaraPaymentStatus.toLowerCase() == "approved") { markAppointmentForTamara(appo); addAdvancedNumberRequestTamara("Tamara-Advance-0000", tamaraOrderID, appo.appointmentNo.toString(), appo); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); AppToast.showErrorToast(message: err); }); } catch (err) { print(err); } } markAppointmentForTamara(AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); var apptData = { "AppointmentNo": appo.appointmentNo.toString(), "DoctorID": appo.doctorID.toString(), "ServiceID": appo.serviceID.toString(), "ProjectID": appo.projectID.toString(), "ClinicID": appo.clinicID.toString(), "AppointmentDate": appo.appointmentDate.toString(), }; DoctorsListService service = new DoctorsListService(); service.markAppointmentForTamara(appo.projectID!, appo.appointmentNo.toString()).then((res) { GifLoaderDialogUtils.hideDialog(context); if (appo.isLiveCareAppointment!) addVIDARequestInsert("0", tamaraOrderID, appo); else getAppoQR(context, appo); }).catchError((err) { print(err); AppToast.showErrorToast(message: err); GifLoaderDialogUtils.hideDialog(context); }); } checkPaymentStatus(AppoitmentAllHistoryResultList appo) { String txn_ref; num? amount; String? payment_method; final currency = projectViewModel.user!.outSA == 0 ? "sar" : 'aed'; GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service.checkPaymentStatus(transID!, false, context).then((res) { GifLoaderDialogUtils.hideDialog(context); String paymentInfo = res['Response_Message']; if (paymentInfo == 'Success') { txn_ref = res['Merchant_Reference']; amount = res['Amount']; payment_method = res['PaymentMethod']; createAdvancePayment(res, appo); projectViewModel.analytics.appointment.payment_success( appointment_type: 'regular', payment_method: payment_method, clinic: appo.clinicName, hospital: appo.projectName, txn_amount: "$amount", txn_currency: currency, txn_number: txn_ref); } else { AppToast.showErrorToast(message: res['Response_Message']); projectViewModel.analytics.appointment.payment_fail( appointment_type: 'regular', payment_method: payment_method!, clinic: appo.clinicName, hospital: appo.projectName, txn_amount: "$amount!", txn_currency: currency, error_type: res['Response_Message']); } }).catchError((err) { if (mounted) GifLoaderDialogUtils.hideDialog(context); print(err); }); } createAdvancePayment(res, AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); String paymentReference = res['Fort_id'].toString(); service.createAdvancePayment(appo, appo.projectID.toString(), res['Amount'], res['Fort_id'], res['PaymentMethod'], context).then((res) { GifLoaderDialogUtils.hideDialog(context); addAdvancedNumberRequest( Utils.isVidaPlusProject(projectViewModel, appo.projectID!) ? res['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() : res['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), paymentReference, appo.appointmentNo.toString(), appo, res['OnlineCheckInAppointments'][0]); }).catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); }); } addAdvancedNumberRequest(String advanceNumber, String paymentReference, String appointmentID, AppoitmentAllHistoryResultList appo, dynamic apptData) { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service.addAdvancedNumberRequest(advanceNumber, paymentReference, appointmentID, context).then((res) { GifLoaderDialogUtils.hideDialog(context); if (appo.isLiveCareAppointment!) addVIDARequestInsert(advanceNumber, paymentReference, appo); else getAppoQR(context, appo); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); }); } addVIDARequestInsert(String advanceNumber, String paymentReference, AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service .insertVIDARequest(appo.appointmentNo, appo.clinicID, appo.projectID, appo.serviceID, appo.doctorID, appo.appointmentDate!, transID!, projectViewModel.isArabic ? 1 : 2, context) .then((res) { GifLoaderDialogUtils.hideDialog(context); getPatientAppointmentHistory(); }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); }); } Future navigateToPaymentMethod(context, PatientShareResponse patientShareResponse, AppoitmentAllHistoryResultList appo) async { Navigator.push( context, FadePage( page: PaymentMethod( onSelectedMethod: (String metohd, [String? selectedInstallmentPlan]) { setState(() {}); }, patientShare: widget.patientShareResponse!.patientShareWithTax))) .then((value) { print(value); selectedPaymentMethod = value[0] ?? ""; selectedInstallments = value[1] ?? ""; getPatientAppointmentHistory(); if (value != null) { final appType = appo.isLiveCareAppointment! ? 'livecare' : 'regular'; if (selectedPaymentMethod == "ApplePay") { if (projectViewModel.havePrivilege(103)) { startApplePay(appo, patientShareResponse); } else { openPayment(value, projectViewModel.user, double.parse(patientShareResponse.patientShareWithTax.toString()), patientShareResponse, appo); } } else { openPayment(value, projectViewModel.user, double.parse(patientShareResponse.patientShareWithTax.toString()), patientShareResponse, appo); } projectViewModel.analytics.appointment.payment_method(appointment_type: appType, clinic: appo.clinicName, payment_method: value[0], payment_type: 'appointment'); } }); } void startApplePay(AppoitmentAllHistoryResultList appo, PatientShareResponse patientShareResponse) async { transID = Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo); print("TransactionID: $transID"); GifLoaderDialogUtils.showMyDialog(context); LiveCareService service = new LiveCareService(); ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest(); PayfortProjectDetailsRespModel? payfortProjectDetailsRespModel; await context.read().getProjectDetailsForPayfort(projectId: appo.projectID, serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum()).then((value) { payfortProjectDetailsRespModel = value; }); applePayInsertRequest.clientRequestID = transID; applePayInsertRequest.clinicID = appo.clinicID; applePayInsertRequest.currency = projectViewModel.user.outSA == 1 ? "AED" : "SAR"; // applePayInsertRequest.customerEmail = projectViewModel.authenticatedUserObject.user.emailAddress; applePayInsertRequest.customerEmail = "CustID_${projectViewModel.user.patientID}@HMG.com"; applePayInsertRequest.customerID = projectViewModel.user.patientID; applePayInsertRequest.customerName = projectViewModel.user.firstName! + " " + projectViewModel.user.lastName!; applePayInsertRequest.deviceToken = await AppSharedPreferences().getString(PUSH_TOKEN); applePayInsertRequest.voipToken = await AppSharedPreferences().getString(ONESIGNAL_APNS_TOKEN); applePayInsertRequest.doctorID = appo.doctorID; applePayInsertRequest.projectID = appo.projectID.toString(); applePayInsertRequest.serviceID = ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(); applePayInsertRequest.channelID = 3; applePayInsertRequest.patientID = projectViewModel.user.patientID; applePayInsertRequest.patientTypeID = projectViewModel.user.patientType; applePayInsertRequest.patientOutSA = projectViewModel.user.outSA; applePayInsertRequest.appointmentDate = appo.appointmentDate; applePayInsertRequest.appointmentNo = appo.appointmentNo; applePayInsertRequest.orderDescription = "Appointment Payment"; applePayInsertRequest.liveServiceID = "0"; applePayInsertRequest.latitude = "0.0"; applePayInsertRequest.longitude = "0.0"; applePayInsertRequest.amount = patientShareResponse.patientShareWithTax.toString(); applePayInsertRequest.isSchedule = appo.isLiveCareAppointment! ? "1" : "0"; applePayInsertRequest.language = projectViewModel.isArabic ? 'ar' : 'en'; applePayInsertRequest.languageID = projectViewModel.isArabic ? 1 : 2; applePayInsertRequest.userName = projectViewModel.user.patientID; applePayInsertRequest.responseContinueURL = "http://hmg.com/Documents/success.html"; applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html"; applePayInsertRequest.paymentOption = "ApplePay"; applePayInsertRequest.isMobSDK = true; applePayInsertRequest.merchantReference = transID; applePayInsertRequest.merchantIdentifier = payfortProjectDetailsRespModel!.merchantIdentifier; applePayInsertRequest.commandType = "PURCHASE"; applePayInsertRequest.signature = payfortProjectDetailsRespModel!.signature; applePayInsertRequest.accessCode = payfortProjectDetailsRespModel!.accessCode; applePayInsertRequest.shaRequestPhrase = payfortProjectDetailsRespModel!.shaRequest; applePayInsertRequest.shaResponsePhrase = payfortProjectDetailsRespModel!.shaResponse; applePayInsertRequest.returnURL = ""; service.applePayInsertRequest(applePayInsertRequest, context).then((res) async { if (res["MessageStatus"] == 1) { await context.read().initiateApplePayWithPayfort( customerName: projectViewModel.user.firstName! + " " + projectViewModel.user.lastName!, // customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress, customerEmail: "CustID_${projectViewModel.user.patientID}@HMG.com", orderDescription: "Appointment Payment", orderAmount: double.parse(patientShareResponse.patientShareWithTax.toString()), merchantReference: transID, payfortProjectDetailsRespModel: payfortProjectDetailsRespModel, currency: projectViewModel.user.outSA == 1 ? "AED" : "SAR", onFailed: (failureResult) async { GifLoaderDialogUtils.hideDialog(context); log("failureResult: ${failureResult.toString()}"); AppToast.showErrorToast(message: failureResult.toString()); }, onSuccess: (successResult) async { log("Payfort: ${successResult.responseMessage}"); await context.read().addPayfortApplePayResponse(projectViewModel.user.patientID!, result: successResult); checkPaymentStatus(appo); }, projectId: appo.projectID, serviceTypeEnum: ServiceTypeEnum.appointmentPayment, ); } else { GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: "An error occurred while processing your request"); } }).catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); AppToast.showErrorToast(message: err); }); } confirmAppointment(AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service.confirmAppointment(appo.appointmentNo!, appo.clinicID!, appo.projectID!, appo.isLiveCareAppointment!, context).then((res) { GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { AppToast.showSuccessToast(message: res['ErrorEndUserMessage']); if (appo.isLiveCareAppointment!) { insertLiveCareVIDARequest(appo); } else { getPatientAppointmentHistory(); } projectViewModel.analytics.todoList.to_do_list_confirm_appointment(appo); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } }).catchError((err) { GifLoaderDialogUtils.hideDialog(context); print(err); }); } insertLiveCareVIDARequest(AppoitmentAllHistoryResultList appo) { GifLoaderDialogUtils.showMyDialog(context); DoctorsListService service = new DoctorsListService(); service .insertVIDARequest(appo.appointmentNo, appo.clinicID, appo.projectID, appo.serviceID, appo.doctorID, appo.appointmentDate!, Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), projectViewModel.isArabic ? 1 : 2, context) .then((res) { GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { AppToast.showSuccessToast(message: res['ErrorEndUserMessage']); getPatientAppointmentHistory(); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } }).catchError((err) { print(err); GifLoaderDialogUtils.hideDialog(context); }); } ancillaryOrdersDetails(item, projectId) { Navigator.push( context, FadePage( page: AnicllaryOrdersDetails(item.appointmentNo, item.orderNo, projectId), ), ); } }