feat(patient): implement doctor-only patient deletion, alert theme styling, and test auto-cleanup

This commit is contained in:
=
2026-09-22 13:41:14 -04:00
parent 73b69722a0
commit 654a7f402d
10 changed files with 616 additions and 16 deletions
@@ -23,6 +23,9 @@ abstract class _PatientStoreBase with Store {
@observable
bool isSaving = false;
@observable
bool isDeleting = false;
@observable
String? errorMessage;
@@ -185,6 +188,7 @@ abstract class _PatientStoreBase with Store {
successMessage = null;
isLoading = false;
isSaving = false;
isDeleting = false;
final now = DateTime.now();
fecReg = DateFormat('dd/MM/yyyy').format(now);
@@ -391,4 +395,31 @@ abstract class _PatientStoreBase with Store {
return false;
}
}
@action
Future<bool> deletePatient() async {
if (id == null) {
errorMessage = 'No se puede eliminar un paciente que no ha sido guardado.';
return false;
}
isDeleting = true;
errorMessage = null;
successMessage = null;
try {
await service.deletePatient(id!);
runInAction(() {
isDeleting = false;
successMessage = 'Paciente eliminado exitosamente';
});
return true;
} catch (e) {
runInAction(() {
errorMessage = e.toString().replaceAll('Exception: ', '');
isDeleting = false;
});
return false;
}
}
}