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.5 KiB
Dart
44 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hmg_patient_app_new/features/radiology/radiology_repo.dart';
|
|
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
|
|
|
|
import 'models/resp_models/patient_radiology_response_model.dart';
|
|
|
|
class RadiologyViewModel extends ChangeNotifier {
|
|
bool isRadiologyOrdersLoading = false;
|
|
|
|
RadiologyRepo radiologyRepo;
|
|
ErrorHandlerService errorHandlerService;
|
|
|
|
List<PatientRadiologyResponseModel> patientRadiologyOrders = [];
|
|
|
|
RadiologyViewModel({required this.radiologyRepo, required this.errorHandlerService});
|
|
|
|
initRadiologyProvider() {
|
|
patientRadiologyOrders.clear();
|
|
isRadiologyOrdersLoading = true;
|
|
getPatientRadiologyOrders();
|
|
notifyListeners();
|
|
}
|
|
|
|
Future<void> getPatientRadiologyOrders({Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
final result = await radiologyRepo.getPatientRadiologyOrders(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) {
|
|
patientRadiologyOrders = apiResponse.data!;
|
|
isRadiologyOrdersLoading = false;
|
|
notifyListeners();
|
|
if (onSuccess != null) {
|
|
onSuccess(apiResponse);
|
|
}
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|