blood donation changes

pull/166/head
aamir-csol 2 months ago
parent a816afadea
commit 0017c0601b

@ -679,7 +679,7 @@ const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard';
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; static const maxSmallScreen = 660;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.preProd;
// static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT
@ -889,6 +889,10 @@ class ApiConsts {
static String getProjectsHaveBDClinics = "Services/OUTPs.svc/REST/BD_getProjectsHaveBDClinics"; static String getProjectsHaveBDClinics = "Services/OUTPs.svc/REST/BD_getProjectsHaveBDClinics";
static String getClinicsBDFreeSlots = "Services/OUTPs.svc/REST/BD_GetFreeSlots"; static String getClinicsBDFreeSlots = "Services/OUTPs.svc/REST/BD_GetFreeSlots";
static String getPatientBloodGroup = "services/PatientVarification.svc/REST/BloodDonation_GetBloodGroupDetails";
static String getPatientBloodAgreement = "Services/PatientVarification.svc/REST/CheckUserAgreementForBloodDonation";
// ************ static values for Api **************** // ************ static values for Api ****************
static final double appVersionID = 50.3; static final double appVersionID = 50.3;
static final int appChannelId = 3; static final int appChannelId = 3;

@ -23,6 +23,8 @@ abstract class BloodDonationRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> getFreeBloodDonationSlots({required Map<String, dynamic> request}); Future<Either<Failure, GenericApiModel<dynamic>>> getFreeBloodDonationSlots({required Map<String, dynamic> request});
Future<Either<Failure, GenericApiModel<dynamic>>> addUserAgreementForBloodDonation({required Map<String, dynamic> request}); Future<Either<Failure, GenericApiModel<dynamic>>> addUserAgreementForBloodDonation({required Map<String, dynamic> request});
Future<Either<Failure, GenericApiModel<dynamic>>> getUserAgreementForBloodDonation();
} }
class BloodDonationRepoImp implements BloodDonationRepo { class BloodDonationRepoImp implements BloodDonationRepo {
@ -76,7 +78,7 @@ class BloodDonationRepoImp implements BloodDonationRepo {
GenericApiModel<List_BloodGroupDetailsModel>? apiResponse; GenericApiModel<List_BloodGroupDetailsModel>? apiResponse;
Failure? failure; Failure? failure;
await apiClient.post( await apiClient.post(
GET_BLOOD_REQUEST, ApiConsts.getPatientBloodGroup,
body: mapDevice, body: mapDevice,
isAllowAny: true, isAllowAny: true,
onFailure: (error, statusCode, {messageStatus, failureType}) { onFailure: (error, statusCode, {messageStatus, failureType}) {
@ -287,4 +289,36 @@ class BloodDonationRepoImp implements BloodDonationRepo {
return Left(UnknownFailure(e.toString())); return Left(UnknownFailure(e.toString()));
} }
} }
@override
Future<Either<Failure, GenericApiModel<List<dynamic>>>> getUserAgreementForBloodDonation() async {
try {
GenericApiModel<List<dynamic>>? apiResponse;
Failure? failure;
await apiClient.post(
ApiConsts.getPatientBloodAgreement,
body: {},
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
apiResponse = GenericApiModel<List<dynamic>>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: null,
data: response,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
}
},
);
if (failure != null) return Left(failure!);
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
return Right(apiResponse!);
} catch (e) {
return Left(UnknownFailure(e.toString()));
}
}
} }

@ -4,6 +4,7 @@ import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/doctor_response_mapper.dart'; import 'package:hmg_patient_app_new/core/utils/doctor_response_mapper.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart'; import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/features/blood_donation/blood_donation_repo.dart'; import 'package:hmg_patient_app_new/features/blood_donation/blood_donation_repo.dart';
@ -258,25 +259,11 @@ class BloodDonationViewModel extends ChangeNotifier {
Future<void> updateBloodGroup() async { Future<void> updateBloodGroup() async {
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader();
// body['City'] = detailsModel.city; Map<String, dynamic> payload = {"City": selectedCity?.description, "cityCode": selectedCity?.iD, "Gender": selectedGender?.value, "isDentalAllowedBackend": false};
// body['cityCode'] = detailsModel.cityCode;
// body['Gender'] = detailsModel.gender;
// body['BloodGroup'] = detailsModel.bloodGroup;
// body['CellNumber'] = user.mobileNumber;
// body['LanguageID'] = languageID;
// body['NationalID'] = user.nationalityID;
// body['ZipCode'] = user.zipCode ?? "+966";
// body['isDentalAllowedBackend'] = false;
Map<String, dynamic> payload = {
"City": selectedCity?.description,
"cityCode": selectedCity?.iD,
"Gender": selectedGender?.value,
"isDentalAllowedBackend": false
// "Gender": selectedGender?.value,
};
await bloodDonationRepo.updateBloodGroup(request: payload); await bloodDonationRepo.updateBloodGroup(request: payload);
await addUserAgreementForBloodDonation(); await addUserAgreementForBloodDonation();
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
dialogService.showSuccessBottomSheetWithoutH(message: "Blood Group Updated Successfully", onOkPressed: () {});
} }
Future<void> addUserAgreementForBloodDonation() async { Future<void> addUserAgreementForBloodDonation() async {
@ -284,10 +271,16 @@ class BloodDonationViewModel extends ChangeNotifier {
await bloodDonationRepo.addUserAgreementForBloodDonation(request: payload); await bloodDonationRepo.addUserAgreementForBloodDonation(request: payload);
} }
Future<void> getUserAgreementForBloodDonation() async {
await bloodDonationRepo.getUserAgreementForBloodDonation();
}
Future<void> fetchAllData() async { Future<void> fetchAllData() async {
LoaderBottomSheet.showLoader(loadingText: "Fetching Data..."); LoaderBottomSheet.showLoader(loadingText: "Fetching Data...");
await getRegionSelectedClinics(); await getRegionSelectedClinics();
// await getPatientBloodGroupDetails(); if (isUserAuthanticated()) {
// await getPatientBloodGroupDetails();
}
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
} }
} }

@ -58,68 +58,68 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
trailing: CustomButton( trailing: CustomButton(
text: "Book", text: "Book",
onPressed: () { onPressed: () {
// if (bloodDonationVM.isUserAuthanticated()) { if (bloodDonationVM.isUserAuthanticated()) {
bloodDonationVM.fetchHospitalsList().then((value) { bloodDonationVM.fetchHospitalsList().then((value) {
showCommonBottomSheetWithoutHeight(context, title: "Select Hospital", isDismissible: false, child: Consumer<BloodDonationViewModel>(builder: (_, data, __) { showCommonBottomSheetWithoutHeight(context, title: "Select Hospital", isDismissible: false, child: Consumer<BloodDonationViewModel>(builder: (_, data, __) {
return HospitalBottomSheetBodySelection( return HospitalBottomSheetBodySelection(
onUserHospitalSelection: (BdGetProjectsHaveBdClinic userChoice) { onUserHospitalSelection: (BdGetProjectsHaveBdClinic userChoice) {
bloodDonationVM.getFreeBloodDonationSlots(request: {"ClinicID": 134, "ProjectID": userChoice.projectId}); bloodDonationVM.getFreeBloodDonationSlots(request: {"ClinicID": 134, "ProjectID": userChoice.projectId});
}, },
); );
}), callBackFunc: () {}); }), callBackFunc: () {});
}); });
// } else { } else {
// return showCommonBottomSheetWithoutHeight( return showCommonBottomSheetWithoutHeight(
// context, context,
// title: LocaleKeys.notice.tr(context: context), title: LocaleKeys.notice.tr(context: context),
// child: Column( child: Column(
// mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
// children: [ children: [
// Lottie.asset(AppAnimations.errorAnimation, repeat: true, reverse: false, frameRate: FrameRate(60), width: 100.h, height: 100.h, fit: BoxFit.fill), Lottie.asset(AppAnimations.errorAnimation, repeat: true, reverse: false, frameRate: FrameRate(60), width: 100.h, height: 100.h, fit: BoxFit.fill),
// SizedBox(height: 8.h), SizedBox(height: 8.h),
// (LocaleKeys.loginToUseService.tr()).toText16(color: AppColors.blackColor), (LocaleKeys.loginToUseService.tr()).toText16(color: AppColors.blackColor),
// SizedBox(height: 16.h), SizedBox(height: 16.h),
// Row( Row(
// children: [ children: [
// Expanded( Expanded(
// child: CustomButton( child: CustomButton(
// text: LocaleKeys.cancel.tr(), text: LocaleKeys.cancel.tr(),
// onPressed: () { onPressed: () {
// Navigator.of(context).pop(); Navigator.of(context).pop();
// }, },
// backgroundColor: AppColors.secondaryLightRedColor, backgroundColor: AppColors.secondaryLightRedColor,
// borderColor: AppColors.secondaryLightRedColor, borderColor: AppColors.secondaryLightRedColor,
// textColor: AppColors.primaryRedColor, textColor: AppColors.primaryRedColor,
// icon: AppAssets.cancel, icon: AppAssets.cancel,
// iconColor: AppColors.primaryRedColor, iconColor: AppColors.primaryRedColor,
// ), ),
// ), ),
// SizedBox(width: 8.h), SizedBox(width: 8.h),
// Expanded( Expanded(
// child: CustomButton( child: CustomButton(
// text: LocaleKeys.confirm.tr(), text: LocaleKeys.confirm.tr(),
// onPressed: () async { onPressed: () async {
// Navigator.of(context).pop(); Navigator.of(context).pop();
// // Navigator.pushAndRemoveUntil(context, CustomPageRoute(page: LandingNavigation()), (r) => false); // Navigator.pushAndRemoveUntil(context, CustomPageRoute(page: LandingNavigation()), (r) => false);
// await getIt<AuthenticationViewModel>().onLoginPressed(); await getIt<AuthenticationViewModel>().onLoginPressed();
// }, },
// backgroundColor: AppColors.bgGreenColor, backgroundColor: AppColors.bgGreenColor,
// borderColor: AppColors.bgGreenColor, borderColor: AppColors.bgGreenColor,
// textColor: Colors.white, textColor: Colors.white,
// icon: AppAssets.confirm, icon: AppAssets.confirm,
// ), ),
// ), ),
// ], ],
// ), ),
// SizedBox(height: 16.h), SizedBox(height: 16.h),
// ], ],
// ).center, ).center,
// callBackFunc: () {}, callBackFunc: () {},
// isFullScreen: false, isFullScreen: false,
// isCloseButtonVisible: true, isCloseButtonVisible: true,
// ); );
// } }
}, },
backgroundColor: AppColors.bgRedLightColor, backgroundColor: AppColors.bgRedLightColor,
borderColor: AppColors.bgRedLightColor, borderColor: AppColors.bgRedLightColor,
@ -297,7 +297,60 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
onPressed: () async { onPressed: () async {
DialogService dialogService = getIt.get<DialogService>(); DialogService dialogService = getIt.get<DialogService>();
if (await bloodDonationVM.validateSelections()) { if (await bloodDonationVM.validateSelections()) {
bloodDonationVM.updateBloodGroup(); if (bloodDonationVM.isUserAuthanticated()) {
bloodDonationVM.updateBloodGroup();
} else {
return showCommonBottomSheetWithoutHeight(
context,
title: LocaleKeys.notice.tr(context: context),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Lottie.asset(AppAnimations.errorAnimation, repeat: true, reverse: false, frameRate: FrameRate(60), width: 100.h, height: 100.h, fit: BoxFit.fill),
SizedBox(height: 8.h),
(LocaleKeys.loginToUseService.tr()).toText16(color: AppColors.blackColor),
SizedBox(height: 16.h),
Row(
children: [
Expanded(
child: CustomButton(
text: LocaleKeys.cancel.tr(),
onPressed: () {
Navigator.of(context).pop();
},
backgroundColor: AppColors.secondaryLightRedColor,
borderColor: AppColors.secondaryLightRedColor,
textColor: AppColors.primaryRedColor,
icon: AppAssets.cancel,
iconColor: AppColors.primaryRedColor,
),
),
SizedBox(width: 8.h),
Expanded(
child: CustomButton(
text: LocaleKeys.confirm.tr(),
onPressed: () async {
Navigator.of(context).pop();
// Navigator.pushAndRemoveUntil(context, CustomPageRoute(page: LandingNavigation()), (r) => false);
await getIt<AuthenticationViewModel>().onLoginPressed();
},
backgroundColor: AppColors.bgGreenColor,
borderColor: AppColors.bgGreenColor,
textColor: Colors.white,
icon: AppAssets.confirm,
),
),
],
),
SizedBox(height: 16.h),
],
).center,
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
}
} }
}, },
backgroundColor: AppColors.primaryRedColor, backgroundColor: AppColors.primaryRedColor,

@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/route_extensions.dart'; import 'package:hmg_patient_app_new/extensions/route_extensions.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart'; import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart';
@ -23,6 +24,9 @@ abstract class DialogService {
Future<void> showCommonBottomSheetWithoutH({String? label, required String message, required Function() onOkPressed, Function()? onCancelPressed}); Future<void> showCommonBottomSheetWithoutH({String? label, required String message, required Function() onOkPressed, Function()? onCancelPressed});
Future<void> showSuccessBottomSheetWithoutH({String? label, required String message, required Function() onOkPressed, Function()? onCancelPressed});
Future<void> showFamilyBottomSheetWithoutH( Future<void> showFamilyBottomSheetWithoutH(
{String? label, {String? label,
required String message, required String message,
@ -122,6 +126,20 @@ class DialogServiceImp implements DialogService {
); );
} }
@override
Future<void> showSuccessBottomSheetWithoutH(
{String? label, required String message, required Function() onOkPressed, Function()? onCancelPressed}) async {
final context = navigationService.navigatorKey.currentContext;
if (context == null) return;
showCommonBottomSheetWithoutHeight(
context,
title: label ?? "",
child: Utils.getSuccessWidget(loadingText: message.needTranslation),
callBackFunc: () {},
);
}
@override @override
Future<void> showFamilyBottomSheetWithoutH( Future<void> showFamilyBottomSheetWithoutH(
{String? label, {String? label,
@ -256,6 +274,8 @@ Widget exceptionBottomSheetWidget(
); );
} }
Widget showPhoneNumberPickerWidget( Widget showPhoneNumberPickerWidget(
{required BuildContext context, String? message, required Function() onSMSPress, required Function() onWhatsappPress}) { {required BuildContext context, String? message, required Function() onSMSPress, required Function() onWhatsappPress}) {
return StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) { return StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save