diff --git a/lib/config/config.dart b/lib/config/config.dart index f40deae0..aca97ede 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -21,8 +21,8 @@ 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 = '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.201.204.103/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; @@ -706,6 +706,8 @@ var GET_OFFER_DETAILS = 'Services/Authentication.svc/REST/GetNDOfferData'; var GET_PRESCRIPTION_INSTRUCTIONS_PDF = 'Services/ChatBot_Service.svc/REST/Chatbot_SendMedicationInstructionByWhatsApp'; +var SEND_PATIENT_IMMEDIATE_UPDATE_INSURANCE_REQUEST = 'Services/OUTPs.svc/REST/PatientCompanyUpdate'; + //PAYFORT var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails"; var addPayFortApplePayResponse = "Services/PayFort_Serv.svc/REST/AddResponse"; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 2c77ec83..4f2731a8 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -189,8 +189,8 @@ class BaseAppClient { // body['IdentificationNo'] = 1023854217; // body['MobileNo'] = "531940021"; //0560717232 - body['PatientID'] = 4768663; //4609100 - body['TokenID'] = "@dm!n"; + // body['PatientID'] = 4768663; //4609100 + // body['TokenID'] = "@dm!n"; // Patient ID: 3027574 // Mobile no.: 0502303285 diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index d72509f8..d30cfbaa 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -303,7 +303,7 @@ class _BookConfirmState extends State { confirmMessage: errorMsg, okText: TranslationBase.of(context).updateInsuranceText, cancelText: TranslationBase.of(context).continueCash, - okFunction: () => {openUpdateInsurance()}, + okFunction: () => {openUpdateInsuranceForWalkIn()}, cancelFunction: () => {continueAsCashForWalkIn(widget.doctor.projectID!)}); dialog.showAlertDialog(context); } @@ -717,7 +717,7 @@ class _BookConfirmState extends State { confirmMessage: res['ErrorEndUserMessage'], okText: "Update insurance", cancelText: "Continue as cash", - okFunction: () => {openUpdateInsurance()}, + okFunction: () => {openUpdateInsurance(docObject, appointmentNo, false)}, cancelFunction: () => {continueAsCash(docObject, appointmentNo, false)}); dialog.showAlertDialog(context); } @@ -727,9 +727,28 @@ class _BookConfirmState extends State { }); } - void openUpdateInsurance() { - Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); - Navigator.push(context, FadePage(page: InsuranceUpdate())); + void openUpdateInsurance(DoctorList docObject, String appointmentNo, bool isLiveCareAppointment) { + DoctorsListService service = new DoctorsListService(); + GifLoaderDialogUtils.showMyDialog(context); + service.sendPatientUpdateRequest().then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res["MessageStatus"] == 1) { + if (isLiveCareAppointment) { + getLiveCareAppointmentPatientShare(context, appointmentNo, docObject!.clinicID!, docObject.projectID!, docObject); + } else { + getPatientShare(context, appointmentNo, docObject.clinicID!, docObject.projectID!, docObject); + } + getToDoCount(); + } else { + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + }); } void continueAsCash(DoctorList docObject, String appointmentNo, bool isLiveCareAppointment) { @@ -753,6 +772,29 @@ class _BookConfirmState extends State { }); } + void openUpdateInsuranceForWalkIn() { + DoctorsListService service = new DoctorsListService(); + GifLoaderDialogUtils.showMyDialog(context); + service.sendPatientUpdateRequest().then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res["MessageStatus"] == 1) { + if (res["MessageStatus"] == 1) { + getWalkinAppointmentPatientShare(); + } else { + AppToast.showErrorToast(message: res["ErrorEndUserMessage"]); + } + } else { + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + }); + } + void continueAsCashForWalkIn(int projectID) { GifLoaderDialogUtils.showMyDialog(context); widget.service.convertPatientToCash(projectID).then((res) { @@ -893,6 +935,7 @@ class _BookConfirmState extends State { insertAppointment(context, widget.doctor, widget.initialSlotDuration); } }).onError((error, stackTrace) { + GifLoaderDialogUtils.hideDialog(context); insertAppointment(context, widget.doctor, widget.initialSlotDuration); }); } @@ -913,6 +956,7 @@ class _BookConfirmState extends State { Future.delayed(Duration(milliseconds: 500), () { // checkPatientNphiesEligibility(docObject, res['AppointmentNo'], context); + GifLoaderDialogUtils.hideDialog(context); getToDoCount(); getPatientShare(context, res['AppointmentNo'], docObject.clinicID!, docObject.projectID!, docObject); }); @@ -1025,6 +1069,7 @@ class _BookConfirmState extends State { String errorMsg = ""; GifLoaderDialogUtils.showMyDialog(context, barrierDismissible: false); widget.service.getPatientShare(appointmentNo, clinicID, projectID, languageID, context).then((res) { + GifLoaderDialogUtils.hideDialog(context); projectViewModel.selectedBodyPartList.clear(); projectViewModel.laserSelectionDuration = 0; if (res['OnlineCheckInAppointments'].length != 0) { @@ -1052,8 +1097,8 @@ class _BookConfirmState extends State { confirmMessage: errorMsg, okText: TranslationBase.of(context).updateInsuranceText, cancelText: TranslationBase.of(context).continueCash, - okFunction: () => {openUpdateInsurance()}, - cancelFunction: () => {continueAsCash(docObject, appointmentNo, false)}); + okFunction: () => {Navigator.pop(context), openUpdateInsurance(docObject, appointmentNo, widget.patientShareResponse.isLiveCareAppointment!)}, + cancelFunction: () => {Navigator.pop(context), continueAsCash(docObject, appointmentNo, widget.patientShareResponse.isLiveCareAppointment!)}); dialog.showAlertDialog(context); } } @@ -1095,7 +1140,7 @@ class _BookConfirmState extends State { confirmMessage: errorMsg, okText: TranslationBase.of(context).updateInsuranceText, cancelText: TranslationBase.of(context).continueCash, - okFunction: () => {openUpdateInsurance()}, + okFunction: () => {openUpdateInsurance(docObject, appointmentNo, true)}, cancelFunction: () => {continueAsCash(docObject, appointmentNo, true)}); dialog.showAlertDialog(context); } diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index 753ed6c9..988c2833 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -6,6 +6,7 @@ import 'package:hmg_patient_app/config/shared_pref_kay.dart'; import 'package:hmg_patient_app/core/enum/PayfortEnums.dart'; import 'package:hmg_patient_app/core/model/ImagesInfo.dart'; import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; +import 'package:hmg_patient_app/locator.dart'; import 'package:hmg_patient_app/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:hmg_patient_app/models/Appointments/DoctorListResponse.dart'; import 'package:hmg_patient_app/models/Appointments/OBGyneProcedureListResponse.dart'; @@ -34,6 +35,7 @@ import 'package:hmg_patient_app/uitl/app_shared_preferences.dart'; import 'package:hmg_patient_app/uitl/app_toast.dart'; import 'package:hmg_patient_app/uitl/date_uitl.dart'; import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart'; +import 'package:hmg_patient_app/uitl/navigation_service.dart'; import 'package:hmg_patient_app/uitl/penguin_method_channel.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/utils.dart'; @@ -967,7 +969,7 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { } }).catchError((err) { print(err); - GifLoaderDialogUtils.hideDialog(context); + GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext ?? context); err != null ?? AppToast.showErrorToast(message: err); }); getToDoCount(); @@ -1000,8 +1002,8 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { confirmMessage: res['ErrorEndUserMessage'], okText: "Update insurance", cancelText: "Continue as cash", - okFunction: () => {openUpdateInsurance()}, - cancelFunction: () => {continueAsCash(appo, false)}); + okFunction: () => {openUpdateInsurance(appo, appo.isLiveCareAppointment!)}, + cancelFunction: () => {continueAsCash(appo, appo.isLiveCareAppointment!)}); dialog.showAlertDialog(context); } }).catchError((err) { @@ -1010,9 +1012,28 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { }); } - void openUpdateInsurance() { - Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); - Navigator.push(context, FadePage(page: InsuranceUpdate())); + void openUpdateInsurance(AppoitmentAllHistoryResultList appo, bool isLiveCareAppointment) { + DoctorsListService service = new DoctorsListService(); + GifLoaderDialogUtils.showMyDialog(context); + service.sendPatientUpdateRequest().then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res["MessageStatus"] == 1) { + if (isLiveCareAppointment) { + getLiveCareAppointmentPatientShare(context, service, appo); + } else { + getPatientShare(context, appo); + } + // getToDoCount(); + } else { + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + }); } void continueAsCash(AppoitmentAllHistoryResultList appo, bool isLiveCareAppointment) { @@ -1071,8 +1092,8 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { confirmMessage: errorMsg, okText: TranslationBase.of(context).updateInsuranceText, cancelText: TranslationBase.of(context).continueCash, - okFunction: () => {openUpdateInsurance()}, - cancelFunction: () => {continueAsCash(appo, false)}); + okFunction: () => {openUpdateInsurance(appo, appo.isLiveCareAppointment!)}, + cancelFunction: () => {continueAsCash(appo, appo.isLiveCareAppointment!)}); dialog.showAlertDialog(context); } } @@ -1112,7 +1133,7 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { confirmMessage: errorMsg, okText: TranslationBase.of(context).updateInsuranceText, cancelText: TranslationBase.of(context).continueCash, - okFunction: () => {openUpdateInsurance()}, + okFunction: () => {openUpdateInsurance(appo, appo.isLiveCareAppointment!)}, cancelFunction: () => {continueAsCash(appo, true)}); dialog.showAlertDialog(context); } diff --git a/lib/pages/livecare/widgets/clinic_list.dart b/lib/pages/livecare/widgets/clinic_list.dart index 599b7df9..ae9bab81 100644 --- a/lib/pages/livecare/widgets/clinic_list.dart +++ b/lib/pages/livecare/widgets/clinic_list.dart @@ -239,8 +239,25 @@ class _clinic_listState extends State { } void openUpdateInsurance() { - Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); - Navigator.push(context, FadePage(page: InsuranceUpdate())); + DoctorsListService service = new DoctorsListService(); + GifLoaderDialogUtils.showMyDialog(context); + service.sendPatientUpdateRequest().then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res["MessageStatus"] == 1) { + startLiveCare(); + } else { + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.push(context, FadePage(page: InsuranceUpdate())); + }); + + // Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + // Navigator.push(context, FadePage(page: InsuranceUpdate())); } showLiveCarePaymentDialog(GetERAppointmentFeesList getERAppointmentFeesList, int waitingTime) { diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index f8d8c1ee..f7b6f401 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -1931,6 +1931,19 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } + Future sendPatientUpdateRequest() async { + Map request; + request = {}; + dynamic localRes; + await baseAppClient.post(SEND_PATIENT_IMMEDIATE_UPDATE_INSURANCE_REQUEST, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + + return Future.value(localRes); + } + Future getAncillaryOrders() async { Map body = Map();