From 84159656b620bfde7b785da1530de187386a3188 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 14 Jul 2024 17:11:21 +0300 Subject: [PATCH] updates for ER Online-Checkin --- lib/config/config.dart | 8 +- .../EROnlineCheckIn/EROnlineCheckInHome.dart | 89 ++++++++++++++++--- .../EROnlineCheckInPaymentDetails.dart | 55 +++++++++++- .../fragments/home_page_fragment2.dart | 2 +- .../appointment_services/GetDoctorsList.dart | 34 ++++++- .../clinic_services/get_clinic_service.dart | 11 +++ lib/widgets/in_app_browser/InAppBrowser.dart | 6 +- 7 files changed, 180 insertions(+), 25 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 6789925d..759e5204 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -20,10 +20,10 @@ var PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; -// var BASE_URL = 'http://10.50.100.198:2018/'; +// var BASE_URL = 'http://10.50.100.198:1022/'; // var BASE_URL = 'http://10.50.100.198:4422/'; -// var BASE_URL = 'https://uat.hmgwebservices.com/'; -var BASE_URL = 'https://hmgwebservices.com/'; +var BASE_URL = 'https://uat.hmgwebservices.com/'; +// var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'http://10.20.200.111:1010/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; @@ -671,6 +671,8 @@ var AUTO_GENERATE_INVOICE_ER = 'Services/OUTPs.svc/Rest/Outp_AutoGenerateInvoice var CHECK_IF_PATIENT_ARRIVED_ER_ONLINE_CHECKIN = 'Services/OUTPs.svc/Rest/IsPatientArrived'; +var CHECK_PATIENT_ER_CLINIC_BALANCE_AMOUNT = 'Services/OUTPs.svc/Rest/getPatientAdvanceBalanceAmountByClinic'; + var GET_PROJECT_FROM_NFC = 'Services/OUTPs.svc/Rest/GetProjectByNFC'; //PAYFORT diff --git a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart index bd09f05a..17d72248 100644 --- a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart +++ b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart @@ -1,6 +1,8 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/ErService/EROnlineCheckIn/EROnlineCheckInBookAppointment.dart'; import 'package:diplomaticquarterapp/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.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/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -31,7 +33,8 @@ class _EROnlineCheckInHomePageState extends State with @override void initState() { WidgetsBinding.instance.addPostFrameCallback((_) { - checkIfPatientHasArrived(); + // checkIfPatientHasArrived(); + checkPatientERClinicBalanceAmount(); }); super.initState(); } @@ -283,6 +286,7 @@ class _EROnlineCheckInHomePageState extends State with showNfcReader(context, onNcfScan: (String nfcId) { Future.delayed(const Duration(milliseconds: 100), () { print(nfcId); + getProjectIDFromNFC(nfcId, true); // Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails())); }); }, onCancel: () { @@ -309,7 +313,7 @@ class _EROnlineCheckInHomePageState extends State with showNfcReader(context, onNcfScan: (String nfcId) { Future.delayed(const Duration(milliseconds: 100), () { print(nfcId); - getProjectIDFromNFC(nfcId); + getProjectIDFromNFC(nfcId, false); }); }, onCancel: () { Navigator.of(context).pop(); @@ -340,7 +344,7 @@ class _EROnlineCheckInHomePageState extends State with ); } - void getProjectIDFromNFC(String nfcID) { + void getProjectIDFromNFC(String nfcID, bool isArrived) { GifLoaderDialogUtils.showMyDialog(context); ClinicListService ancillaryOrdersService = new ClinicListService(); ancillaryOrdersService.getProjectIDFromNFC(nfcID).then((response) { @@ -348,17 +352,21 @@ class _EROnlineCheckInHomePageState extends State with print(response["GetProjectByNFC"]); int projectID = response['GetProjectByNFC'][0]["ProjectID"]; String projectName = response['GetProjectByNFC'][0]["ProjectName"]; - GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage( - page: EROnlineCheckInPaymentDetails( - projectID: projectID, - isERBookAppointment: false, - projectName: projectName, + if (isArrived) { + autoGenerateInvoiceER(projectID); + } else { + GifLoaderDialogUtils.hideDialog(context); + Navigator.push( + context, + FadePage( + page: EROnlineCheckInPaymentDetails( + projectID: projectID, + isERBookAppointment: false, + projectName: projectName, + ), ), - ), - ); + ); + } } else { AppToast.showErrorToast(message: "Invalid NFC Card Scanned."); } @@ -382,4 +390,59 @@ class _EROnlineCheckInHomePageState extends State with GifLoaderDialogUtils.hideDialog(context); }); } + + autoGenerateInvoiceER(int projectID) { + DoctorsListService service = new DoctorsListService(); + service.autoGenerateInvoiceERClinicWithNoPaymentDetails(projectID, true).then((res) { + GifLoaderDialogUtils.hideDialog(context); + _showMyDialog("Your online Check-In in the ER clinic has been done successfully.", context); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: err); + print(err); + }); + } + + Future _showMyDialog(String message, BuildContext context) async { + return showDialog( + context: context, + barrierDismissible: true, // user must tap button! + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Alert'), + content: SingleChildScrollView( + child: ListBody( + children: [ + Text(message), + ], + ), + ), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + }, + ), + ], + ); + }, + ); + } + + void checkPatientERClinicBalanceAmount() { + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService ancillaryOrdersService = new ClinicListService(); + ancillaryOrdersService.checkPatientERClinicBalanceAmount(10).then((response) { + print(response["BalanceAmount"]); + isPatientArrived = response['BalanceAmount'] > 0; + GifLoaderDialogUtils.hideDialog(context); + // erOnlineCheckInPaymentDetailsResponse = EROnlineCheckInPaymentDetailsResponse.fromJson(response["ResponsePatientShare"]); + setState(() {}); + }).catchError((err) { + AppToast.showErrorToast(message: err.toString()); + GifLoaderDialogUtils.hideDialog(context); + }); + } } diff --git a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart index c2028430..f9e6016b 100644 --- a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart +++ b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da import 'package:diplomaticquarterapp/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart'; import 'package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.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'; @@ -452,7 +453,8 @@ class _EROnlineCheckInPaymentDetailsState extends State _showMyDialog(String message, BuildContext context) async { + return showDialog( + context: context, + barrierDismissible: true, // user must tap button! + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Alert'), + content: SingleChildScrollView( + child: ListBody( + children: [ + Text(message), + ], + ), + ), + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + Navigator.of(context).pop(); + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + }, + ), + ], + ); + }, + ); + } + getEROnlineCheckInPaymentDetails() { GifLoaderDialogUtils.showMyDialog(context); ClinicListService ancillaryOrdersService = new ClinicListService(); diff --git a/lib/pages/landing/fragments/home_page_fragment2.dart b/lib/pages/landing/fragments/home_page_fragment2.dart index c1c922ac..7441f591 100644 --- a/lib/pages/landing/fragments/home_page_fragment2.dart +++ b/lib/pages/landing/fragments/home_page_fragment2.dart @@ -52,7 +52,7 @@ class _HomePageFragment2State extends State { hmgServices.add(HmgServices(0, TranslationBase.of(context).book, TranslationBase.of(context).appointmentLabel, "assets/images/new/book appointment.svg", isLogin)); hmgServices.add(HmgServices(1, TranslationBase.of(context).liveCare, TranslationBase.of(context).onlineConsulting, "assets/images/new/Live_Care.svg", isLogin)); - hmgServices.add(HmgServices(2, TranslationBase.of(context).emergencyTitle, TranslationBase.of(context).emergencySubtitle, "assets/images/new/emergency.svg", isLogin)); + hmgServices.add(HmgServices(2, TranslationBase.of(context).emergencyTitle, TranslationBase.of(context).onlineCheckIn, "assets/images/new/emergency.svg", isLogin)); hmgServices.add(HmgServices(3, TranslationBase.of(context).hhcHome, TranslationBase.of(context).healthCare, "assets/images/new/HHC.svg", isLogin)); hmgServices.add(HmgServices(4, TranslationBase.of(context).checkup, TranslationBase.of(context).comprehensive, "assets/images/new/comprehensive_checkup.svg", isLogin)); hmgServices.add(HmgServices(5, TranslationBase.of(context).online, TranslationBase.of(context).payment, "assets/images/new/paymentMethods.png", isLogin)); diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index c46fa30b..b06bb48e 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 = []; @@ -1765,7 +1765,33 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } - Future autoGenerateInvoiceERClinic(int projectID, int paymentMethod, String paymentReferenceNo, num amount, String cardType, String cardNumber, String orderID, String rrn, bool isAdvanceAvailable) async { + Future autoGenerateInvoiceERClinicWithNoPaymentDetails(int projectID, bool isAdvanceAvailable) async { + Map request; + request = { + "ProjectID": projectID, + "ClinicID": "10", + // "PaymentMethod": cardType, + // "PaymentReferenceNo": paymentReferenceNo, + // "PaymentAmount": amount, + // "CardType": cardType, + // "CardNumber": cardNumber, + // "OrderId": orderID, + "MemberID": 102, + // "RRN": rrn, + "IsAdvanceAvailable": isAdvanceAvailable + }; + dynamic localRes; + await baseAppClient.post(AUTO_GENERATE_INVOICE_ER, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + + return Future.value(localRes); + } + + Future autoGenerateInvoiceERClinic( + int projectID, int paymentMethod, String paymentReferenceNo, num amount, String cardType, String cardNumber, String orderID, String rrn, bool isAdvanceAvailable) async { Map request; request = { "ProjectID": projectID, diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 920615ee..d8aa4ca9 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -461,6 +461,17 @@ class ClinicListService extends BaseService { return Future.value(localRes); } + Future checkPatientERClinicBalanceAmount(int clinicID) async { + Map request = {"ClinicID": clinicID}; + dynamic localRes; + await baseAppClient.post(CHECK_PATIENT_ER_CLINIC_BALANCE_AMOUNT, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request, isAllowAny: true); + return Future.value(localRes); + } + Future getProjectIDFromNFC(String nfcID) async { Map request = {"nFC_Code": nfcID}; dynamic localRes; diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index f353eec2..a04b5f03 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -38,9 +38,9 @@ class MyInAppBrowser extends InAppBrowser { static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE // static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT - // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT - static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE + // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE // static String SERVICE_URL = 'https://uat.hmgwebservices.com/payfortforvidaplus/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL UAT VIDA PLUS @@ -343,7 +343,7 @@ class MyInAppBrowser extends InAppBrowser { form = form.replaceFirst('PROJECT_ID_VALUE', projId); form = form.replaceFirst('PAYMENT_OPTION_VALUE', paymentMethod); form = form.replaceFirst('LANG_VALUE', currentLanguageID); - form = form.replaceFirst('SERVICE_URL_VALUE', "https://mdlaboratories.com/tamaralive/Home/Checkout"); + form = form.replaceFirst('SERVICE_URL_VALUE', "https://mdlaboratories.com/tamara/Home/Checkout"); form = form.replaceFirst('INSTALLMENTS_VALUE', installments); form = form.replaceFirst('CUSTNATIONALID_VALUE', authUser.patientIdentificationNo!);