lab result changes
							parent
							
								
									e044fc8c5e
								
							
						
					
					
						commit
						a77fc49c68
					
				| @ -1,9 +1,59 @@ | ||||
| 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/exceptions/api_failure.dart'; | ||||
| import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart'; | ||||
| import 'package:dartz/dartz.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/logger_service.dart'; | ||||
| 
 | ||||
| abstract class AuthenticationRepo { | ||||
|   Future<Either<Failure, GenericApiModel<dynamic>>> getPatientLabOrders({ | ||||
|     required String firebaseToken, | ||||
|   }); | ||||
| abstract class LabRepo { | ||||
|   Future<Either<Failure, GenericApiModel<List<PatientLabOrdersResponseModel>>>> getPatientLabOrders({required num patientId}); | ||||
| } | ||||
| 
 | ||||
| class LabRepoImp implements LabRepo { | ||||
|   final ApiClient apiClient; | ||||
|   final LoggerService loggerService; | ||||
| 
 | ||||
|   LabRepoImp({required this.loggerService, required this.apiClient}); | ||||
| 
 | ||||
|   @override | ||||
|   Future<Either<Failure, GenericApiModel<List<PatientLabOrdersResponseModel>>>> getPatientLabOrders({required num patientId}) async { | ||||
|     final mapDevice = {"PatientID": patientId}; | ||||
| 
 | ||||
|     try { | ||||
|       GenericApiModel<List<PatientLabOrdersResponseModel>>? apiResponse; | ||||
|       Failure? failure; | ||||
|       await apiClient.post( | ||||
|         GET_Patient_LAB_ORDERS, | ||||
|         body: mapDevice, | ||||
|         onFailure: (error, statusCode, {messageStatus, failureType}) { | ||||
|           failure = failureType; | ||||
|         }, | ||||
|         onSuccess: (response, statusCode, {messageStatus}) { | ||||
|           try { | ||||
|             final list = response['ListPLO']; | ||||
|             if (list == null || list.isEmpty) { | ||||
|               throw Exception("lab list is empty"); | ||||
|             } | ||||
| 
 | ||||
|             final labOrders = list.map((item) => PatientLabOrdersResponseModel.fromJson(item as Map<String, dynamic>)).toList(); | ||||
| 
 | ||||
|             apiResponse = GenericApiModel<List<PatientLabOrdersResponseModel>>( | ||||
|               messageStatus: messageStatus, | ||||
|               statusCode: statusCode, | ||||
|               errorMessage: null, | ||||
|               data: labOrders, | ||||
|             ); | ||||
|           } 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())); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -1,13 +1,45 @@ | ||||
| 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() { | ||||
|     isLabOrdersLoading = true; | ||||
|     isLabResultsLoading = true; | ||||
|     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); | ||||
|           } | ||||
|         } | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,126 @@ | ||||
| class PatientLabOrdersResponseModel { | ||||
|   String? description; | ||||
|   dynamic femaleInterpretativeData; | ||||
|   int? gender; | ||||
|   bool? isCertificateAllowed; | ||||
|   int? lineItemNo; | ||||
|   dynamic maleInterpretativeData; | ||||
|   dynamic notes; | ||||
|   int? orderLineItemNo; | ||||
|   int? orderNo; | ||||
|   String? packageID; | ||||
|   int? patientID; | ||||
|   String? projectID; | ||||
|   String? referanceRange; | ||||
|   String? resultValue; | ||||
|   int? resultValueBasedLineItemNo; | ||||
|   String? resultValueFlag; | ||||
|   String? sampleCollectedOn; | ||||
|   String? sampleReceivedOn; | ||||
|   String? setupID; | ||||
|   dynamic superVerifiedOn; | ||||
|   String? testCode; | ||||
|   String? uOM; | ||||
|   String? verifiedOn; | ||||
|   String? packageShortDescription; | ||||
|   String? testShortDescription; | ||||
|   dynamic verifiedOnDateTime; | ||||
|   num? percentage; | ||||
|   num? width; | ||||
|   num? resultTypeID; | ||||
| 
 | ||||
|   PatientLabOrdersResponseModel( | ||||
|       {this.description, | ||||
|       this.femaleInterpretativeData, | ||||
|       this.gender, | ||||
|       this.isCertificateAllowed, | ||||
|       this.lineItemNo, | ||||
|       this.maleInterpretativeData, | ||||
|       this.notes, | ||||
|       this.orderLineItemNo, | ||||
|       this.orderNo, | ||||
|       this.packageID, | ||||
|       this.patientID, | ||||
|       this.projectID, | ||||
|       this.referanceRange, | ||||
|       this.resultValue, | ||||
|       this.resultValueBasedLineItemNo, | ||||
|       this.resultValueFlag, | ||||
|       this.sampleCollectedOn, | ||||
|       this.sampleReceivedOn, | ||||
|       this.setupID, | ||||
|       this.superVerifiedOn, | ||||
|       this.testCode, | ||||
|       this.uOM, | ||||
|       this.verifiedOn, | ||||
|       this.verifiedOnDateTime}); | ||||
| 
 | ||||
|   PatientLabOrdersResponseModel.fromJson(Map<String, dynamic> json, {String? flag}) { | ||||
|     description = json['Description']; | ||||
|     femaleInterpretativeData = json['FemaleInterpretativeData']; | ||||
|     gender = json['Gender']; | ||||
|     isCertificateAllowed = json['IsCertificateAllowed']; | ||||
|     lineItemNo = json['LineItemNo']; | ||||
|     maleInterpretativeData = json['MaleInterpretativeData']; | ||||
|     notes = json['Notes']; | ||||
|     orderLineItemNo = json['OrderLineItemNo']; | ||||
|     orderNo = json['OrderNo']; | ||||
|     packageID = json['PackageID']; | ||||
|     patientID = json['PatientID']; | ||||
|     projectID = json['ProjectID']; | ||||
|     referanceRange = json['ReferanceRange']; | ||||
|     resultValue = json['ResultValue']; | ||||
|     resultValueBasedLineItemNo = json['ResultValueBasedLineItemNo']; | ||||
|     resultValueFlag = json['ResultValueFlag']; | ||||
|     sampleCollectedOn = json['SampleCollectedOn']; | ||||
|     sampleReceivedOn = json['SampleReceivedOn']; | ||||
|     setupID = json['SetupID']; | ||||
|     superVerifiedOn = json['SuperVerifiedOn']; | ||||
|     testCode = json['TestCode']; | ||||
|     uOM = json['UOM']; | ||||
|     verifiedOn = json['VerifiedOn']; | ||||
|     verifiedOnDateTime = json['VerifiedOnDateTime']; | ||||
|     packageShortDescription = json['PackageShortDescription']; | ||||
|     testShortDescription = json['TestShortDescription']; | ||||
|     resultTypeID = json['ResultTypeID']; | ||||
|   } | ||||
| 
 | ||||
|   Map<String, dynamic> toJson() { | ||||
|     final Map<String, dynamic> data = new Map<String, dynamic>(); | ||||
|     data['Description'] = this.description; | ||||
|     data['FemaleInterpretativeData'] = this.femaleInterpretativeData; | ||||
|     data['Gender'] = this.gender; | ||||
|     data['IsCertificateAllowed'] = this.isCertificateAllowed; | ||||
|     data['LineItemNo'] = this.lineItemNo; | ||||
|     data['MaleInterpretativeData'] = this.maleInterpretativeData; | ||||
|     data['Notes'] = this.notes; | ||||
|     data['OrderLineItemNo'] = this.orderLineItemNo; | ||||
|     data['OrderNo'] = this.orderNo; | ||||
|     data['PackageID'] = this.packageID; | ||||
|     data['PatientID'] = this.patientID; | ||||
|     data['ProjectID'] = this.projectID; | ||||
|     data['ReferanceRange'] = this.referanceRange; | ||||
|     data['ResultValue'] = this.resultValue; | ||||
|     data['ResultValueBasedLineItemNo'] = this.resultValueBasedLineItemNo; | ||||
|     data['ResultValueFlag'] = this.resultValueFlag; | ||||
|     data['SampleCollectedOn'] = this.sampleCollectedOn; | ||||
|     data['SampleReceivedOn'] = this.sampleReceivedOn; | ||||
|     data['SetupID'] = this.setupID; | ||||
|     data['SuperVerifiedOn'] = this.superVerifiedOn; | ||||
|     data['TestCode'] = this.testCode; | ||||
|     data['UOM'] = this.uOM; | ||||
|     data['VerifiedOn'] = this.verifiedOn; | ||||
|     data['VerifiedOnDateTime'] = this.verifiedOnDateTime; | ||||
|     data['PackageShortDescription'] = this.packageShortDescription; | ||||
|     data['TestShortDescription'] = this.testShortDescription; | ||||
| 
 | ||||
|     return data; | ||||
|   } | ||||
| 
 | ||||
|   bool shouldShowResultBarAndGraph() { | ||||
|     if (resultTypeID == null) return false; | ||||
|     if (resultTypeID == 6) return false; | ||||
| 
 | ||||
|     return true; | ||||
|   } | ||||
| } | ||||
| @ -1,12 +0,0 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| 
 | ||||
| class BottomNavigationProvider extends ChangeNotifier { | ||||
|   int _currentIndex = 0; | ||||
| 
 | ||||
|   int get currentIndex => _currentIndex; | ||||
| 
 | ||||
|   void setIndex(int index) { | ||||
|     _currentIndex = index; | ||||
|     notifyListeners(); | ||||
|   } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue
	
	 Haroon Amjad
						Haroon Amjad