|
|
|
|
@ -29,7 +29,11 @@ class MedicalFileViewModel extends ChangeNotifier {
|
|
|
|
|
bool isPatientSickLeavePDFLoading = false;
|
|
|
|
|
bool isPatientMedicalReportsListLoading = false;
|
|
|
|
|
bool isPatientAllergiesListLoading = false;
|
|
|
|
|
bool _isFamilyFilesLoading = false;
|
|
|
|
|
|
|
|
|
|
bool get isFamilyFilesLoading => _isFamilyFilesLoading;
|
|
|
|
|
|
|
|
|
|
set setIsFamilyFilesLoading(bool value) => _isFamilyFilesLoading = value;
|
|
|
|
|
MedicalFileRepo medicalFileRepo;
|
|
|
|
|
ErrorHandlerService errorHandlerService;
|
|
|
|
|
|
|
|
|
|
@ -431,6 +435,9 @@ class MedicalFileViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getFamilyFiles({int? status, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
|
|
|
|
|
setIsFamilyFilesLoading = true;
|
|
|
|
|
|
|
|
|
|
final shouldShowLoader = patientFamilyFiles.isEmpty;
|
|
|
|
|
if (shouldShowLoader) {
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
|
@ -439,24 +446,31 @@ class MedicalFileViewModel extends ChangeNotifier {
|
|
|
|
|
final result = await medicalFileRepo.getPatientFamilyFiles(status, _appState.getSuperUserID != null ? _appState.getSuperUserID! : _appState.getAuthenticatedUser()!.patientId!);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async => await errorHandlerService.handleError(
|
|
|
|
|
failure: failure,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
if (shouldShowLoader) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
}
|
|
|
|
|
onError!(failure.message);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
(failure) async {
|
|
|
|
|
|
|
|
|
|
setIsFamilyFilesLoading = false;
|
|
|
|
|
|
|
|
|
|
await errorHandlerService.handleError(
|
|
|
|
|
failure: failure,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
if (shouldShowLoader) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
}
|
|
|
|
|
onError!(failure.message);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
(apiResponse) {
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
|
|
|
|
|
setIsFamilyFilesLoading = false;
|
|
|
|
|
|
|
|
|
|
// _dialogService.showErrorBottomSheet(message: apiResponse.errorMessage!, onOkPressed: () {});
|
|
|
|
|
if (shouldShowLoader) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
}
|
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
|
if (apiResponse.data != null) {
|
|
|
|
|
// Add current user as the first active family file
|
|
|
|
|
final currentUser = _appState.getAuthenticatedUser()!;
|
|
|
|
|
final currentUserFamilyFile = FamilyFileResponseModelLists(
|
|
|
|
|
patientId: currentUser.patientId,
|
|
|
|
|
@ -536,6 +550,9 @@ class MedicalFileViewModel extends ChangeNotifier {
|
|
|
|
|
pendingFamilyFiles = newPendingFamilyFiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clear loading state on success
|
|
|
|
|
setIsFamilyFilesLoading = false;
|
|
|
|
|
|
|
|
|
|
if (shouldShowLoader) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
}
|
|
|
|
|
|