CR Implementation contd.

CR-19328-LiveCare-Enhancements
haroon amjad 2 weeks ago
parent 31ed9483ad
commit ca71ff08e3

@ -3,7 +3,9 @@ import 'dart:io';
import 'package:dartz/dartz.dart';
import 'package:hmg_patient_app_new/core/api/api_client.dart';
import 'package:hmg_patient_app_new/core/api_consts.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart';
import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart';
import 'package:hmg_patient_app_new/features/immediate_livecare/models/resp_models/get_livecare_clinic_schedule_response_model.dart';
import 'package:hmg_patient_app_new/features/immediate_livecare/models/resp_models/get_livecare_immediate_clinics_response_model.dart';
@ -11,6 +13,8 @@ import 'package:hmg_patient_app_new/features/immediate_livecare/models/resp_mode
import 'package:hmg_patient_app_new/features/immediate_livecare/models/resp_models/get_patient_livecare_history_response_model.dart';
import 'package:hmg_patient_app_new/services/logger_service.dart';
import '../../core/dependencies.dart';
abstract class ImmediateLiveCareRepo {
Future<Either<Failure, GenericApiModel<List<GetLiveCareClinicListResponseModel>>>> getLiveCareImmediateClinicsList(int age, int genderID, {Function(dynamic)? onSuccess, Function(String)? onError});
@ -28,6 +32,9 @@ abstract class ImmediateLiveCareRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> addInsuranceUpdateRequestForLiveCare(String name, String mobileNumber, String fileNumber,
{Function(dynamic)? onSuccess, Function(String)? onError});
Future<Either<Failure, GenericApiModel<dynamic>>> rescheduleLiveCareCallRequest(int callID, int serviceID, String consultationTime, bool isRescheduledForOneHourLater,
{Function(dynamic)? onSuccess, Function(String)? onError});
}
class ImmediateLiveCareRepoImp implements ImmediateLiveCareRepo {
@ -292,4 +299,51 @@ class ImmediateLiveCareRepoImp implements ImmediateLiveCareRepo {
return Left(UnknownFailure(e.toString()));
}
}
@override
Future<Either<Failure, GenericApiModel>> rescheduleLiveCareCallRequest(int callID, int serviceID, String consultationTime, bool isRescheduledForOneHourLater,
{Function(dynamic p1)? onSuccess, Function(String p1)? onError}) async {
Map<String, dynamic> mapDevice = {
"VCID": callID,
"UserID": getIt.get<AppState>().getAuthenticatedUser()!.patientId,
"ServiceID": serviceID,
"consultationTime": consultationTime,
"Notes": isRescheduledForOneHourLater ? "Rescheduled by user for 1 hour later" : "Rescheduled by user for 30 mins later",
"ProjectID": getIt.get<AppState>().getAuthenticatedUser()!.outSa! == 0
? ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat
? 15
: 12
: 2,
};
try {
GenericApiModel<dynamic>? apiResponse;
Failure? failure;
await apiClient.post(
RESCHEDULE_LIVECARE_CALL,
body: mapDevice,
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
// onError!(error);
},
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
apiResponse = GenericApiModel<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()));
}
}
}

@ -366,6 +366,30 @@ class ImmediateLiveCareViewModel extends ChangeNotifier {
);
}
Future<void> rescheduleLiveCareCallRequest(
{int? callID, int? serviceID, String? consultationTime, bool? isRescheduledForOneHourLater, Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await immediateLiveCareRepo.rescheduleLiveCareCallRequest(callID!, serviceID!, consultationTime!, isRescheduledForOneHourLater!);
result.fold(
// (failure) async => await errorHandlerService.handleError(failure: failure),
(failure) async {
if (onError != null) {
onError(failure.message);
}
},
(apiResponse) {
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
notifyListeners();
if (onSuccess != null) {
onSuccess(apiResponse);
}
}
},
);
}
void startTimer() {
// Only start timer if it's not already active
if (timer == null || !timer!.isActive) {

@ -20,6 +20,7 @@ import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
import 'package:hmg_patient_app_new/widgets/countdown_timer.dart';
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
import 'package:lottie/lottie.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
@ -203,8 +204,36 @@ class _ImmediateLiveCarePendingRequestPageState extends State<ImmediateLiveCareP
CustomButton(
text: LocaleKeys.cantWaitLiveCare.tr(context: context),
onPressed: () {
showCommonBottomSheetWithoutHeight(context,
child: LiveCareRescheduleWidget(), callBackFunc: () async {}, title: LocaleKeys.whenCallBackLiveCare.tr(context: context), isCloseButtonVisible: true, isFullScreen: false);
showCommonBottomSheetWithoutHeight(context, child: LiveCareRescheduleWidget(), callBackFunc: (val) async {
if (val != null) {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.reschedulingAppo.tr(context: context));
String rescheduleDateTime = "";
if (val == "30") {
rescheduleDateTime = DateUtil.convertDateToString(DateTime.now().add(Duration(minutes: 30)));
}
if (val == "60") {
rescheduleDateTime = DateUtil.convertDateToString(DateTime.now().add(Duration(minutes: 60)));
}
immediateLiveCareVM.rescheduleLiveCareCallRequest(
callID: immediateLiveCareViewModel.patientLiveCareHistoryList.first.vCID,
serviceID: immediateLiveCareViewModel.patientLiveCareHistoryList.first.serviceID,
consultationTime: rescheduleDateTime,
isRescheduledForOneHourLater: val == "30" ? false : true,
onSuccess: (val) {
LoaderBottomSheet.hideLoader();
},
onError: (err) {
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight(context,
child: Utils.getErrorWidget(loadingText: err.toString()),
callBackFunc: () {},
title: "",
isCloseButtonVisible: true,
isDismissible: true,
isFullScreen: false);
});
}
}, title: LocaleKeys.whenCallBackLiveCare.tr(context: context), isCloseButtonVisible: true, isFullScreen: false, isDismissible: true);
},
backgroundColor: AppColors.warningColorYellow.withValues(alpha: 0.20),
borderColor: AppColors.warningColorYellow.withValues(alpha: 0.01),

@ -27,7 +27,7 @@ class LiveCareRescheduleWidget extends StatelessWidget {
LocaleKeys.after30MinsDesc.tr(context: context),
// "Call for immediate assistance",
).onPress(() {
Navigator.of(context).pop();
Navigator.of(context).pop("30");
}),
SizedBox(height: 16.h),
checkInOptionCard(
@ -35,7 +35,7 @@ class LiveCareRescheduleWidget extends StatelessWidget {
LocaleKeys.after1Hour.tr(context: context),
LocaleKeys.after1HourDesc.tr(context: context),
).onPress(() async {
Navigator.of(context).pop();
Navigator.of(context).pop("60");
}),
SizedBox(height: 16.h),
],

@ -237,7 +237,7 @@ class ButtonSheetContent extends StatelessWidget {
void showCommonBottomSheetWithoutHeight(
BuildContext context, {
required Widget child,
VoidCallback? callBackFunc,
Function? callBackFunc,
String title = "",
bool isConfirmButton = false,
bool isCloseButtonVisible = true,
@ -339,7 +339,7 @@ void showCommonBottomSheetWithoutHeight(
},
).then((value) {
if (callBackFunc != null) {
callBackFunc();
callBackFunc(value);
}
});
}

Loading…
Cancel
Save