From d284ceac0426acf1935dd016fa3dd375eae53f1d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 24 Nov 2020 17:26:13 +0300 Subject: [PATCH] advance payment & payment flow issues fixed --- .../service/medical/my_balance_service.dart | 19 +++--- .../medical/my_balance_view_model.dart | 4 +- lib/pages/Blood/confirm_payment_page.dart | 3 + lib/pages/BookAppointment/BookSuccess.dart | 3 + lib/pages/ToDoList/ToDo.dart | 3 + lib/pages/livecare/widgets/clinic_list.dart | 3 + .../medical/balance/advance_payment_page.dart | 61 +++++++++++++------ .../medical/balance/confirm_payment_page.dart | 12 +++- .../appointment_services/GetDoctorsList.dart | 15 +++-- lib/widgets/in_app_browser/InAppBrowser.dart | 32 ++++++---- 10 files changed, 103 insertions(+), 52 deletions(-) diff --git a/lib/core/service/medical/my_balance_service.dart b/lib/core/service/medical/my_balance_service.dart index c456b38c..e3be9bcf 100644 --- a/lib/core/service/medical/my_balance_service.dart +++ b/lib/core/service/medical/my_balance_service.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/my_balance/AdvanceModel.dart'; @@ -24,7 +22,8 @@ class MyBalanceService extends BaseService { String logInTokenID; String verificationCode; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); getPatientAdvanceBalanceAmount() async { hasError = false; @@ -61,13 +60,14 @@ class MyBalanceService extends BaseService { }, body: body); } - getPatientInfoByPatientIDAndMobileNumber() async { + getPatientInfoByPatientIDAndMobileNumber(AdvanceModel advanceModel) async { hasError = false; super.error = ""; Map body = Map(); body['isDentalAllowedBackend'] = false; - body['MobileNo'] = authenticatedUserObject.user.mobileNumber; - body['ProjectID'] = authenticatedUserObject.user.projectID; + body['MobileNo'] = advanceModel.mobileNumber; + body['ProjectID'] = advanceModel.hospitalsModel.iD; + body['PatientID'] = advanceModel.fileNumber; await baseAppClient.post(GET_PATIENT_INFO_BY_ID_AND_MOBILE_NUMBER, onSuccess: (response, statusCode) async { @@ -81,7 +81,7 @@ class MyBalanceService extends BaseService { }, body: body); } - sendActivationCodeForAdvancePayment({int patientID,int projectID}) async { + sendActivationCodeForAdvancePayment({int patientID, int projectID}) async { hasError = false; super.error = ""; Map body = Map(); @@ -111,9 +111,8 @@ class MyBalanceService extends BaseService { body['LogInTokenID'] = logInTokenID; await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT, - onSuccess: (response, statusCode) async { - - }, onFailure: (String error, int statusCode) { + onSuccess: (response, statusCode) async {}, + onFailure: (String error, int statusCode) { hasError = true; super.error = error; super.error = error; diff --git a/lib/core/viewModels/medical/my_balance_view_model.dart b/lib/core/viewModels/medical/my_balance_view_model.dart index 8225d97e..62b7868b 100644 --- a/lib/core/viewModels/medical/my_balance_view_model.dart +++ b/lib/core/viewModels/medical/my_balance_view_model.dart @@ -112,10 +112,10 @@ class MyBalanceViewModel extends BaseViewModel { } } - Future getPatientInfoByPatientIDAndMobileNumber() async { + Future getPatientInfoByPatientIDAndMobileNumber(AdvanceModel advanceModel) async { setState(ViewState.Busy); await _myBalanceService - .getPatientInfoByPatientIDAndMobileNumber(); + .getPatientInfoByPatientIDAndMobileNumber(advanceModel); if (_myBalanceService.hasError) { error = _myBalanceService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/Blood/confirm_payment_page.dart b/lib/pages/Blood/confirm_payment_page.dart index 3d9fccb2..9ad6d68f 100644 --- a/lib/pages/Blood/confirm_payment_page.dart +++ b/lib/pages/Blood/confirm_payment_page.dart @@ -213,6 +213,9 @@ class ConfirmPaymentPage extends StatelessWidget { appo.projectID.toString(), authenticatedUser.emailAddress, paymentMethod, + authenticatedUser.patientType, + authenticatedUser.firstName, + authenticatedUser.patientID, authenticatedUser, browser); } diff --git a/lib/pages/BookAppointment/BookSuccess.dart b/lib/pages/BookAppointment/BookSuccess.dart index 39e290a1..82248560 100644 --- a/lib/pages/BookAppointment/BookSuccess.dart +++ b/lib/pages/BookAppointment/BookSuccess.dart @@ -573,6 +573,9 @@ class _BookSuccessState extends State { appo.projectID.toString(), authenticatedUser.emailAddress, paymentMethod, + authenticatedUser.patientType, + authenticatedUser.firstName, + authenticatedUser.patientID, authenticatedUser, widget.browser); } diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index b0315d28..96835d7b 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -606,6 +606,9 @@ class _ToDoState extends State { appo.projectID.toString(), authenticatedUser.emailAddress, paymentMethod, + authenticatedUser.patientType, + authenticatedUser.firstName, + authenticatedUser.patientID, authenticatedUser, widget.browser); } diff --git a/lib/pages/livecare/widgets/clinic_list.dart b/lib/pages/livecare/widgets/clinic_list.dart index d2e52b72..8ce3b7b0 100644 --- a/lib/pages/livecare/widgets/clinic_list.dart +++ b/lib/pages/livecare/widgets/clinic_list.dart @@ -285,6 +285,9 @@ class _clinic_listState extends State { "12", authenticatedUser.emailAddress, paymentMethod, + authenticatedUser.patientType, + authenticatedUser.firstName, + authenticatedUser.patientID, authenticatedUser, browser); } diff --git a/lib/pages/medical/balance/advance_payment_page.dart b/lib/pages/medical/balance/advance_payment_page.dart index f19b03ed..9b255711 100644 --- a/lib/pages/medical/balance/advance_payment_page.dart +++ b/lib/pages/medical/balance/advance_payment_page.dart @@ -29,7 +29,6 @@ import 'new_text_Field.dart'; enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON } - class AdvancePaymentPage extends StatefulWidget { @override _AdvancePaymentPageState createState() => _AdvancePaymentPageState(); @@ -238,13 +237,35 @@ class _AdvancePaymentPageState extends State { _fileTextController.text.isEmpty || _selectedHospital == null, onTap: () { + var mobileNum; + var patientName; + + if (beneficiaryType == BeneficiaryType.MyFamilyFiles) { + mobileNum = selectedPatientFamily.mobileNumber; + patientName = selectedPatientFamily.patientName; + } + + if (beneficiaryType == BeneficiaryType.MyAccount) { + mobileNum = model.user.mobileNumber; + patientName = model.user.firstName; + } + + if (beneficiaryType == BeneficiaryType.OtherAccount) { + mobileNum = _selectedPatientInfo.mobileNumber; + patientName = _selectedPatientInfo.fullName; + } + advanceModel.fileNumber = _fileTextController.text; advanceModel.hospitalsModel = _selectedHospital; advanceModel.note = _notesTextController.text; advanceModel.email = email ?? model.user.emailAddress; advanceModel.amount = amount; + advanceModel.mobileNumber = mobileNum; + advanceModel.patientName = patientName; - model.getPatientInfoByPatientIDAndMobileNumber().then((value) { + model + .getPatientInfoByPatientIDAndMobileNumber(advanceModel) + .then((value) { if (model.state != ViewState.Error && model.state != ViewState.ErrorLocal) { Utils.hideKeyboard(context); @@ -269,8 +290,8 @@ class _AdvancePaymentPageState extends State { ); } }).showProgressBar( - text: "Loading", - backgroundColor: Colors.blue.withOpacity(0.6)); + text: "Loading", + backgroundColor: Colors.blue.withOpacity(0.6)); }, ), )), @@ -331,22 +352,22 @@ class _AdvancePaymentPageState extends State { void confirmSelectFamilyDialog( List getAllSharedRecordsByStatusList) { - if(getAllSharedRecordsByStatusList.isNotEmpty) - showDialog( - context: context, - child: SelectPatientFamilyDialog( - getAllSharedRecordsByStatusList: getAllSharedRecordsByStatusList, - selectedPatientFamily: selectedPatientFamily, - onValueSelected: (value) { - setState(() { - selectedPatientFamily = value; - _fileTextController.text = - selectedPatientFamily.patientID.toString(); - advanceModel.depositorName = value.patientName; - }); - }, - ), - ); + if (getAllSharedRecordsByStatusList.isNotEmpty) + showDialog( + context: context, + child: SelectPatientFamilyDialog( + getAllSharedRecordsByStatusList: getAllSharedRecordsByStatusList, + selectedPatientFamily: selectedPatientFamily, + onValueSelected: (value) { + setState(() { + selectedPatientFamily = value; + _fileTextController.text = + selectedPatientFamily.responseID.toString(); + advanceModel.depositorName = value.patientName; + }); + }, + ), + ); } String getBeneficiaryType() { diff --git a/lib/pages/medical/balance/confirm_payment_page.dart b/lib/pages/medical/balance/confirm_payment_page.dart index dbc2537f..4954653d 100644 --- a/lib/pages/medical/balance/confirm_payment_page.dart +++ b/lib/pages/medical/balance/confirm_payment_page.dart @@ -137,7 +137,11 @@ class ConfirmPaymentPage extends StatelessWidget { ), NewTextFields( hintText: TranslationBase.of(context).depositorName, - initialValue: advanceModel.depositorName, + initialValue: model.user.firstName + + " " + + model.user.middleName + + " " + + model.user.lastName, isEnabled: false, ), SizedBox( @@ -217,6 +221,9 @@ class ConfirmPaymentPage extends StatelessWidget { advanceModel.hospitalsModel.iD.toString(), advanceModel.email, paymentMethod, + patientInfoAndMobileNumber.patientType, + advanceModel.patientName, + advanceModel.fileNumber, authenticatedUser, browser); } @@ -276,6 +283,9 @@ class ConfirmPaymentPage extends StatelessWidget { res['Amount'], res['Fort_id'], res['PaymentMethod'], + patientInfoAndMobileNumber.patientType, + advanceModel.patientName, + advanceModel.fileNumber, AppGlobal.context) .then((res) { print(res['OnlineCheckInAppointments'][0]['AdvanceNumber']); diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index eb1ab98f..579c0e10 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -1168,6 +1168,9 @@ class DoctorsListService extends BaseService { double payedAmount, String paymentReference, String paymentMethodName, + dynamic patientType, + String patientName, + dynamic patientID, BuildContext context) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { @@ -1179,12 +1182,12 @@ class DoctorsListService extends BaseService { Request req = appGlobal.getPublicRequest(); request = { - "CustName": authUser.firstName + " " + authUser.lastName, - "CustID": authUser.patientID, + "CustName": patientName, + "CustID": patientID, "SetupID": "010266", "ProjectID": projectID, - "PatientID": authUser.patientID, - "AccountID": authUser.patientID, + "PatientID": patientID, + "AccountID": patientID, "PaymentAmount": payedAmount, "NationalityID": null, "DepositorName": authUser.firstName + " " + authUser.lastName, @@ -1201,8 +1204,8 @@ class DoctorsListService extends BaseService { "SessionID": "YckwoXhUmWBsnHKEKig", "isDentalAllowedBackend": false, "TokenID": "@dm!n", - "PatientTypeID": authUser.patientType, - "PatientType": authUser.patientType + "PatientTypeID": patientType, + "PatientType": patientType }; dynamic localRes; await baseAppClient.post(HIS_CREATE_ADVANCE_PAYMENT, diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index 203eef12..e465db39 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -107,13 +107,16 @@ class MyInAppBrowser extends InAppBrowser { String projId, String emailId, String paymentMethod, + dynamic patientType, + String patientName, + dynamic patientID, AuthenticatedUser authenticatedUser, InAppBrowser browser) { getDeviceToken(); this.browser = browser; this.browser.openUrl( url: generateURL(amount, orderDesc, transactionID, projId, emailId, - paymentMethod, authenticatedUser)); + paymentMethod, patientType, patientName, patientID, authenticatedUser)); } openBrowser(String url) { @@ -128,6 +131,9 @@ class MyInAppBrowser extends InAppBrowser { String projId, String emailId, String paymentMethod, + dynamic patientType, + String patientName, + dynamic patientID, AuthenticatedUser authUser, [var patientData, var servID, @@ -136,11 +142,11 @@ class MyInAppBrowser extends InAppBrowser { String currentLanguageID = getLanguageID() == 'ar' ? 'AR' : 'EN'; String form = getForm(); - if (authUser != null) { - form = form.replaceFirst("EMAIL_VALUE", authUser.emailAddress); - } else { + // if (authUser != null) { + // form = form.replaceFirst("EMAIL_VALUE", authUser.emailAddress); + // } else { form = form.replaceFirst("EMAIL_VALUE", emailId); - } + // } form = form.replaceFirst('AMOUNT_VALUE', amount.toString()); form = form.replaceFirst('ORDER_DESCRIPTION_VALUE', orderDesc); @@ -152,7 +158,7 @@ class MyInAppBrowser extends InAppBrowser { form = form.replaceFirst('PATIENT_OUT_SA', authUser.outSA == 0 ? false.toString() : true.toString()); form = form.replaceFirst('PATIENT_TYPE_ID', - patientData == null ? authUser.patientType.toString() : "1"); + patientData == null ? patientType.toString() : "1"); // form = form.replaceFirst('DEVICE_TOKEN', this.cs.sharedService.getSharedData(AuthenticationService.DEVICE_TOKEN, false) + "," + this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false)); // form = form.replaceFirst('LATITUDE_VALUE', this.cs.sharedService.getSharedData('userLat', false)); @@ -172,13 +178,13 @@ class MyInAppBrowser extends InAppBrowser { form = form.replaceFirst('LIVE_SERVICE_ID', "2"); } - if (patientData == null) { - form = form.replaceFirst('CUSTNAME_VALUE', authUser.firstName); - form = form.replaceFirst('CUSTID_VALUE', authUser.patientID.toString()); - } else { - form = form.replaceFirst('CUSTNAME_VALUE', patientData.depositorName); - form = form.replaceFirst('CUSTID_VALUE', patientData.fileNumber); - } + // if (patientData == null) { + form = form.replaceFirst('CUSTNAME_VALUE', patientName); + form = form.replaceFirst('CUSTID_VALUE', patientID.toString()); + // } else { + // form = form.replaceFirst('CUSTNAME_VALUE', patientData.depositorName); + // form = form.replaceFirst('CUSTID_VALUE', patientData.fileNumber); + // } form = form.replaceFirst('LATITUDE_VALUE', "24.708488"); form = form.replaceFirst('LONGITUDE_VALUE', "46.665925");