|  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/lab/lab_repo.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_orders_response_model.dart'; | 
					
						
							|  |  |  | import 'package:hmg_patient_app_new/services/error_handler_service.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class LabViewModel extends ChangeNotifier { | 
					
						
							|  |  |  |   bool isLabOrdersLoading = false; | 
					
						
							|  |  |  |   bool isLabResultsLoading = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   LabRepo labRepo; | 
					
						
							|  |  |  |   ErrorHandlerService errorHandlerService; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   List<PatientLabOrdersResponseModel> patientLabOrders = []; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   LabViewModel({required this.labRepo, required this.errorHandlerService}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   initLabProvider() { | 
					
						
							|  |  |  |     patientLabOrders.clear(); | 
					
						
							|  |  |  |     // isLabOrdersLoading = true;
 | 
					
						
							|  |  |  |     // isLabResultsLoading = true;
 | 
					
						
							|  |  |  |     // getPatientLabOrders();
 | 
					
						
							|  |  |  |     notifyListeners(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> getPatientLabOrders({Function(dynamic)? onSuccess, Function(String)? onError}) async { | 
					
						
							|  |  |  |     final result = await labRepo.getPatientLabOrders(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) { | 
					
						
							|  |  |  |           patientLabOrders = apiResponse.data!; | 
					
						
							|  |  |  |           isLabOrdersLoading = false; | 
					
						
							|  |  |  |           isLabResultsLoading = false; | 
					
						
							|  |  |  |           notifyListeners(); | 
					
						
							|  |  |  |           if (onSuccess != null) { | 
					
						
							|  |  |  |             onSuccess(apiResponse); | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |