diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index 20bb8ce4..d8ba32a5 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -211,7 +211,7 @@ class ApiClientImp implements ApiClient { } // body['TokenID'] = "@dm!n"; - // body['PatientID'] = 1307867; + // body['PatientID'] = 226077; // body['PatientID'] = 53320; // body['PatientTypeID'] = 1; // body['PatientOutSA'] = 0; diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index 39558844..fef90e8f 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -48,7 +48,6 @@ class ApiConsts { switch (appEnvironmentType) { case AppEnvironmentTypeEnum.prod: baseUrl = "https://hmgwebservices.com/"; - // baseUrl = "http://10.200.204.42/"; payFortEnvironment = FortEnvironment.production; payFortEnvironmentType = EnvironmentType.production; applePayMerchantId = "merchant.com.hmgwebservices"; diff --git a/lib/features/habib_wallet/habib_wallet_view_model.dart b/lib/features/habib_wallet/habib_wallet_view_model.dart index e888600a..21ec0e79 100644 --- a/lib/features/habib_wallet/habib_wallet_view_model.dart +++ b/lib/features/habib_wallet/habib_wallet_view_model.dart @@ -31,6 +31,7 @@ class HabibWalletViewModel extends ChangeNotifier { num walletRechargeAmount = 0; String notesText = ""; bool isWalletAmountToBeLoaded = false; + bool isLakumInfoToBeLoaded = false; // ── Balance visibility (show/hide like a password field) ────────────────── bool isWalletAmountHidden = true; @@ -55,7 +56,7 @@ class HabibWalletViewModel extends ChangeNotifier { notifyListeners(); // On first unhide, fetch the data if not already fetched. if (!isLakumPointsHidden && !isLakumInfoFetched) { - isWalletAmountToBeLoaded = true; + isLakumInfoToBeLoaded = true; getLakumAccountInformation(); } } @@ -358,6 +359,8 @@ class HabibWalletViewModel extends ChangeNotifier { if (isWalletAmountToBeLoaded) { isWalletAmountLoading = true; habibWalletAmount = 0; + } + if (isLakumInfoToBeLoaded) { isLakumAccountInfoLoading = true; yahalaAccountNumber = ""; } @@ -429,6 +432,11 @@ class HabibWalletViewModel extends ChangeNotifier { notifyListeners(); } + setIsLakumInfoToBeLoaded(bool value) { + isLakumInfoToBeLoaded = value; + notifyListeners(); + } + String getSelectedRechargeTypeValue() { switch (selectedRechargeType) { case 1: @@ -571,7 +579,7 @@ class HabibWalletViewModel extends ChangeNotifier { } Future getLakumAccountInformation({Function(dynamic)? onSuccess, Function(String)? onError}) async { - if (!isWalletAmountToBeLoaded) { + if (!isLakumInfoToBeLoaded) { return; } @@ -586,6 +594,8 @@ class HabibWalletViewModel extends ChangeNotifier { (failure) async { yahalaAccountNumber = "0"; isLakumAccountInfoLoading = false; + isLakumInfoFetched = true; + isLakumInfoToBeLoaded = false; notifyListeners(); // 675534 }, (apiResponse) async { @@ -613,6 +623,7 @@ class HabibWalletViewModel extends ChangeNotifier { } isLakumAccountInfoLoading = false; isLakumInfoFetched = true; + isLakumInfoToBeLoaded = false; notifyListeners(); if (onSuccess != null) { onSuccess(apiResponse); diff --git a/lib/features/insurance/insurance_repo.dart b/lib/features/insurance/insurance_repo.dart index 2719035b..0a0ee0be 100644 --- a/lib/features/insurance/insurance_repo.dart +++ b/lib/features/insurance/insurance_repo.dart @@ -11,7 +11,7 @@ import 'package:hmg_patient_app_new/features/insurance/models/resp_models/upload import 'package:hmg_patient_app_new/services/logger_service.dart'; abstract class InsuranceRepo { - Future>>> getPatientInsuranceDetails(); + Future>>> getPatientInsuranceDetails({bool isFromHomePage = false}); Future>>> getPatientInsuranceCardHistory(); @@ -35,8 +35,10 @@ class InsuranceRepoImp implements InsuranceRepo { InsuranceRepoImp({required this.loggerService, required this.apiClient}); @override - Future>>> getPatientInsuranceDetails() async { - Map mapDevice = {}; + Future>>> getPatientInsuranceDetails({bool isFromHomePage = false}) async { + Map mapDevice = { + "IsFromHomePage": isFromHomePage + }; try { GenericApiModel>? apiResponse; diff --git a/lib/features/insurance/insurance_view_model.dart b/lib/features/insurance/insurance_view_model.dart index 2422920a..caeba030 100644 --- a/lib/features/insurance/insurance_view_model.dart +++ b/lib/features/insurance/insurance_view_model.dart @@ -32,11 +32,11 @@ class InsuranceViewModel extends ChangeNotifier { InsuranceViewModel({required this.insuranceRepo, required this.errorHandlerService}); - initInsuranceProvider() { + initInsuranceProvider({bool isFromHomePage = false}) { if (isInsuranceDataToBeLoaded) { patientInsuranceList.clear(); isInsuranceLoading = true; - getPatientInsuranceDetails(); + getPatientInsuranceDetails(isFromHomePage: isFromHomePage); } patientInsuranceCardHistoryList.clear(); isInsuranceHistoryLoading = true; @@ -76,12 +76,12 @@ class InsuranceViewModel extends ChangeNotifier { notifyListeners(); } - Future getPatientInsuranceDetails({Function(dynamic)? onSuccess, Function(String)? onError}) async { + Future getPatientInsuranceDetails({bool isFromHomePage = false, Function(dynamic)? onSuccess, Function(String)? onError}) async { if (!isInsuranceDataToBeLoaded) { return; } - final result = await insuranceRepo.getPatientInsuranceDetails(); + final result = await insuranceRepo.getPatientInsuranceDetails(isFromHomePage: isFromHomePage); result.fold( // (failure) async => await errorHandlerService.handleError(failure: failure), diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index 367a9b51..fdb8afcf 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -172,7 +172,10 @@ class _LandingPageState extends State { emergencyServicesViewModel.checkPatientERAdvanceBalance(); // myAppointmentsViewModel.getPatientAppointmentQueueDetails(); notificationsViewModel.initNotificationsViewModel(); - insuranceViewModel.initInsuranceProvider(); + + if (Utils.havePrivilege(122)) { + insuranceViewModel.initInsuranceProvider(isFromHomePage: true); + } if (!appState.isRatedVisible) { appointmentRatingViewModel.getLastRatingAppointment( diff --git a/lib/presentation/medical_file/medical_file_page.dart b/lib/presentation/medical_file/medical_file_page.dart index a3de6c08..27978723 100644 --- a/lib/presentation/medical_file/medical_file_page.dart +++ b/lib/presentation/medical_file/medical_file_page.dart @@ -110,7 +110,7 @@ class _MedicalFilePageState extends State { appState = getIt.get(); scheduleMicrotask(() { if (appState.isAuthenticated) { - insuranceViewModel.initInsuranceProvider(); + // insuranceViewModel.initInsuranceProvider(); // Load vital signs hmgServicesViewModel.getPatientVitalSign(); @@ -495,6 +495,9 @@ class _MedicalFilePageState extends State { medicalFileViewModel.setIsPatientMedicalReportsLoading(true); medicalFileViewModel.getPatientMedicalReportList(); } + if (index == 2 && isExpanded) { + insuranceViewModel.initInsuranceProvider(); + } }, items: [ ExpandableListItem( diff --git a/lib/widgets/app_language_change.dart b/lib/widgets/app_language_change.dart index c2ae0272..7810457b 100644 --- a/lib/widgets/app_language_change.dart +++ b/lib/widgets/app_language_change.dart @@ -76,6 +76,7 @@ class _AppLanguageChangeState extends State { myAppointmentsViewModel.getPatientAppointments(true, false); habibWalletVM.setIsWalletAmountToBeLoaded(true); + habibWalletVM.setIsLakumInfoToBeLoaded(true); habibWalletVM.initHabibWalletProvider(); habibWalletVM.getPatientBalanceAmount(); habibWalletVM.getLakumAccountInformation();