You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			44 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Dart
		
	
		
		
			
		
	
	
			44 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Dart
		
	
| 
											2 months ago
										 | import 'package:flutter/material.dart'; | ||
|  | import 'package:hmg_patient_app_new/features/insurance/insurance_repo.dart'; | ||
|  | import 'package:hmg_patient_app_new/features/insurance/models/resp_models/patient_insurance_details_response_model.dart'; | ||
|  | import 'package:hmg_patient_app_new/features/lab/lab_repo.dart'; | ||
|  | import 'package:hmg_patient_app_new/services/error_handler_service.dart'; | ||
|  | 
 | ||
|  | class InsuranceViewModel extends ChangeNotifier { | ||
|  |   bool isInsuranceLoading = false; | ||
|  | 
 | ||
|  |   InsuranceRepo insuranceRepo; | ||
|  |   ErrorHandlerService errorHandlerService; | ||
|  | 
 | ||
|  |   List<PatientInsuranceDetailsResponseModel> patientInsuranceList = []; | ||
|  | 
 | ||
|  |   InsuranceViewModel({required this.insuranceRepo, required this.errorHandlerService}); | ||
|  | 
 | ||
|  |   initInsuranceProvider() { | ||
|  |     patientInsuranceList.clear(); | ||
|  |     isInsuranceLoading = true; | ||
|  |     getPatientInsuranceDetails(); | ||
|  |     notifyListeners(); | ||
|  |   } | ||
|  | 
 | ||
|  |   Future<void> getPatientInsuranceDetails({Function(dynamic)? onSuccess, Function(String)? onError}) async { | ||
|  |     final result = await insuranceRepo.getPatientInsuranceDetails(patientId: "1231755"); | ||
|  | 
 | ||
|  |     result.fold( | ||
|  |       (failure) async => await errorHandlerService.handleError(failure: failure), | ||
|  |       (apiResponse) { | ||
|  |         if (apiResponse.messageStatus == 2) { | ||
|  |           // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
 | ||
|  |         } else if (apiResponse.messageStatus == 1) { | ||
|  |           patientInsuranceList = apiResponse.data!; | ||
|  |           isInsuranceLoading = false; | ||
|  |           notifyListeners(); | ||
|  |           if (onSuccess != null) { | ||
|  |             onSuccess(apiResponse); | ||
|  |           } | ||
|  |         } | ||
|  |       }, | ||
|  |     ); | ||
|  |   } | ||
|  | } |