diff --git a/lib/config/config.dart b/lib/config/config.dart index 43693ed5..4a782e22 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -639,6 +639,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_ADVANCE_BALANCE = 'Services/OUTPs.svc/Rest/getPatientAdvanceBalanceAmountByClinic'; + var GET_PROJECT_FROM_NFC = 'Services/OUTPs.svc/Rest/GetProjectByNFC'; //PAYFORT diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index fbc54c13..91747535 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1935,4 +1935,5 @@ const Map localizedValues = { "selectHospitalBloodDonation": {"en": "Please select the hospital you want to book an appointment with: ", "ar": "يرجى اختيار المستشفى الذي تريد حجز موعد معه:"}, "wecare": {"en": "We Care", "ar": "نحن نهتم"}, "myinstructions": {"en": "My Instructions", "ar": "تعليماتي"}, + "ERCheckInSuccess": {"en": "Your ER Online Check-In has been successfully done.", "ar": "لقد تم تسجيل وصولك للطوارئ عبر الإنترنت بنجاح."}, }; diff --git a/lib/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart b/lib/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart index 36de5cb4..faf4a498 100644 --- a/lib/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart +++ b/lib/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart @@ -1,18 +1,18 @@ class EROnlineCheckInPaymentDetailsResponse { - int cashPrice; - int cashPriceTax; - int cashPriceWithTax; + num cashPrice; + num cashPriceTax; + num cashPriceWithTax; int companyId; String companyName; - int companyShareWithTax; + num companyShareWithTax; Null errCode; int groupID; String insurancePolicyNo; String message; String patientCardID; - double patientShare; - double patientShareWithTax; - double patientTaxAmount; + num patientShare; + num patientShareWithTax; + num patientTaxAmount; int policyId; String policyName; String procedureId; diff --git a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart index 8126d3a4..559ec4f4 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(); + checkPatientERAdvanceBalance(); }); 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) { @@ -349,16 +353,20 @@ class _EROnlineCheckInHomePageState extends State with 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 { + Navigator.push( + context, + FadePage( + page: EROnlineCheckInPaymentDetails( + projectID: projectID, + isERBookAppointment: false, + projectName: projectName, + ), ), - ), - ); + ); + } } else { AppToast.showErrorToast(message: "Invalid NFC Card Scanned."); } @@ -368,6 +376,47 @@ class _EROnlineCheckInHomePageState extends State with }); } + autoGenerateInvoiceER(int projectID) { + GifLoaderDialogUtils.showMyDialog(context); + DoctorsListService service = new DoctorsListService(); + service.autoGenerateInvoiceERClinic(projectID, 4, null, null, null, null, null, null, true).then((res) { + GifLoaderDialogUtils.hideDialog(context); + _showMyDialog(TranslationBase.of(context).ERCheckInSuccess, 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 checkIfPatientHasArrived() { GifLoaderDialogUtils.showMyDialog(context); ClinicListService ancillaryOrdersService = new ClinicListService(); @@ -382,4 +431,19 @@ class _EROnlineCheckInHomePageState extends State with GifLoaderDialogUtils.hideDialog(context); }); } + + void checkPatientERAdvanceBalance() { + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService ancillaryOrdersService = new ClinicListService(); + ancillaryOrdersService.checkPatientERAdvanceBalance(10).then((response) { + print(response["BalanceAmount"]); + isPatientArrived = response['BalanceAmount'] > 0; + GifLoaderDialogUtils.hideDialog(context); + 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 d7d6cd6d..de2f7ccc 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,12 @@ 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/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index 3e2ea23e..b1362cb3 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -1427,12 +1427,12 @@ class DoctorsListService extends BaseService { Request req = appGlobal.getPublicRequest(); request = { - "VersionID": req.VersionID, - "Channel": req.Channel, - "IPAdress": req.IPAdress, - "generalid": req.generalid, - "PatientOutSA": authUser.outSA, - "PatientTypeID": authUser.patientType, + // "VersionID": req.VersionID, + // "Channel": req.Channel, + // "IPAdress": req.IPAdress, + // "generalid": req.generalid, + // "PatientOutSA": authUser.outSA, + // "PatientTypeID": authUser.patientType, "LanguageID": 1, "ERAdvanceAmount": { "ProjectId": projectID, @@ -1769,7 +1769,8 @@ class DoctorsListService extends BaseService { request = { "ProjectID": projectID, "ClinicID": "10", - "PaymentMethod": paymentMethod, + // "PaymentMethod": paymentMethod, + "PaymentMethod": "VISA", "PaymentReferenceNo": paymentReferenceNo, "PaymentAmount": amount, "CardType": cardType, diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index fd0ae450..15fa2c66 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -198,6 +198,17 @@ class ClinicListService extends BaseService { return Future.value(localRes); } + Future checkPatientERAdvanceBalance(int clinicID) async { + Map request = {"ClinicID": clinicID}; + dynamic localRes; + await baseAppClient.post(CHECK_PATIENT_ER_ADVANCE_BALANCE, 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/services/payfort_services/payfort_service.dart b/lib/services/payfort_services/payfort_service.dart index 655ce673..50765443 100644 --- a/lib/services/payfort_services/payfort_service.dart +++ b/lib/services/payfort_services/payfort_service.dart @@ -143,7 +143,7 @@ class PayfortService extends BaseService { String customerName, String customerEmail, String orderDescription, - double orderAmount, + num orderAmount, String merchantIdentifier, String applePayAccessCode, String applePayShaRequestPhrase, diff --git a/lib/services/payfort_services/payfort_view_model.dart b/lib/services/payfort_services/payfort_view_model.dart index 553169ba..2b88f83a 100644 --- a/lib/services/payfort_services/payfort_view_model.dart +++ b/lib/services/payfort_services/payfort_view_model.dart @@ -45,7 +45,7 @@ class PayfortViewModel extends ChangeNotifier { String customerEmail, String orderDescription, String merchantReference, - double orderAmount, + num orderAmount, PayfortProjectDetailsRespModel payfortProjectDetailsRespModel, SucceededCallback onSuccess, FailedCallback onFailed, diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 48d1ce7b..0fce8fb3 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2920,6 +2920,7 @@ class TranslationBase { String get selectHospitalBloodDonation => localizedValues["selectHospitalBloodDonation"][locale.languageCode]; String get wecare => localizedValues["wecare"][locale.languageCode]; String get myinstructions => localizedValues["myinstructions"][locale.languageCode]; + String get ERCheckInSuccess => localizedValues["ERCheckInSuccess"][locale.languageCode]; }