From a2a305ea71e0cb65e721b4950e09dee49557625d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 31 Oct 2023 09:18:33 +0300 Subject: [PATCH] Blood donation CR implementing --- lib/config/config.dart | 2 + ...blood_donation_projects_list_response.dart | 46 +++++ .../service/blood/blood_donation_service.dart | 14 ++ lib/core/service/client/base_app_client.dart | 2 +- lib/pages/Blood/blood_donation.dart | 160 +++++++++++++----- .../blood_donation_book_appointment.dart | 112 ++++++++++++ .../clinic_services/get_clinic_service.dart | 17 +- lib/widgets/in_app_browser/InAppBrowser.dart | 4 +- 8 files changed, 299 insertions(+), 58 deletions(-) create mode 100644 lib/core/model/blooddonation/blood_donation_projects_list_response.dart create mode 100644 lib/pages/Blood/blood_donation_book_appointment.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 5ab2c668..ad1b8781 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -618,6 +618,8 @@ var PAYFORT_PROD_URL = 'https://paymentservices.payfort.com/FortAPI/paymentApi'; var CHECK_PATIENT_NPHIES_ELIGIBILITY = 'Services/Doctors.svc/REST/checkPatientInsuranceCompanyValidity'; var CONVERT_PATIENT_TO_CASH = 'Services/Doctors.svc/REST/deActivateInsuranceCompany'; +var GET_BLOOD_DONATION_PROJECTS_LIST = 'Services/OUTPs.svc/REST/BD_getProjectsHaveBDClinics'; + class AppGlobal { static var context; diff --git a/lib/core/model/blooddonation/blood_donation_projects_list_response.dart b/lib/core/model/blooddonation/blood_donation_projects_list_response.dart new file mode 100644 index 00000000..ceb108c5 --- /dev/null +++ b/lib/core/model/blooddonation/blood_donation_projects_list_response.dart @@ -0,0 +1,46 @@ +class BloodDonationProjectsListResponse { + int rowID; + int iD; + int projectID; + int numberOfRooms; + bool isActive; + int createdBy; + String createdOn; + dynamic editedBy; + dynamic editedON; + String projectName; + dynamic projectNameN; + + BloodDonationProjectsListResponse( + {this.rowID, this.iD, this.projectID, this.numberOfRooms, this.isActive, this.createdBy, this.createdOn, this.editedBy, this.editedON, this.projectName, this.projectNameN}); + + BloodDonationProjectsListResponse.fromJson(Map json) { + rowID = json['RowID']; + iD = json['ID']; + projectID = json['ProjectID']; + numberOfRooms = json['NumberOfRooms']; + isActive = json['IsActive']; + createdBy = json['CreatedBy']; + createdOn = json['CreatedOn']; + editedBy = json['EditedBy']; + editedON = json['EditedON']; + projectName = json['ProjectName']; + projectNameN = json['ProjectNameN']; + } + + Map toJson() { + final Map data = new Map(); + data['RowID'] = this.rowID; + data['ID'] = this.iD; + data['ProjectID'] = this.projectID; + data['NumberOfRooms'] = this.numberOfRooms; + data['IsActive'] = this.isActive; + data['CreatedBy'] = this.createdBy; + data['CreatedOn'] = this.createdOn; + data['EditedBy'] = this.editedBy; + data['EditedON'] = this.editedON; + data['ProjectName'] = this.projectName; + data['ProjectNameN'] = this.projectNameN; + return data; + } +} diff --git a/lib/core/service/blood/blood_donation_service.dart b/lib/core/service/blood/blood_donation_service.dart index a59a2169..3a3ee6a2 100644 --- a/lib/core/service/blood/blood_donation_service.dart +++ b/lib/core/service/blood/blood_donation_service.dart @@ -70,4 +70,18 @@ class BloodDonationService extends BaseService { throw error; } } + + Future getBloodDonationProjectsList() async { + Map request; + request = {}; + dynamic localRes; + await baseAppClient.post(GET_BLOOD_DONATION_PROJECTS_LIST, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + + return Future.value(localRes); + } + } diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 313742fa..eb7f05a4 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -150,7 +150,7 @@ class BaseAppClient { // body['IdentificationNo'] = 1023854217; // body['MobileNo'] = "531940021"; - // body['PatientID'] = 4767512; //3844083 + // body['PatientID'] = 3648924; //3844083 // body['TokenID'] = "@dm!n"; // Patient ID: 3027574 diff --git a/lib/pages/Blood/blood_donation.dart b/lib/pages/Blood/blood_donation.dart index 717be242..6b9a2837 100644 --- a/lib/pages/Blood/blood_donation.dart +++ b/lib/pages/Blood/blood_donation.dart @@ -5,12 +5,15 @@ import 'package:diplomaticquarterapp/core/model/blooddonation/get_all_cities.dar import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/h20_setting.dart'; +import 'package:diplomaticquarterapp/pages/Blood/blood_donation_book_appointment.dart'; import 'package:diplomaticquarterapp/pages/Blood/user_agreement_page.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.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'; @@ -21,7 +24,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON } + enum Gender { Male, Female, NON } + enum Blood { Oplus, Ominus, Aplus, Aminus, Bplus, Bminus, ABplus, ABminus, NON } class BloodDonationPage extends StatefulWidget { @@ -134,33 +139,32 @@ class _BloodDonationPageState extends State { ), SizedBox(height: 12), if (projectProvider.isLogin && model.state != ViewState.Busy) - CommonDropDownView( - TranslationBase.of(context).city, - model.CitiesModelList.isNotEmpty - ? projectProvider.isArabic - ? model.CitiesModelList[_selectedHospitalIndex].descriptionN - : model.CitiesModelList[_selectedHospitalIndex].description - : "", () { - List list = [ - for (int i = 0; i < model.CitiesModelList.length; i++) - RadioSelectionDialogModel(projectProvider.isArabic ? model.CitiesModelList[i].descriptionN : model.CitiesModelList[i].description, i), - ]; + TranslationBase.of(context).city, + model.CitiesModelList.isNotEmpty + ? projectProvider.isArabic + ? model.CitiesModelList[_selectedHospitalIndex].descriptionN + : model.CitiesModelList[_selectedHospitalIndex].description + : "", () { + List list = [ + for (int i = 0; i < model.CitiesModelList.length; i++) + RadioSelectionDialogModel(projectProvider.isArabic ? model.CitiesModelList[i].descriptionN : model.CitiesModelList[i].description, i), + ]; - showDialog( - context: context, - builder: (cxt) => RadioSelectionDialog( - listData: list, - selectedIndex: _selectedHospitalIndex, - isScrollable: true, - onValueSelected: (index) { - _selectedHospitalIndex = index; - _selectedHospital = model.CitiesModelList[index]; - setState(() {}); - }, - ), - ); - }).withBorderedContainer, + showDialog( + context: context, + builder: (cxt) => RadioSelectionDialog( + listData: list, + selectedIndex: _selectedHospitalIndex, + isScrollable: true, + onValueSelected: (index) { + _selectedHospitalIndex = index; + _selectedHospital = model.CitiesModelList[index]; + setState(() {}); + }, + ), + ); + }).withBorderedContainer, SizedBox(height: 12), CommonDropDownView(TranslationBase.of(context).gender, _selectedGenderIndex == 1 ? TranslationBase.of(context).male : TranslationBase.of(context).female, () { List list = [ @@ -272,28 +276,90 @@ class _BloodDonationPageState extends State { ), ), ), - DefaultButton( - TranslationBase.of(context).save, - checkedValue - ? () async { - if (_selectedHospital == null) { - AppToast.showErrorToast(message: TranslationBase.of(context).selectCity); - return; - } - bloodDetails.city = _selectedHospital.description; - bloodDetails.cityCode = _selectedHospital.iD.toString(); - bloodDetails.gender = _selectedGenderIndex; - bloodDetails.bloodGroup = getBlood(_selectedBloodTypeIndex); - await model.updateBloodGroup(bloodDetails); - if (model.state == ViewState.Idle) { - AppToast.showSuccessToast(message: model.updatedRegisterBloodMessage); - } else { - AppToast.showErrorToast(message: model.error); - } - } - : null, - disabledColor: CustomColors.grey2, - ).insideContainer + Container( + color: CustomColors.appBackgroudGreyColor, + margin: EdgeInsets.all(14), + height: 45.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Expanded( + flex: 1, + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + height: 45.0, + child: CustomTextButton( + backgroundColor: CustomColors.green, + elevation: 0, + onPressed: () { + Navigator.push(context, FadePage(page: BloodDonationBookAppointment())); + }, + child: Text(TranslationBase.of(context).bookAppo.toUpperCase(), + style: TextStyle( + fontSize: 16.0, + color: Colors.white, + )), + ), + ), + ), + mWidth(7), + Expanded( + flex: 1, + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + height: 45.0, + child: CustomTextButton( + backgroundColor: Color(0xffc5272d), + elevation: 0, + onPressed: () async { + if (_selectedHospital == null) { + AppToast.showErrorToast(message: TranslationBase.of(context).selectCity); + return; + } + bloodDetails.city = _selectedHospital.description; + bloodDetails.cityCode = _selectedHospital.iD.toString(); + bloodDetails.gender = _selectedGenderIndex; + bloodDetails.bloodGroup = getBlood(_selectedBloodTypeIndex); + await model.updateBloodGroup(bloodDetails); + if (model.state == ViewState.Idle) { + AppToast.showSuccessToast(message: model.updatedRegisterBloodMessage); + } else { + AppToast.showErrorToast(message: model.error); + } + }, + child: Text(TranslationBase.of(context).save.toUpperCase(), style: TextStyle(fontSize: 16.0, color: Colors.white)), + ), + ), + ), + ], + ), + ), + // DefaultButton( + // TranslationBase.of(context).save, + // checkedValue + // ? () async { + // if (_selectedHospital == null) { + // AppToast.showErrorToast(message: TranslationBase.of(context).selectCity); + // return; + // } + // bloodDetails.city = _selectedHospital.description; + // bloodDetails.cityCode = _selectedHospital.iD.toString(); + // bloodDetails.gender = _selectedGenderIndex; + // bloodDetails.bloodGroup = getBlood(_selectedBloodTypeIndex); + // await model.updateBloodGroup(bloodDetails); + // if (model.state == ViewState.Idle) { + // AppToast.showSuccessToast(message: model.updatedRegisterBloodMessage); + // } else { + // AppToast.showErrorToast(message: model.error); + // } + // } + // : null, + // disabledColor: CustomColors.grey2, + // ).insideContainer ], ), ), diff --git a/lib/pages/Blood/blood_donation_book_appointment.dart b/lib/pages/Blood/blood_donation_book_appointment.dart new file mode 100644 index 00000000..e252afe0 --- /dev/null +++ b/lib/pages/Blood/blood_donation_book_appointment.dart @@ -0,0 +1,112 @@ +import 'package:diplomaticquarterapp/core/model/blooddonation/blood_donation_projects_list_response.dart'; +import 'package:diplomaticquarterapp/core/service/blood/blood_donation_service.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/widgets/dialogs/radio_selection_dialog.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; + +import '../AlHabibMedicalService/h2o/h20_setting.dart'; + +class BloodDonationBookAppointment extends StatefulWidget { + const BloodDonationBookAppointment(); + + @override + State createState() => _BloodDonationBookAppointmentState(); +} + +class _BloodDonationBookAppointmentState extends State { + List bloodDonationProjectsListResponse = []; + int _selectedProjectID = 0; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + getBloodDonationProjectsList(); + }); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + isShowAppBar: true, + showNewAppBar: true, + backgroundColor: Color(0xffF7F7F7), + showNewAppBarTitle: true, + isShowDecPage: true, + description: TranslationBase.of(context).bloodDonationInfo, + appBarTitle: TranslationBase.of(context).bloodD, + body: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(21), + child: Column( + children: [ + CommonDropDownView(TranslationBase.of(context).selectProject, "Select Hospital", () { + 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; + setState(() {}); + }, + ), + ); + }).withBorderedContainer, + ], + ), + ), + ), + ); + } + + getBloodDonationFreeSlots() { + BloodDonationService service = new BloodDonationService(); + GifLoaderDialogUtils.showMyDialog(context); + service.getBloodDonationProjectsList().then((res) { + GifLoaderDialogUtils.hideDialog(context); + print(res['BD_getProjectsHaveBDClinics']); + if (res["MessageStatus"] == 1) { + res['BD_getProjectsHaveBDClinics'].forEach((element) { + bloodDonationProjectsListResponse.add(BloodDonationProjectsListResponse.fromJson(element)); + }); + print(bloodDonationProjectsListResponse.length); + } else { + AppToast.showErrorToast(message: res["ErrorEndUserMessage"]); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } + + getBloodDonationProjectsList() { + BloodDonationService service = new BloodDonationService(); + GifLoaderDialogUtils.showMyDialog(context); + service.getBloodDonationProjectsList().then((res) { + GifLoaderDialogUtils.hideDialog(context); + print(res['BD_getProjectsHaveBDClinics']); + if (res["MessageStatus"] == 1) { + res['BD_getProjectsHaveBDClinics'].forEach((element) { + bloodDonationProjectsListResponse.add(BloodDonationProjectsListResponse.fromJson(element)); + }); + print(bloodDonationProjectsListResponse.length); + } else { + AppToast.showErrorToast(message: res["ErrorEndUserMessage"]); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } +} diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 8bf3a0ec..31e9641c 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -177,14 +177,15 @@ class ClinicListService extends BaseService { }, body: request); return Future.value(localRes); } + Future getCountries() async { - Map request ={}; + Map request = {}; dynamic localRes; - await baseAppClient.post(GET_NATIONALITY, onSuccess: (response, statusCode) async { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: request); - return Future.value(localRes); -} + await baseAppClient.post(GET_NATIONALITY, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } } diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index f38ad57c..28a364e5 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -35,9 +35,9 @@ class MyInAppBrowser extends InAppBrowser { // static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT - // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT - static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE + // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE // static String SERVICE_URL = 'https://uat.hmgwebservices.com/payfortforvidaplus/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL UAT VIDA PLUS