From 9a0a658083e2a6bb205900516c1a4a5336d7fd3c Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 9 Jun 2024 11:46:00 +0300 Subject: [PATCH] Online CheckIn CR implementation Contd. --- .../EROnlineCheckInBookAppointment.dart | 171 +++++++++++++++++- .../EROnlineCheckIn/EROnlineCheckInHome.dart | 12 +- .../EROnlineCheckInPaymentDetails.dart | 27 ++- .../appointment_services/GetDoctorsList.dart | 7 +- 4 files changed, 203 insertions(+), 14 deletions(-) diff --git a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInBookAppointment.dart b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInBookAppointment.dart index 640c605b..1333883b 100644 --- a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInBookAppointment.dart +++ b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInBookAppointment.dart @@ -1,6 +1,15 @@ +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.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'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -11,8 +20,20 @@ class EROnlineCheckInBookAppointment extends StatefulWidget { State createState() => _EROnlineCheckInBookAppointmentState(); } -class _EROnlineCheckInBookAppointmentState extends State { +class _EROnlineCheckInBookAppointmentState extends State with SingleTickerProviderStateMixin { ProjectViewModel projectViewModel; + List projectsList = []; + final GlobalKey projectDropdownKey = GlobalKey(); + HospitalsModel selectedHospital; + String projectDropdownValue = ""; + + @override + void initState() { + WidgetsBinding.instance.addPostFrameCallback((_) { + getProjectsList(); + }); + super.initState(); + } @override Widget build(BuildContext context) { @@ -28,9 +49,155 @@ class _EROnlineCheckInBookAppointmentState extends State( + key: projectDropdownKey, + hint: new Text(TranslationBase.of(context).selectHospital), + value: selectedHospital, + iconSize: 0, + isExpanded: true, + style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black), + items: projectsList.map((item) { + return new DropdownMenuItem( + value: item, + child: new Text(item.name), + ); + }).toList(), + onChanged: (newValue) async { + setState(() { + selectedHospital = newValue; + projectDropdownValue = newValue.mainProjectID.toString(); + }); + }, + ), + ), + ), + ], + ), + ), + Icon(Icons.keyboard_arrow_down), + ], + ), + ), + ), + mHeight(16), + Container( + width: double.infinity, + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).clinicName, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, + ), + ), + Text( + "ER Clinic", + style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black), + ), + ], + ), + ), + ], + ), + ), + bottomSheet: Container( + height: 80, + color: CustomColors.white, + padding: EdgeInsets.fromLTRB(12.0, 12.0, 12.0, 25.0), + child: DefaultButton( + TranslationBase.of(context).bookAppo, + () { + if (projectDropdownValue == "" || selectedHospital == null) { + AppToast.showErrorToast(message: TranslationBase.of(context).selectHospital); + } else { + Navigator.push( + context, + FadePage( + page: EROnlineCheckInPaymentDetails( + projectID: selectedHospital.iD, + isERBookAppointment: true, + projectName: selectedHospital.name, + ), + ), + ); + } + }, + color: CustomColors.accentColor, ), ), ); } + + getProjectsList() { + int languageID = projectViewModel.isArabic ? 1 : 2; + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService service = new ClinicListService(); + List projectsListLocal = []; + service.getProjectsList(languageID, context).then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res['MessageStatus'] == 1) { + setState(() { + res['ListProject'].forEach((v) { + projectsListLocal.add(new HospitalsModel.fromJson(v)); + }); + projectsList = projectsListLocal; + }); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } + + void openDropdown(GlobalKey key) { + GestureDetector detector; + void searchForGestureDetector(BuildContext element) { + element.visitChildElements((element) { + if (element.widget != null && element.widget is GestureDetector) { + detector = element.widget; + return false; + } else { + searchForGestureDetector(element); + } + return true; + }); + } + + searchForGestureDetector(key.currentContext); + assert(detector != null); + detector.onTap(); + } } diff --git a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart index 94bff23c..8126d3a4 100644 --- a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart +++ b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInHome.dart @@ -347,8 +347,18 @@ class _EROnlineCheckInHomePageState extends State with if (response["GetProjectByNFC"].length != 0) { print(response["GetProjectByNFC"]); int projectID = response['GetProjectByNFC'][0]["ProjectID"]; + String projectName = response['GetProjectByNFC'][0]["ProjectName"]; GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: EROnlineCheckInPaymentDetails(projectID: projectID))); + Navigator.push( + context, + FadePage( + page: EROnlineCheckInPaymentDetails( + projectID: projectID, + isERBookAppointment: false, + projectName: projectName, + ), + ), + ); } else { AppToast.showErrorToast(message: "Invalid NFC Card Scanned."); } diff --git a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart index e848e7a5..d7d6cd6d 100644 --- a/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart +++ b/lib/pages/ErService/EROnlineCheckIn/EROnlineCheckInPaymentDetails.dart @@ -29,10 +29,11 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class EROnlineCheckInPaymentDetails extends StatefulWidget { - int projectID = 0; + bool isERBookAppointment = false; + String projectName = ""; - EROnlineCheckInPaymentDetails({@required this.projectID}); + EROnlineCheckInPaymentDetails({@required this.projectID, @required this.isERBookAppointment, @required this.projectName}); @override State createState() => _EROnlineCheckInPaymentDetailsState(); @@ -181,7 +182,7 @@ class _EROnlineCheckInPaymentDetailsState extends State HIS_createAdvancePayment(AppoitmentAllHistoryResultList appo, String projectID, double payedAmount, String paymentReference, String paymentMethodName, dynamic patientType, String patientName, dynamic patientID, BuildContext context, - {bool isAncillaryOrder = false}) async { + {bool isAncillaryOrder = false, int clinicID = 0}) async { Map request; if (await this.sharedPref.getObject(USER_PROFILE) != null) { var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); @@ -1764,7 +1764,7 @@ class DoctorsListService extends BaseService { return Future.value(localRes); } - Future autoGenerateInvoiceERClinic(int projectID, int paymentMethod, String paymentReferenceNo, num amount, String cardType, String cardNumber, String orderID, String rrn) async { + Future autoGenerateInvoiceERClinic(int projectID, int paymentMethod, String paymentReferenceNo, num amount, String cardType, String cardNumber, String orderID, String rrn, bool isAdvanceAvailable) async { Map request; request = { "ProjectID": projectID, @@ -1776,7 +1776,8 @@ class DoctorsListService extends BaseService { "CardNumber": cardNumber, "OrderId": orderID, "MemberID": 102, - "RRN": rrn + "RRN": rrn, + "IsAdvanceAvailable": isAdvanceAvailable }; dynamic localRes; await baseAppClient.post(AUTO_GENERATE_INVOICE_ER, onSuccess: (response, statusCode) async {