@ -1,6 +1,9 @@
import ' package:easy_localization/easy_localization.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:get_it/get_it.dart ' ;
import ' package:hmg_patient_app_new/core/app_state.dart ' ;
import ' package:hmg_patient_app_new/core/utils/date_util.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/features/my_appointments/models/appointemnet_filters.dart ' ;
import ' package:hmg_patient_app_new/features/my_appointments/models/resp_models/ask_doctor_request_type_response_model.dart ' ;
@ -10,7 +13,13 @@ import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/
import ' package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_queue_details_response_model.dart ' ;
import ' package:hmg_patient_app_new/features/my_appointments/my_appointments_repo.dart ' ;
import ' package:hmg_patient_app_new/features/my_appointments/utils/appointment_type.dart ' ;
import ' package:hmg_patient_app_new/generated/locale_keys.g.dart ' ;
import ' package:hmg_patient_app_new/presentation/insurance/insurance_home_page.dart ' ;
import ' package:hmg_patient_app_new/services/error_handler_service.dart ' ;
import ' package:hmg_patient_app_new/services/navigation_service.dart ' ;
import ' package:hmg_patient_app_new/widgets/common_bottom_sheet.dart ' ;
import ' package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart ' ;
import ' package:hmg_patient_app_new/widgets/routes/custom_page_route.dart ' ;
class MyAppointmentsViewModel extends ChangeNotifier {
int selectedTabIndex = 0 ;
@ -73,6 +82,9 @@ class MyAppointmentsViewModel extends ChangeNotifier {
GetTamaraInstallmentsDetailsResponseModel ? getTamaraInstallmentsDetailsResponseModel ;
bool isTamaraDetailsLoading = false ;
bool isShowNotEligibleDialog = false ;
String notEligibleErrorMsg = " " ;
MyAppointmentsViewModel ( { required this . myAppointmentsRepo , required this . errorHandlerService , required this . appState } ) ;
void onTabChange ( int index ) {
@ -141,6 +153,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
isTamaraDetailsLoading = true ;
isAppointmentPatientShareLoading = true ;
isEyeMeasurementsAppointmentsLoading = true ;
isShowNotEligibleDialog = false ;
notifyListeners ( ) ;
}
@ -349,7 +362,99 @@ class MyAppointmentsViewModel extends ChangeNotifier {
/ / dialogService . showErrorDialog ( message: apiResponse . errorMessage ! , onOkPressed: ( ) { } ) ;
} else if ( apiResponse . messageStatus = = 1 ) {
patientAppointmentShareResponseModel = apiResponse . data ! ;
if ( ( patientAppointmentShareResponseModel ! . isCash ! ) ) {
isShowNotEligibleDialog = false ;
} else {
if ( patientAppointmentShareResponseModel ! . isInsured ! & & patientAppointmentShareResponseModel ! . isEligible ! ) {
isShowNotEligibleDialog = false ;
} else {
if ( patientAppointmentShareResponseModel ! . isInsured ! & & patientAppointmentShareResponseModel ! . isEligible ! ) {
isShowNotEligibleDialog = true ;
notEligibleErrorMsg = LocaleKeys . invalidEligibility . tr ( context: GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ;
} else {
isShowNotEligibleDialog = true ;
notEligibleErrorMsg = LocaleKeys . invalidInsurance . tr ( context: GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ;
}
}
}
isAppointmentPatientShareLoading = false ;
if ( isShowNotEligibleDialog ) {
showCommonBottomSheetWithoutHeight ( GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ,
child: Padding (
padding: EdgeInsets . only (
left: 24. w ,
top: 24. h ,
right: 24. w ,
bottom: 12. h ,
) ,
child: Utils . getWarningWidget (
loadingText: notEligibleErrorMsg ,
confirmText: LocaleKeys . updateInsuranceInfo . tr ( context: GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ,
cancelText: LocaleKeys . continueCash . tr ( context: GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ,
isShowActionButtons: true ,
onCancelTap: ( ) {
Navigator . pop ( GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ;
LoaderBottomSheet . showLoader ( ) ;
convertPatientToCash (
projectID: projectID ,
onSuccess: ( val ) {
LoaderBottomSheet . hideLoader ( ) ;
setIsPatientAppointmentShareLoading ( true ) ;
getPatientShareAppointment ( projectID , clinicID , appointmentNo , isLiveCareAppointment ) ;
} ,
onError: ( err ) {
LoaderBottomSheet . hideLoader ( ) ;
showCommonBottomSheetWithoutHeight (
title: LocaleKeys . notice . tr ( context: GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ,
GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ,
child: Utils . getErrorWidget ( loadingText: err . toString ( ) ) ,
callBackFunc: ( ) {
Navigator . pop ( GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ;
Navigator . pop ( GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ;
} ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ) ;
} ,
onConfirmTap: ( ) async {
Navigator . pop ( GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ;
Navigator . pop ( GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ;
Navigator . push (
GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ,
CustomPageRoute (
page: InsuranceHomePage ( ) ,
) ,
) ;
} ) ,
) , callBackFunc: ( ) {
/ / Navigator . pop ( GetIt . instance < NavigationService > ( ) . navigatorKey . currentContext ! ) ;
} , isFullScreen: false , isCloseButtonVisible: false , isDismissible: false ) ;
}
notifyListeners ( ) ;
if ( onSuccess ! = null ) {
onSuccess ( apiResponse ) ;
}
}
} ,
) ;
}
Future < void > convertPatientToCash ( { required int projectID , Function ( dynamic ) ? onSuccess , Function ( String ) ? onError } ) async {
final result = await myAppointmentsRepo . convertPatientToCash ( projectID: projectID ) ;
result . fold (
/ / ( failure ) async = > await errorHandlerService . handleError ( failure: failure ) ,
( failure ) async {
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 ) ;