From bbbec1a7161604da1a6951c1ee6b0b77981e53d1 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 1 Nov 2023 12:54:41 +0300 Subject: [PATCH] Blood Donation appointment implementation completed. --- .../blood_donation_book_appointment.dart | 111 ++++++++++++++---- lib/pages/BookAppointment/BookConfirm.dart | 1 - 2 files changed, 89 insertions(+), 23 deletions(-) diff --git a/lib/pages/Blood/blood_donation_book_appointment.dart b/lib/pages/Blood/blood_donation_book_appointment.dart index bbfe3272..34d4ab9a 100644 --- a/lib/pages/Blood/blood_donation_book_appointment.dart +++ b/lib/pages/Blood/blood_donation_book_appointment.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/service/blood/blood_donation_service.d import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/FreeSlot.dart'; import 'package:diplomaticquarterapp/models/Appointments/timeSlot.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; @@ -11,6 +12,7 @@ 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/custom_text_button.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; @@ -42,6 +44,8 @@ class _BloodDonationBookAppointmentState extends State docFreeSlots = []; List dayEvents = []; @@ -95,25 +99,32 @@ class _BloodDonationBookAppointmentState extends State list = []; - bloodDonationProjectsListResponse.forEach((element) { - list.add(RadioSelectionDialogModel(element.projectName, element.projectID)); - }); - showDialog( - context: context, - builder: (cxt) => RadioSelectionDialog( - listData: list, - selectedIndex: 0, - onValueSelected: (index) { - print(index); - _selectedProjectID = index; - getBloodDonationFreeSlots(); - setState(() {}); - }, - ), - ); - }).withBorderedContainer, + Text("Please select the project you want to book an appointment with: ", style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600, letterSpacing: -0.64)), + mHeight(12), + CommonDropDownView( + TranslationBase.of(context).selectProject, + selectedProjectName, + () { + List list = []; + bloodDonationProjectsListResponse.forEach((element) { + list.add(RadioSelectionDialogModel(element.projectName, element.projectID)); + }); + showDialog( + context: context, + builder: (cxt) => RadioSelectionDialog( + listData: list, + selectedIndex: 0, + onValueSelected: (index) { + print(index); + _selectedProjectID = index; + selectedProjectName = bloodDonationProjectsListResponse.firstWhere((element) => element.projectID == index).projectName; + getBloodDonationFreeSlots(); + setState(() {}); + }, + ), + ); + }, + ).withBorderedContainer, mHeight(12), Container( decoration: cardRadius(12), @@ -149,16 +160,72 @@ class _BloodDonationBookAppointmentState extends State[ + Container( + width: MediaQuery.of(context).size.width * 0.9, + child: DefaultButton( + TranslationBase.of(context).bookAppo, + () async { + if (BloodDonationBookAppointment.areSlotsAvailable) { + insertBloodDonationAppointment(); + } else { + AppToast.showErrorToast(message: TranslationBase.of(context).selectSlot); + } + // GifLoaderDialogUtils.showMyDialog(context); + // await model.sendLabReportEmail(patientLabOrder: widget.patientLabOrders, mes: TranslationBase.of(context).sendSuc, userObj: projectViewModel.user, isVidaPlus: Utils.isVidaPlusProject(projectViewModel, num.parse(widget.patientLabOrders.projectID)), isDownload: true); + // GifLoaderDialogUtils.hideDialog(context); + // try { + // String path = await _createFileFromString(model.labReportPDF, "pdf"); + // OpenFilex.open(path); + // } catch (ex) { + // AppToast.showErrorToast(message: "Cannot open file."); + // } + }, + textColor: Colors.white, + color: CustomColors.green, + ), + ), + ], + ), + ), ); } + void insertBloodDonationAppointment() { + DoctorsListService service = new DoctorsListService(); + final timeSlot = BloodDonationBookAppointment.selectedAppoDateTime; + GifLoaderDialogUtils.showMyDialog(context); + service + .insertAppointment( + _doctorID, _clinicID, _selectedProjectID, BloodDonationBookAppointment.selectedTime, BloodDonationBookAppointment.selectedDate, 45, context, null, null, null, projectViewModel) + .then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res['MessageStatus'] == 1) { + AppToast.showSuccessToast(message: TranslationBase.of(context).bookedSuccess); + Navigator.of(context).pop(); + Future.delayed(new Duration(milliseconds: 500), () { + // getToDoCount(); + }); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + } + }); + } + void _onDaySelected(DateTime day, ProjectViewModel projectViewModel) { final DateFormat formatter = DateFormat('yyyy-MM-dd'); setState(() { diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 50dbc70f..19dc01f6 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -335,7 +335,6 @@ class _BookConfirmState extends State { AppToast.showSuccessToast(message: TranslationBase.of(context).bookedSuccess); Future.delayed(new Duration(milliseconds: 500), () { - // checkPatientNphiesEligibility(docObject, res['AppointmentNo'], context); getToDoCount(); getPatientShare(context, res['AppointmentNo'], docObject.clinicID, docObject.projectID, docObject); });