diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 3183e021..0f437ebb 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -2007,7 +2007,6 @@ "generalInstructions": "تعليمات عامة", "copyLink": "نسخ الوصلة:", "paymentLinkCopied": "تم نسخ رابط الدفع إلى الحافظة الخاصة بك!", - "copyLinkTxt": "أو يمكنك نسخ رابط الدفع من الأسفل وإرساله إلى شخص يمكنه الدفع نيابة عنك:", "proErrorMessage": "عزيزي المريض ، طاقم العمل لدينا خارج المكتب حاليًا ، يرجى ملاحظة أن ساعات العمل لدينا من 7:00 صباحًا إلى 10:00 مساءً ، ويسعدنا مساعدتك خلال هذا الوقت ، أو يمكنك الاتصال", "InPatient": "مريض منوم", "admissionReq": "طلب القبول", @@ -2040,5 +2039,7 @@ "patientsRightsConsent": "الإقرار بحقوق ومسؤوليات المرضى: ", "generalConsent13": "أنا الموقع أدناه أقر بانه تم تزويدي بـ وثيقة حقوق ومسؤوليات المرضى وقام الموظف المختص بشرح وثيقة حقوق ومسؤوليات المرضى لي.", "acknowledgementConsent": "الإقرارات: ", - "generalConsent14": "لقد قرأت وفهمت وأوافق على الشروط والأحكام المبينة أعلاه وأوافق على الإلتزام بالمتطلبات المذكورة تجاه المستشفى ، لقد قرأت التفاصيل المبينة في نموذج التسجيل الخاص بي وأقر بأنها صحيحة. أنا الموقع ادناه أقر بأنه أتيحت لي الفرصة لطرح الأسئلة والتحفظات بشأن هذه الموافقة، وتلقيت إجابات مرضية على جميع إستفساراتي." + "generalConsent14": "لقد قرأت وفهمت وأوافق على الشروط والأحكام المبينة أعلاه وأوافق على الإلتزام بالمتطلبات المذكورة تجاه المستشفى ، لقد قرأت التفاصيل المبينة في نموذج التسجيل الخاص بي وأقر بأنها صحيحة. أنا الموقع ادناه أقر بأنه أتيحت لي الفرصة لطرح الأسئلة والتحفظات بشأن هذه الموافقة، وتلقيت إجابات مرضية على جميع إستفساراتي.", + "patientNameLbl": "اسم المريض: ", + "copyLinkTxt": "يمكنك إتمام الدفع بنفسك، أو نسخ رابط الدفع أدناه وإرساله إلى شخص آخر ليقوم بالدفع نيابةً عنك." } diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 51ec1058..c1547dd2 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -1995,9 +1995,8 @@ "noMedicalInstructions": "You do not have any medical instructions right now.", "medicalInstructions": "Medical Instructions", "generalInstructions": "General Instructions", - "copyLink": "COPY LINK", + "copyLink": "Copy Link", "paymentLinkCopied": "Payment link copied to your clipboard!'", - "copyLinkTxt": "Or you can copy the payment link from below & send it to someone who can pay on your behalf: ", "proErrorMessage": "Dear patient, Our staff is currently out of office, please note that our working hours are from 7:00 AM to 10:00 PM, and we'd love to help you during that time, or you can call us.", "InPatient": "InPatient", "admissionReq": "Admission Request", @@ -2030,7 +2029,9 @@ "patientsRightsConsent": "ACKNOWLEDGEMENT OF NOTICE OF PATIENT RIGHTS AND RESPONSIBILITIES: ", "generalConsent13": "I, the undersigned, acknowledge that I have been provided with a copy of the Patients' Bill of Right and Responsibilities and the admission staff has explained to me Patients' Bill of Right and Responsibilities.", "acknowledgementConsent": "ACKNOWLEDGEMENTS: ", - "generalConsent14": "I, the undersigned, acknowledge that I have been provided with a copy of the Patients' Bill of Right and Responsibilities and the admission staff has explained to me Patients' Bill of Right and Responsibilities." + "generalConsent14": "I, the undersigned, acknowledge that I have been provided with a copy of the Patients' Bill of Right and Responsibilities and the admission staff has explained to me Patients' Bill of Right and Responsibilities.", + "patientNameLbl": "Patient Name: ", + "copyLinkTxt": "You can pay yourself or you can copy the payment link from below & send it to someone who can pay on your behalf." } diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index 93474cef..e26d41dc 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -211,7 +211,7 @@ class ApiClientImp implements ApiClient { } body['TokenID'] = "@dm!n"; - // body['PatientID'] = 2122445; + // body['PatientID'] = 4777326; // body['PatientID'] = 53320; // body['PatientTypeID'] = 1; // body['PatientOutSA'] = 0; diff --git a/lib/features/inpatient_services/inpatient_services_repo.dart b/lib/features/inpatient_services/inpatient_services_repo.dart index 997c1cec..69091e61 100644 --- a/lib/features/inpatient_services/inpatient_services_repo.dart +++ b/lib/features/inpatient_services/inpatient_services_repo.dart @@ -37,6 +37,26 @@ abstract class InpatientServicesRepo { required int admissionNo, required int admissionReqNo, }); + + Future>> insertForGeneralAdmissionConsent({ + required int projectID, + required int clinicID, + required int admissionReqNo, + required int patientID, + required int status, + }); + + Future>> getInPatientPaymentLink({ + required int projectID, + required int clinicID, + required int paymentRequestID, + required int admissionNo, + required int orderID, + required String name, + required String email, + required num amount, + required String nationalID, + }); } class InpatientServicesRepoImp implements InpatientServicesRepo { @@ -302,4 +322,108 @@ class InpatientServicesRepoImp implements InpatientServicesRepo { return Left(UnknownFailure(e.toString())); } } + + @override + Future> insertForGeneralAdmissionConsent( + {required int projectID, required int clinicID, required int admissionReqNo, required int patientID, required int status}) async { + Map mapDevice = { + "AdmissionRequestNo": admissionReqNo, + "ClinicID": clinicID, + "CreatedBy": 102, + "PatientID": patientID, + "ProjectID": projectID, + "status": status, + "searchKey": "", + "pageIndex": 0, + "pageSize": 0, + }; + + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post( + INSERT_GENERAL_ADMISSION_CONSENT, + body: mapDevice, + onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, + onSuccess: (res, statusCode, {messageStatus, errorMessage}) { + try { + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: res, + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, + ); + if (failure != null) return Left(failure!); + if (apiResponse == null) return Left(ServerFailure("Unknown error")); + return Right(apiResponse!); + } catch (e) { + return Left(UnknownFailure(e.toString())); + } + } + + @override + Future> getInPatientPaymentLink( + {required int projectID, + required int clinicID, + required int paymentRequestID, + required int admissionNo, + required int orderID, + required String name, + required String email, + required num amount, + required String nationalID}) async { + Map mapDevice = { + "ProjectID": projectID, + "PaymentRequestId": paymentRequestID, + "ClientOrderID": orderID, + "OrderDescription": "InPatient Advance Payment", + "CustomerName": name, + "CustomerEmail": email, + "Amount": amount, + "IsPaid": 0, + "AppointmentID": admissionNo.toString(), + "PaymentOption": "0", + "PaymentReferenceNumber": admissionNo, + "SourceType": "1", + "NationalID": nationalID, + "ClinicID": clinicID, + "createdBy": 102 + }; + + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post( + GET_INPATIENT_ADVANCE_PAYMENT_LINK, + body: mapDevice, + onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, + onSuccess: (res, statusCode, {messageStatus, errorMessage}) { + try { + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: res, + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, + ); + if (failure != null) return Left(failure!); + if (apiResponse == null) return Left(ServerFailure("Unknown error")); + return Right(apiResponse!); + } catch (e) { + return Left(UnknownFailure(e.toString())); + } + } } diff --git a/lib/features/inpatient_services/inpatient_services_view_model.dart b/lib/features/inpatient_services/inpatient_services_view_model.dart index 119e6c06..942a29ec 100644 --- a/lib/features/inpatient_services/inpatient_services_view_model.dart +++ b/lib/features/inpatient_services/inpatient_services_view_model.dart @@ -16,6 +16,8 @@ import 'package:hmg_patient_app_new/services/error_handler_service.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; +import 'package:share_plus/share_plus.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../../generated/locale_keys.g.dart'; @@ -42,6 +44,8 @@ class InpatientServicesViewModel extends ChangeNotifier { int advancePaymentSelectedTabIndex = 0; + String advancePaymentRequestLink = ""; + InpatientServicesViewModel({required this.inpatientServicesRepo, required this.errorHandlerService, required this.appState}); initInPatientServices() { @@ -52,6 +56,7 @@ class InpatientServicesViewModel extends ChangeNotifier { hasDischargeMedicationOrder = false; advancePaymentSelectedTabIndex = 0; isAdvancePaymentHistoryLoading = true; + advancePaymentRequestLink = ""; notifyListeners(); } @@ -301,4 +306,70 @@ class InpatientServicesViewModel extends ChangeNotifier { }, ); } + + Future insertForGeneralAdmissionConsent( + {required int projectID, required int clinicID, required int admissionReqNo, required int patientID, required int status, Function(dynamic)? onSuccess, Function(String)? onError}) async { + final result = await inpatientServicesRepo.insertForGeneralAdmissionConsent(projectID: projectID, clinicID: clinicID, admissionReqNo: admissionReqNo, patientID: patientID, status: status); + + result.fold( + (failure) async { + if (onError != null) { + onError(failure.message.toString()); + } + }, + (apiResponse) { + if (apiResponse.messageStatus == 2) { + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } + + Future getInPatientPaymentLink( + {required int projectID, + required int clinicID, + required int paymentRequestID, + required int admissionNo, + required int orderID, + required String name, + required String email, + required num amount, + required String nationalID, + required bool isCopy, + Function(dynamic)? onSuccess, + Function(String)? onError}) async { + final result = await inpatientServicesRepo.getInPatientPaymentLink( + projectID: projectID, clinicID: clinicID, paymentRequestID: paymentRequestID, admissionNo: admissionNo, orderID: orderID, name: name, email: email, amount: amount, nationalID: nationalID); + + result.fold( + (failure) async { + if (onError != null) { + onError(failure.message.toString()); + } + }, + (apiResponse) { + if (apiResponse.messageStatus == 2) { + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + advancePaymentRequestLink = apiResponse.data['PaymentUrl']; + if (isCopy) { + Share.share(advancePaymentRequestLink); + } else { + Uri uri = Uri.parse(advancePaymentRequestLink); + launchUrl(uri, mode: LaunchMode.externalApplication); + // this.browser.openUrlRequest(urlRequest: URLRequest(url: WebUri.uri(Uri.parse(paymentLink))), options: _InAppBrowserOptions); + } + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 3daabda2..8063e4d9 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -1987,7 +1987,6 @@ abstract class LocaleKeys { static const generalInstructions = 'generalInstructions'; static const copyLink = 'copyLink'; static const paymentLinkCopied = 'paymentLinkCopied'; - static const copyLinkTxt = 'copyLinkTxt'; static const proErrorMessage = 'proErrorMessage'; static const InPatient = 'InPatient'; static const admissionReq = 'admissionReq'; @@ -2021,5 +2020,7 @@ abstract class LocaleKeys { static const generalConsent13 = 'generalConsent13'; static const acknowledgementConsent = 'acknowledgementConsent'; static const generalConsent14 = 'generalConsent14'; + static const patientNameLbl = 'patientNameLbl'; + static const copyLinkTxt = 'copyLinkTxt'; } diff --git a/lib/presentation/inpatient_services/general_consent_page.dart b/lib/presentation/inpatient_services/general_consent_page.dart index ecf92ac9..323e0f0c 100644 --- a/lib/presentation/inpatient_services/general_consent_page.dart +++ b/lib/presentation/inpatient_services/general_consent_page.dart @@ -1,19 +1,29 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.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/inpatient_services/inpatient_services_view_model.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; +import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; +import 'package:provider/provider.dart'; import '../../generated/locale_keys.g.dart'; class GeneralConsentPage extends StatelessWidget { - const GeneralConsentPage({super.key}); + GeneralConsentPage({super.key}); + + late InpatientServicesViewModel inPatientServicesViewModel; @override Widget build(BuildContext context) { + inPatientServicesViewModel = Provider.of(context, listen: false); return Scaffold( backgroundColor: AppColors.bgScaffoldColor, body: Column( @@ -107,7 +117,32 @@ class GeneralConsentPage extends StatelessWidget { Expanded( child: CustomButton( text: LocaleKeys.rejectView.tr(), - onPressed: () {}, + onPressed: () { + LoaderBottomSheet.showLoader(); + inPatientServicesViewModel.insertForGeneralAdmissionConsent( + projectID: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.projectID! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.projectId!, + clinicID: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.clinicID! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.clinicId!, + admissionReqNo: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.admissionRequestNo! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.admissionRequestNo!, + patientID: getIt.get().getAuthenticatedUser()!.patientId!, + status: 0, + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight(context, child: Utils.getSuccessWidget(loadingText: LocaleKeys.success.tr(context: context)), callBackFunc: () { + Navigator.pop(context); + }, isCloseButtonVisible: true, isFullScreen: false); + }, + onError: (err) { + showCommonBottomSheetWithoutHeight(context, child: Utils.getErrorWidget(loadingText: err.toString()), callBackFunc: () { + Navigator.pop(context); + }, isCloseButtonVisible: true, isFullScreen: false); + }); + }, backgroundColor: AppColors.secondaryLightRedColor, borderColor: AppColors.secondaryLightRedColor, textColor: AppColors.primaryRedColor, @@ -123,10 +158,35 @@ class GeneralConsentPage extends StatelessWidget { Expanded( child: CustomButton( text: LocaleKeys.acceptLbl.tr(), - onPressed: () {}, + onPressed: () { + LoaderBottomSheet.showLoader(); + inPatientServicesViewModel.insertForGeneralAdmissionConsent( + projectID: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.projectID! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.projectId!, + clinicID: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.clinicID! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.clinicId!, + admissionReqNo: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.admissionRequestNo! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.admissionRequestNo!, + patientID: getIt.get().getAuthenticatedUser()!.patientId!, + status: 1, + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight(context, child: Utils.getSuccessWidget(loadingText: LocaleKeys.success.tr(context: context)), callBackFunc: () { + Navigator.pop(context); + }, isCloseButtonVisible: true, isFullScreen: false, isAutoDismiss: true); + }, + onError: (err) { + showCommonBottomSheetWithoutHeight(context, child: Utils.getErrorWidget(loadingText: err.toString()), callBackFunc: () { + Navigator.pop(context); + }, isCloseButtonVisible: true, isFullScreen: false, isAutoDismiss: true); + }); + }, backgroundColor: AppColors.successColor, borderColor: AppColors.successColor, - textColor: AppColors.textColor, + textColor: AppColors.whiteColor, fontSize: 14.f, isBold: true, borderRadius: 12.r, diff --git a/lib/presentation/inpatient_services/inpatient_advance_payment_page.dart b/lib/presentation/inpatient_services/inpatient_advance_payment_page.dart index dc046232..cd0722ac 100644 --- a/lib/presentation/inpatient_services/inpatient_advance_payment_page.dart +++ b/lib/presentation/inpatient_services/inpatient_advance_payment_page.dart @@ -1,17 +1,24 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.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/inpatient_services/inpatient_services_view_model.dart'; -import 'package:hmg_patient_app_new/generated/codegen_loader.g.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; +import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; +import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart'; +import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; import 'package:hmg_patient_app_new/widgets/custom_tab_bar.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; import 'package:provider/provider.dart'; +import '../../generated/locale_keys.g.dart'; + class InpatientAdvancePaymentPage extends StatelessWidget { const InpatientAdvancePaymentPage({super.key}); @@ -19,37 +26,218 @@ class InpatientAdvancePaymentPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.bgScaffoldColor, - body: CollapsingListView( - title: LocaleKeys.advancePayment.tr(), - child: Consumer(builder: (context, inpatientServicesVM, child) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: 16.h), - CustomTabBar( - activeTextColor: Color(0xffED1C2B), - activeBackgroundColor: Color(0xffED1C2B).withValues(alpha: .1), - initialIndex: 0, - tabs: [ - CustomTabBarModel(null, LocaleKeys.requests.tr(context: context)), - CustomTabBarModel(null, LocaleKeys.history.tr(context: context)), + body: Column( + children: [ + Expanded( + child: CollapsingListView( + title: LocaleKeys.advancePayment.tr(), + child: Consumer(builder: (context, inpatientServicesVM, child) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 16.h), + CustomTabBar( + activeTextColor: Color(0xffED1C2B), + activeBackgroundColor: Color(0xffED1C2B).withValues(alpha: .1), + initialIndex: 0, + tabs: [ + CustomTabBarModel(null, LocaleKeys.requests.tr(context: context)), + CustomTabBarModel(null, LocaleKeys.history.tr(context: context)), + ], + onTabChange: (index) { + inpatientServicesVM.onTabChanged(index); + }, + ).paddingSymmetrical(24.h, 0.h), + SizedBox(height: 24.h), + getSelectedTabView(context).paddingSymmetrical(24.h, 0.h), + ], + ); + }), + ), + ), + Container( + decoration: RoundedRectangleBorder().toSmoothCornerDecoration( + color: AppColors.whiteColor, + borderRadius: 24.r, + hasShadow: true, + ), + child: Padding( + padding: EdgeInsets.all(24.h), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LocaleKeys.totalAmountToPay.tr(context: context).toText22(isBold: true), + SizedBox(height: 8.h), + LocaleKeys.copyLinkTxt.tr(context: context).toText12(color: AppColors.greyTextColor), + SizedBox(height: 16.h), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Utils.getPaymentMethods(), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Utils.getPaymentAmountWithSymbol( + NumberFormat.decimalPattern() + .format(getIt.get().inPatientAdvanceResponseModel!.responseInpatientAdvanceInfo!.first.requestedAmount) + .toString() + .toText24(isBold: true), + AppColors.blackColor, + 17, + isSaudiCurrency: true), + ], + ), + ], + ), + SizedBox(height: 16.h), + Row( + children: [ + Expanded( + child: CustomButton( + text: LocaleKeys.payNow.tr(context: context), + onPressed: () async { + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPaymentInformation.tr(context: context)); + getIt.get().getInPatientPaymentLink( + projectID: getIt.get().isAdmitted + ? getIt.get().getAdmissionInfoResponseModel!.projectID! + : getIt.get().getAdmissionRequestInfoResponseModel!.projectId!, + clinicID: getIt.get().isAdmitted + ? getIt.get().getAdmissionInfoResponseModel!.clinicID! + : getIt.get().getAdmissionRequestInfoResponseModel!.clinicId!, + paymentRequestID: getIt.get().inPatientAdvanceResponseModel!.responseInpatientAdvanceInfo!.first.paymentRequestID!, + admissionNo: getIt.get().isAdmitted + ? getIt.get().getAdmissionInfoResponseModel!.admissionNo! + : getIt.get().getAdmissionRequestInfoResponseModel!.admissionRequestNo!, + orderID: int.parse(DateTime.now().microsecondsSinceEpoch.toString().substring(7, 15)), + name: "${getIt.get().getAuthenticatedUser()!.firstName!} ${getIt.get().getAuthenticatedUser()!.lastName!}", + email: getIt.get().getAuthenticatedUser()!.emailAddress!, + amount: (getIt.get().inPatientAdvanceResponseModel!.responseInpatientAdvanceInfo!.first.requestedAmount) ?? 0, + nationalID: getIt.get().getAuthenticatedUser()!.patientIdentificationNo!, + isCopy: false, + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + }, + onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: err), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }); + }, + backgroundColor: AppColors.infoColor, + borderColor: AppColors.infoColor, + textColor: AppColors.whiteColor, + fontSize: 16, + fontWeight: FontWeight.w600, + borderRadius: 12, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 50.h, + icon: AppAssets.appointment_pay_icon, + iconColor: AppColors.whiteColor, + iconSize: 18.h, + ), + ), + SizedBox(width: 16.h), + Expanded( + child: CustomButton( + text: LocaleKeys.copyLink.tr(context: context), + onPressed: () async { + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPaymentInformation.tr(context: context)); + getIt.get().getInPatientPaymentLink( + projectID: getIt.get().isAdmitted + ? getIt.get().getAdmissionInfoResponseModel!.projectID! + : getIt.get().getAdmissionRequestInfoResponseModel!.projectId!, + clinicID: getIt.get().isAdmitted + ? getIt.get().getAdmissionInfoResponseModel!.clinicID! + : getIt.get().getAdmissionRequestInfoResponseModel!.clinicId!, + paymentRequestID: getIt.get().inPatientAdvanceResponseModel!.responseInpatientAdvanceInfo!.first.paymentRequestID!, + admissionNo: getIt.get().isAdmitted + ? getIt.get().getAdmissionInfoResponseModel!.admissionNo! + : getIt.get().getAdmissionRequestInfoResponseModel!.admissionRequestNo!, + orderID: int.parse(DateTime.now().microsecondsSinceEpoch.toString().substring(7, 15)), + name: "${getIt.get().getAuthenticatedUser()!.firstName!} ${getIt.get().getAuthenticatedUser()!.lastName!}", + email: getIt.get().getAuthenticatedUser()!.emailAddress!, + amount: (getIt.get().inPatientAdvanceResponseModel!.responseInpatientAdvanceInfo!.first.requestedAmount) ?? 0, + nationalID: getIt.get().getAuthenticatedUser()!.patientIdentificationNo!, + isCopy: true, + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + }, + onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: err), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }); + }, + backgroundColor: AppColors.warningColorYellow.withValues(alpha: 0.20), + textColor: AppColors.alertColor, + borderColor: AppColors.warningColorYellow.withValues(alpha: 0.01), + fontSize: 16, + fontWeight: FontWeight.w600, + borderRadius: 12, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 50.h, + icon: AppAssets.appointment_pay_icon, + iconColor: AppColors.alertColor, + iconSize: 18.h, + ), + ), + ], + ), ], - onTabChange: (index) { - inpatientServicesVM.onTabChanged(index); - }, - ).paddingSymmetrical(24.h, 0.h), - SizedBox(height: 24.h), - getSelectedTabView(context).paddingSymmetrical(24.h, 0.h), - ], - ); - }), + ), + ), + ) + ], ), ); } Widget getSelectedTabView(BuildContext context) { return getIt.get().advancePaymentSelectedTabIndex == 0 - ? Container() + ? Container( + decoration: RoundedRectangleBorder().toSmoothCornerDecoration( + color: AppColors.whiteColor, + borderRadius: 20.r, + hasShadow: false, + ), + child: Padding( + padding: EdgeInsets.all(16.h), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "Payment Request For: ".toText16(isBold: true), + SizedBox(height: 16.h), + Wrap( + alignment: WrapAlignment.start, + direction: Axis.horizontal, + spacing: 6.w, + runSpacing: 6.h, + children: [ + AppCustomChipWidget( + labelText: "${LocaleKeys.patientName.tr()} ${getIt.get().getAuthenticatedUser()!.firstName!} ${getIt.get().getAuthenticatedUser()!.lastName!}", + ), + AppCustomChipWidget( + labelText: "${LocaleKeys.identificationNumber.tr()}: ${getIt.get().getAuthenticatedUser()!.patientIdentificationNo!}", + ), + AppCustomChipWidget( + labelText: "${LocaleKeys.fileNumber.tr()}: ${getIt.get().getAuthenticatedUser()!.patientId!}", + ), + ], + ), + ], + ), + ), + ) : getIt.get().isAdvancePaymentHistoryLoading ? Container( decoration: RoundedRectangleBorder().toSmoothCornerDecoration(