From f65fe26fd26fcb131781c7aa636f98b58bf76978 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 6 Jun 2024 16:50:19 +0300 Subject: [PATCH] ER Online CheckIn implementation contd --- lib/config/config.dart | 8 +- .../EROnlineCheckIn/EROnlineCheckInHome.dart | 139 +++++++++++++----- .../EROnlineCheckInPaymentDetails.dart | 69 +++++++-- .../clinic_services/get_clinic_service.dart | 21 +++ 4 files changed, 184 insertions(+), 53 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index e71b185b..43693ed5 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -601,9 +601,9 @@ var GET_DENTAL_APPOINTMENT_INVOICE = "Services/Patients.svc/REST/HIS_eInvoiceFor var SEND_DENTAL_APPOINTMENT_INVOICE_EMAIL = "Services/Notifications.svc/REST/SendInvoiceForDental"; -var GET_TAMARA_PLAN = 'https://mdlaboratories.com/tamaralive/Home/GetInstallments'; +var GET_TAMARA_PLAN = 'https://mdlaboratories.com/tamara/Home/GetInstallments'; -var GET_TAMARA_PAYMENT_STATUS = 'https://mdlaboratories.com/tamaralive/api/OnlineTamara/order_status?orderid='; +var GET_TAMARA_PAYMENT_STATUS = 'https://mdlaboratories.com/tamara/api/OnlineTamara/order_status?orderid='; var UPDATE_TAMARA_STATUS = 'Services/PayFort_Serv.svc/REST/Tamara_UpdateRequestStatus'; @@ -637,6 +637,10 @@ var GET_ER_ONLINE_PAYMENT_DETAILS = 'Services/OUTPs.svc/Rest/Outp_GetPatientPaym var AUTO_GENERATE_INVOICE_ER = 'Services/OUTPs.svc/Rest/Outp_AutoGenerateInvoiceForER'; +var CHECK_IF_PATIENT_ARRIVED_ER_ONLINE_CHECKIN = 'Services/OUTPs.svc/Rest/IsPatientArrived'; + +var GET_PROJECT_FROM_NFC = 'Services/OUTPs.svc/Rest/GetProjectByNFC'; + //PAYFORT var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails"; var addPayFortApplePayResponse = "Services/PayFort_Serv.svc/REST/AddResponse"; diff --git a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart index 4424efc7..64df1b23 100644 --- a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart +++ b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart @@ -1,8 +1,10 @@ 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/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; @@ -21,10 +23,18 @@ class EROnlineCheckInHomePage extends StatefulWidget { State createState() => _EROnlineCheckInHomePageState(); } -class _EROnlineCheckInHomePageState extends State { +class _EROnlineCheckInHomePageState extends State with SingleTickerProviderStateMixin { ProjectViewModel projectViewModel; - bool _supportsNFC = false; + bool isPatientArrived = false; + + @override + void initState() { + WidgetsBinding.instance.addPostFrameCallback((_) { + checkIfPatientHasArrived(); + }); + super.initState(); + } @override Widget build(BuildContext context) { @@ -263,46 +273,99 @@ class _EROnlineCheckInHomePageState extends State { height: 80, color: CustomColors.white, padding: EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 25.0), - child: Row( - children: [ - Expanded( - flex: 1, - child: DefaultButton( - TranslationBase.of(context).checkinOptions, - () { - if (_supportsNFC) { - Future.delayed(const Duration(milliseconds: 500), () { - showNfcReader(context, onNcfScan: (String nfcId) { - Future.delayed(const Duration(milliseconds: 100), () { - print(nfcId); - Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails())); + child: isPatientArrived + ? Container( + child: DefaultButton( + TranslationBase.of(context).arrived, + () { + if (_supportsNFC) { + Future.delayed(const Duration(milliseconds: 500), () { + showNfcReader(context, onNcfScan: (String nfcId) { + Future.delayed(const Duration(milliseconds: 100), () { + print(nfcId); + // Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails())); + }); + }, onCancel: () { + Navigator.of(context).pop(); }); - }, onCancel: () { - Navigator.of(context).pop(); }); - }); - } else { - //NFCNotSupported - AppToast.showErrorToast(message: TranslationBase.of(context).NFCNotSupported); - } - }, - color: CustomColors.green, - ), - ), - mWidth(12), - Expanded( - flex: 1, - child: DefaultButton( - TranslationBase.of(context).bookAppo, - () { - Navigator.push(context, FadePage(page: EROnlineCheckInBookAppointment())); - }, - color: CustomColors.accentColor, + } else { + //NFCNotSupported + AppToast.showErrorToast(message: TranslationBase.of(context).NFCNotSupported); + } + }, + color: CustomColors.accentColor, + ), + ) + : Row( + children: [ + Expanded( + flex: 1, + child: DefaultButton( + TranslationBase.of(context).checkinOptions, + () { + if (_supportsNFC) { + Future.delayed(const Duration(milliseconds: 500), () { + showNfcReader(context, onNcfScan: (String nfcId) { + Future.delayed(const Duration(milliseconds: 100), () { + print(nfcId); + getProjectIDFromNFC(nfcId); + }); + }, onCancel: () { + Navigator.of(context).pop(); + }); + }); + } else { + //NFCNotSupported + AppToast.showErrorToast(message: TranslationBase.of(context).NFCNotSupported); + } + }, + color: CustomColors.green, + ), + ), + mWidth(12), + Expanded( + flex: 1, + child: DefaultButton( + TranslationBase.of(context).bookAppo, + () { + Navigator.push(context, FadePage(page: EROnlineCheckInBookAppointment())); + }, + color: CustomColors.accentColor, + ), + ), + ], ), - ), - ], - ), ), ); } + + void getProjectIDFromNFC(String nfcID) { + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService ancillaryOrdersService = new ClinicListService(); + ancillaryOrdersService.getProjectIDFromNFC(nfcID).then((response) { + print(response["GetProjectByNFC"]); + int projectID = response['GetProjectByNFC'][0]["ProjectID"]; + GifLoaderDialogUtils.hideDialog(context); + Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails(projectID: projectID))); + }).catchError((err) { + AppToast.showErrorToast(message: err.toString()); + GifLoaderDialogUtils.hideDialog(context); + }); + } + + void checkIfPatientHasArrived() { + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService ancillaryOrdersService = new ClinicListService(); + ancillaryOrdersService.checkIfPatientHasArrived(15, 10).then((response) { + print(response["IsPatientArrivedResponse"]); + isPatientArrived = response['IsPatientArrivedResponse']["IsPatientArrived"]; + 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 0b005d6a..e848e7a5 100644 --- a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart +++ b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/enum/PayfortEnums.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Clinics/EROnlineCheckInPaymentDetailsResponse.dart'; import 'package:diplomaticquarterapp/models/LiveCare/ApplePayInsertRequest.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart'; @@ -22,12 +23,16 @@ import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/dragable_sheet.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class EROnlineCheckInPaymentDetails extends StatefulWidget { - const EROnlineCheckInPaymentDetails(); + + int projectID = 0; + + EROnlineCheckInPaymentDetails({@required this.projectID}); @override State createState() => _EROnlineCheckInPaymentDetailsState(); @@ -39,6 +44,7 @@ class _EROnlineCheckInPaymentDetailsState extends State().getProjectDetailsForPayfort(projectId: 15, serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum()).then((value) { + await context.read().getProjectDetailsForPayfort(projectId: widget.projectID, serviceId: ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum()).then((value) { payfortProjectDetailsRespModel = value; }); @@ -335,7 +378,7 @@ class _EROnlineCheckInPaymentDetailsState extends State checkIfPatientHasArrived(int projectID, int clinicID) async { + Map request = {"ProjectID": projectID, "ClinicID": clinicID}; + dynamic localRes; + await baseAppClient.post(CHECK_IF_PATIENT_ARRIVED_ER_ONLINE_CHECKIN, 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; + await baseAppClient.post(GET_PROJECT_FROM_NFC, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request, isAllowAny: true); + return Future.value(localRes); + } }