diff --git a/lib/config/config.dart b/lib/config/config.dart index b09dce5b..5adb06d2 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -67,9 +67,10 @@ const CHECK_PAYMENT_STATUS = "/PayFort_Serv.svc/REST/GetRequestStatusByRequestID //URL create advance payment const CREATE_ADVANCE_PAYMENT = "/Doctors.svc/REST/CreateAdvancePayment"; - const ADD_ADVANCE_NUMBER_REQUEST = '/PayFort_Serv.svc/REST/AddAdvancedNumberRequest'; +const IS_ALLOW_ASK_DOCTOR = '/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; + //URL to get medicine and pharmacies list const CHANNEL = 3; const GENERAL_ID = 'Cs2020@2016\$2958'; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 3611298d..abb070ff 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -181,5 +181,5 @@ const Map> localizedValues = { "payNowBookSuccesstext1": {"en": "Pay Now using online payment service From secure payment gateways", "ar": "ادفع الآن باستخدام خدمة الدفع عبر الإنترنت من بوابات الدفع الآمنة"}, "payNowBookSuccesstext2": {"en": "You can also Pay Later via online payment Or in Hospital", "ar": "يمكنك أيضًا الدفع لاحقًا عبر الدفع عبر الإنترنت أو في المستشفى"}, 'payLater': {'en': 'Pay Later', 'ar': 'ادفع لاحقا'}, - + 'askDocNotAllowed': {'en': 'This service will be available for last 15 days doctor Visit only', 'ar': 'هذه الخدمة متاحة للزيارات خلال اخر 15 يوم فقط'}, }; diff --git a/lib/models/Appointments/AppoimentAllHistoryResultList.dart b/lib/models/Appointments/AppoimentAllHistoryResultList.dart index 4fa19576..a935542a 100644 --- a/lib/models/Appointments/AppoimentAllHistoryResultList.dart +++ b/lib/models/Appointments/AppoimentAllHistoryResultList.dart @@ -173,7 +173,7 @@ class AppoitmentAllHistoryResultList { doctorImageURL = json['DoctorImageURL']; doctorNameObj = json['DoctorNameObj']; doctorRate = json['DoctorRate']; - doctorSpeciality = json['DoctorSpeciality'].cast(); + doctorSpeciality = json['DoctorSpeciality'] != null ?json['DoctorSpeciality'].cast() : ["null"]; doctorTitle = json['DoctorTitle']; gender = json['Gender']; genderDescription = json['GenderDescription']; diff --git a/lib/pages/MyAppointments/AppointmentDetails.dart b/lib/pages/MyAppointments/AppointmentDetails.dart index 281a8aa8..d14858b3 100644 --- a/lib/pages/MyAppointments/AppointmentDetails.dart +++ b/lib/pages/MyAppointments/AppointmentDetails.dart @@ -14,6 +14,8 @@ class AppointmentDetails extends StatefulWidget { AppoitmentAllHistoryResultList appo; static bool isLoading = false; + static bool showFooterButton = false; + AppointmentDetails({@required this.appo}); @override @@ -23,7 +25,6 @@ class AppointmentDetails extends StatefulWidget { class _AppointmentDetailsState extends State with SingleTickerProviderStateMixin { static TabController _tabController; - bool showFooterButton = false; @override void initState() { @@ -43,7 +44,7 @@ class _AppointmentDetailsState extends State return AppScaffold( appBarTitle: widget.appo.doctorNameObj, isShowAppBar: true, - bottomSheet: showFooterButton + bottomSheet: AppointmentDetails.showFooterButton ? Container( width: MediaQuery.of(context).size.width, height: 50.0, @@ -146,9 +147,9 @@ class _AppointmentDetailsState extends State onTap: (index) { setState(() { index == 1 - ? showFooterButton = true - : showFooterButton = false; - print(showFooterButton); + ? AppointmentDetails.showFooterButton = true + : AppointmentDetails.showFooterButton = false; + print(AppointmentDetails.showFooterButton); }); }, tabs: [ @@ -170,7 +171,7 @@ class _AppointmentDetailsState extends State child: TabBarView( physics: NeverScrollableScrollPhysics(), children: [ - AppointmentActions(appo: widget.appo, tabController: _tabController), + AppointmentActions(appo: widget.appo, tabController: _tabController, enableFooterButton: enableFooterButton), DocAvailableAppointments(doctor: getDoctorObject()) ], controller: _tabController, @@ -183,6 +184,12 @@ class _AppointmentDetailsState extends State ); } + void enableFooterButton() { + setState(() { + AppointmentDetails.showFooterButton = true; + }); + } + void goToBookConfirm() { if (DocAvailableAppointments.areSlotsAvailable) navigateToBookConfirm(context); diff --git a/lib/pages/MyAppointments/models/ArrivedButtons.dart b/lib/pages/MyAppointments/models/ArrivedButtons.dart index 00778ef7..56721009 100644 --- a/lib/pages/MyAppointments/models/ArrivedButtons.dart +++ b/lib/pages/MyAppointments/models/ArrivedButtons.dart @@ -49,7 +49,7 @@ class ArrivedButtons { "title": "Ask Your", "subtitle": "Doctor", "icon": "assets/images/new-design/ask_doctor_icon.png", - "caller": "goToTodoList" + "caller": "askDoc" }, { "title": "Survey", diff --git a/lib/pages/MyAppointments/widgets/AppointmentActions.dart b/lib/pages/MyAppointments/widgets/AppointmentActions.dart index 1641776d..1d3f0bc6 100644 --- a/lib/pages/MyAppointments/widgets/AppointmentActions.dart +++ b/lib/pages/MyAppointments/widgets/AppointmentActions.dart @@ -18,8 +18,12 @@ import 'package:url_launcher/url_launcher.dart'; class AppointmentActions extends StatefulWidget { AppoitmentAllHistoryResultList appo; TabController tabController; + final Function enableFooterButton; - AppointmentActions({@required this.appo, @required this.tabController}); + AppointmentActions( + {@required this.appo, + @required this.tabController, + @required this.enableFooterButton}); @override _AppointmentActionsState createState() => _AppointmentActionsState(); @@ -117,6 +121,10 @@ class _AppointmentActionsState extends State { switch (AppoDetailsButton.caller) { case "openReschedule": widget.tabController.animateTo((widget.tabController.index + 1) % 2); + setState(() { + print("Reschedule"); + widget.enableFooterButton(); + }); break; case "onCancelAppointment": @@ -146,6 +154,10 @@ class _AppointmentActionsState extends State { case "goToTodoList": Navigator.of(context).pop(); break; + + case "askDoc": + askYourDoc(); + break; } } @@ -347,8 +359,23 @@ class _AppointmentActionsState extends State { pageBuilder: (context, animation1, animation2) {}); } + askYourDoc() { + DoctorsListService service = new DoctorsListService(); + service + .isAllowedToAskDoctor(widget.appo.doctorID, context) + .then((res) { + print(res['PatientDoctorAppointmentResultList']); + if (res['PatientDoctorAppointmentResultList'].length != 0) { + + } else { + AppToast.showErrorToast(message: TranslationBase.of(context).askDocNotAllowed); + } + }).catchError((err) { + print(err); + }); + } + confirmAppointment() { - loading(true); DoctorsListService service = new DoctorsListService(); service .confirmAppointment(widget.appo.appointmentNo, widget.appo.clinicID, @@ -356,14 +383,12 @@ class _AppointmentActionsState extends State { .then((res) { if (res['MessageStatus'] == 1) { AppToast.showSuccessToast(message: res['ErrorEndUserMessage']); - loading(false); + Navigator.of(context).pop(); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); - loading(false); } }).catchError((err) { print(err); - loading(false); }); } diff --git a/lib/services/appointment_services/GetDoctorsList.dart b/lib/services/appointment_services/GetDoctorsList.dart index a2991805..592240b2 100644 --- a/lib/services/appointment_services/GetDoctorsList.dart +++ b/lib/services/appointment_services/GetDoctorsList.dart @@ -614,7 +614,10 @@ class DoctorsListService extends BaseService { } Future addAdvancedNumberRequest( - String advanceNumber, String paymentReference, String appointmentID, BuildContext context) async { + String advanceNumber, + String paymentReference, + String appointmentID, + BuildContext context) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { var data = AuthenticatedUser.fromJson( @@ -644,10 +647,53 @@ class DoctorsListService extends BaseService { dynamic localRes; await baseAppClient.post(ADD_ADVANCE_NUMBER_REQUEST, onSuccess: (response, statusCode) async { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: request); + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + + Future isAllowedToAskDoctor(int docID, BuildContext context) async { + Utils.showProgressDialog(context); + Map request; + if (await this.sharedPref.getObject(USER_PROFILE) != null) { + var data = AuthenticatedUser.fromJson( + await this.sharedPref.getObject(USER_PROFILE)); + authUser = data; + } + var languageID = await sharedPref.getString(APP_LANGUAGE); + Request req = appGlobal.getPublicRequest(); + request = { + "IsForAskYourDoctor": true, + "DoctorID": docID, + "Top": 25, + "beforeDays": 15, + "exludType": 4, + "VersionID": req.VersionID, + "Channel": req.Channel, + "LanguageID": languageID == 'ar' ? 1 : 2, + "IPAdress": req.IPAdress, + "generalid": req.generalid, + "PatientOutSA": authUser.outSA, + "SessionID": "YckwoXhUmWBsnHKEKig", + "isDentalAllowedBackend": false, + "DeviceTypeID": req.DeviceTypeID, + "PatientID": authUser.patientID, + "TokenID": "@dm!n", + "PatientTypeID": authUser.patientType, + "PatientType": authUser.patientType + }; + + dynamic localRes; + await baseAppClient.post(IS_ALLOW_ASK_DOCTOR, + onSuccess: (response, statusCode) async { + localRes = response; + Utils.hideProgressDialog(); + }, onFailure: (String error, int statusCode) { + Utils.hideProgressDialog(); + throw error; + }, body: request); return Future.value(localRes); } @@ -672,7 +718,11 @@ class DoctorsListService extends BaseService { "AppointmentNo": appo.appointmentNo.toString(), "PaymentMethodName": paymentMethodName, "PaymentAmount": payedAmount == 0 ? "0" : payedAmount.toString(), - "PaymentDate": payedAmount == 0 ? "" : "/Date(" + DateTime.now().millisecondsSinceEpoch.toString() + ")/", + "PaymentDate": payedAmount == 0 + ? "" + : "/Date(" + + DateTime.now().millisecondsSinceEpoch.toString() + + ")/", "PaymentReferenceNumber": payedAmount == 0 ? "" : paymentReference, "ProjectID": appo.projectID.toString(), "PatientID": authUser.patientID, diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 168978b5..48e6fabc 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -292,6 +292,7 @@ class TranslationBase { String get payNowBookSuccesstext1 => localizedValues['payNowBookSuccesstext1'][locale.languageCode]; String get payNowBookSuccesstext2 => localizedValues['payNowBookSuccesstext2'][locale.languageCode]; String get payLater => localizedValues['payLater'][locale.languageCode]; + String get askDocNotAllowed => localizedValues['askDocNotAllowed'][locale.languageCode]; } diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index be2ed285..fceba0c0 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -10,16 +10,18 @@ import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; class MyInAppBrowser extends InAppBrowser { - static String SERVICE_URL = - 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT - // ignore: non_constant_identifier_names // static String SERVICE_URL = -// 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE +// 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + // ignore: non_constant_identifier_names + + static String SERVICE_URL = + 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE - static String PREAUTH_SERVICE_URL = - 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT // static String PREAUTH_SERVICE_URL = -// 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store +// 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT + + static String PREAUTH_SERVICE_URL = + 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store static List successURLS = [ 'success',