|
|
|
|
@ -56,6 +56,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
bool isAppointmentDataToBeLoaded = true;
|
|
|
|
|
bool isMyDoctorsDataToBeLoaded = true;
|
|
|
|
|
bool isArrivedAppointmentDataLoaded = false;
|
|
|
|
|
bool isFullArrivedAppointmentsLoaded = false;
|
|
|
|
|
|
|
|
|
|
bool isEyeMeasurementsAppointmentsLoading = false;
|
|
|
|
|
|
|
|
|
|
@ -178,6 +179,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
isMyAppointmentsLoading = true;
|
|
|
|
|
isTimeLineAppointmentsLoading = true;
|
|
|
|
|
patientMyDoctorsList.clear();
|
|
|
|
|
isFullArrivedAppointmentsLoaded = false;
|
|
|
|
|
}
|
|
|
|
|
isTamaraDetailsLoading = true;
|
|
|
|
|
isAppointmentPatientShareLoading = true;
|
|
|
|
|
@ -276,6 +278,12 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
getPatientAppointmentQueueDetails();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Skip API call if full data is already loaded and we're not requesting timeline view
|
|
|
|
|
if (!isForTimeLine && isFullArrivedAppointmentsLoaded && !isAppointmentDataToBeLoaded) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isAppointmentDataToBeLoaded) return;
|
|
|
|
|
|
|
|
|
|
patientAppointmentsByClinic.clear();
|
|
|
|
|
@ -323,6 +331,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
if (!isForTimeLine) {
|
|
|
|
|
patientAllArrivedAppointmentsHistoryList = apiResponse.data!;
|
|
|
|
|
isArrivedAppointmentDataLoaded = true;
|
|
|
|
|
isFullArrivedAppointmentsLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (onSuccess != null) {
|
|
|
|
|
@ -354,6 +363,49 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Loads full arrived appointments list if not already loaded
|
|
|
|
|
/// This is called when navigating to My Appointments page from landing page
|
|
|
|
|
Future<void> loadFullArrivedAppointmentsIfNeeded({Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
// Skip if already loaded
|
|
|
|
|
if (isFullArrivedAppointmentsLoaded) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setIsAppointmentsHistoryLoading(true);
|
|
|
|
|
|
|
|
|
|
// Fetch full arrived appointments (isForTimeLine = false)
|
|
|
|
|
final result = await myAppointmentsRepo.getPatientAppointments(isActiveAppointment: false, isArrivedAppointments: true, isForTimeLine: false);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async => await errorHandlerService.handleError(failure: failure),
|
|
|
|
|
(apiResponse) {
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
// Handle error
|
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
|
patientArrivedAppointmentsHistoryList = apiResponse.data!;
|
|
|
|
|
patientAllArrivedAppointmentsHistoryList = apiResponse.data!;
|
|
|
|
|
isArrivedAppointmentDataLoaded = true;
|
|
|
|
|
isFullArrivedAppointmentsLoaded = true;
|
|
|
|
|
|
|
|
|
|
// Rebuild the combined list
|
|
|
|
|
patientAppointmentsHistoryList.clear();
|
|
|
|
|
patientAppointmentsHistoryList.addAll(patientUpcomingAppointmentsHistoryList);
|
|
|
|
|
patientAppointmentsHistoryList.addAll(patientArrivedAppointmentsHistoryList);
|
|
|
|
|
|
|
|
|
|
isMyAppointmentsLoading = false;
|
|
|
|
|
|
|
|
|
|
// Update filtered list based on current tab
|
|
|
|
|
updateListWRTTab(selectedTabIndex);
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (onSuccess != null) {
|
|
|
|
|
onSuccess(apiResponse);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getFiltersForSelectedAppointmentList(List<PatientAppointmentHistoryResponseModel> filteredAppointmentList) {
|
|
|
|
|
availableFilters.clear();
|
|
|
|
|
if (filteredAppointmentList.isEmpty == true) return;
|
|
|
|
|
|