|
|
|
|
@ -57,6 +57,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
bool isMyDoctorsDataToBeLoaded = true;
|
|
|
|
|
bool isArrivedAppointmentDataLoaded = false;
|
|
|
|
|
bool isFullArrivedAppointmentsLoaded = false;
|
|
|
|
|
bool isFullUpcomingAppointmentsLoaded = false;
|
|
|
|
|
|
|
|
|
|
bool isEyeMeasurementsAppointmentsLoading = false;
|
|
|
|
|
|
|
|
|
|
@ -77,6 +78,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
List<PatientAppointmentHistoryResponseModel> patientUpcomingAppointmentsHistoryList = [];
|
|
|
|
|
List<PatientAppointmentHistoryResponseModel> patientArrivedAppointmentsHistoryList = [];
|
|
|
|
|
List<PatientAppointmentHistoryResponseModel> patientHomePageUpcomingAppointmentsHistoryList = [];
|
|
|
|
|
|
|
|
|
|
// List<PatientAppointmentHistoryResponseModel> patientAllArrivedAppointmentsHistoryList = [];
|
|
|
|
|
|
|
|
|
|
@ -174,12 +176,14 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
patientAppointmentsHistoryList.clear();
|
|
|
|
|
patientUpcomingAppointmentsHistoryList.clear();
|
|
|
|
|
patientArrivedAppointmentsHistoryList.clear();
|
|
|
|
|
patientHomePageUpcomingAppointmentsHistoryList.clear();
|
|
|
|
|
// patientAllArrivedAppointmentsHistoryList.clear();
|
|
|
|
|
patientEyeMeasurementsAppointmentsHistoryList.clear();
|
|
|
|
|
isMyAppointmentsLoading = true;
|
|
|
|
|
isTimeLineAppointmentsLoading = true;
|
|
|
|
|
patientMyDoctorsList.clear();
|
|
|
|
|
isFullArrivedAppointmentsLoaded = false;
|
|
|
|
|
isFullUpcomingAppointmentsLoaded = false;
|
|
|
|
|
}
|
|
|
|
|
isTamaraDetailsLoading = true;
|
|
|
|
|
isAppointmentPatientShareLoading = true;
|
|
|
|
|
@ -223,6 +227,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
if (val) {
|
|
|
|
|
isMyAppointmentsLoading = true;
|
|
|
|
|
isMyDoctorsDataToBeLoaded = true;
|
|
|
|
|
isFullUpcomingAppointmentsLoaded = false;
|
|
|
|
|
isFullArrivedAppointmentsLoaded = false;
|
|
|
|
|
}
|
|
|
|
|
isAppointmentDataToBeLoaded = val;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -269,7 +275,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getPatientAppointments(bool isActiveAppointment, bool isArrivedAppointments, {bool isForTimeLine = false, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
Future<void> getPatientAppointments(bool isActiveAppointment, bool isArrivedAppointments,
|
|
|
|
|
{bool isAppointmentForHomePage = false, bool isAppointmentForViewAll = false, bool isForTimeLine = false, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
if (patientArrivedAppointmentsHistoryList.isNotEmpty) {
|
|
|
|
|
isPatientHasQueueAppointment = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -279,13 +286,13 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Skip API call if full data is already loaded and we're not requesting timeline view
|
|
|
|
|
if (!isForTimeLine && isFullArrivedAppointmentsLoaded && !isAppointmentDataToBeLoaded) {
|
|
|
|
|
// Retain data and skip API call once all upcoming appointments are loaded
|
|
|
|
|
// (or if home page data is already loaded and view-all is not requested)
|
|
|
|
|
// until isAppointmentDataToBeLoaded is set to true.
|
|
|
|
|
if (!isAppointmentDataToBeLoaded && (isFullUpcomingAppointmentsLoaded || !isAppointmentForViewAll)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isAppointmentDataToBeLoaded) return;
|
|
|
|
|
|
|
|
|
|
patientAppointmentsByClinic.clear();
|
|
|
|
|
patientAppointmentsByHospital.clear();
|
|
|
|
|
patientAppointmentsViewList.clear();
|
|
|
|
|
@ -294,11 +301,16 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
filteredAppointmentList.clear();
|
|
|
|
|
patientAppointmentsHistoryList.clear();
|
|
|
|
|
patientUpcomingAppointmentsHistoryList.clear();
|
|
|
|
|
if (!isAppointmentForViewAll) {
|
|
|
|
|
patientHomePageUpcomingAppointmentsHistoryList.clear();
|
|
|
|
|
}
|
|
|
|
|
patientArrivedAppointmentsHistoryList.clear();
|
|
|
|
|
setIsAppointmentsHistoryLoading(true);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
|
|
final results = await Future.wait([
|
|
|
|
|
myAppointmentsRepo.getPatientAppointments(isActiveAppointment: isActiveAppointment, isArrivedAppointments: isArrivedAppointments),
|
|
|
|
|
myAppointmentsRepo.getPatientAppointments(
|
|
|
|
|
isActiveAppointment: isActiveAppointment, isArrivedAppointments: isArrivedAppointments, isAppointmentForHomePage: isAppointmentForHomePage, isAppointmentForViewAll: isAppointmentForViewAll),
|
|
|
|
|
myAppointmentsRepo.getPatientAppointments(isActiveAppointment: false, isArrivedAppointments: true, isForTimeLine: isForTimeLine),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
@ -307,8 +319,32 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
(apiResponse) {
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
|
|
|
|
|
if (isAppointmentForViewAll) {
|
|
|
|
|
if (patientHomePageUpcomingAppointmentsHistoryList.isNotEmpty) {
|
|
|
|
|
patientUpcomingAppointmentsHistoryList.addAll(patientHomePageUpcomingAppointmentsHistoryList);
|
|
|
|
|
}
|
|
|
|
|
isFullUpcomingAppointmentsLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
isMyAppointmentsLoading = false;
|
|
|
|
|
isAppointmentDataToBeLoaded = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
|
patientUpcomingAppointmentsHistoryList = apiResponse.data!;
|
|
|
|
|
patientUpcomingAppointmentsHistoryList = List<PatientAppointmentHistoryResponseModel>.from(apiResponse.data!);
|
|
|
|
|
|
|
|
|
|
if (!isAppointmentForViewAll) {
|
|
|
|
|
patientHomePageUpcomingAppointmentsHistoryList = List<PatientAppointmentHistoryResponseModel>.from(patientUpcomingAppointmentsHistoryList);
|
|
|
|
|
}
|
|
|
|
|
if (isAppointmentForViewAll) {
|
|
|
|
|
if (patientHomePageUpcomingAppointmentsHistoryList.isNotEmpty) {
|
|
|
|
|
final partialAppointmentNos = patientHomePageUpcomingAppointmentsHistoryList.map((e) => e.appointmentNo?.toString()).whereType<String>().toSet();
|
|
|
|
|
patientUpcomingAppointmentsHistoryList.removeWhere(
|
|
|
|
|
(appointment) => partialAppointmentNos.contains(appointment.appointmentNo?.toString()),
|
|
|
|
|
);
|
|
|
|
|
patientUpcomingAppointmentsHistoryList.insertAll(0, patientHomePageUpcomingAppointmentsHistoryList);
|
|
|
|
|
}
|
|
|
|
|
isFullUpcomingAppointmentsLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isMyAppointmentsLoading = false;
|
|
|
|
|
isAppointmentDataToBeLoaded = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -324,6 +360,13 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
(apiResponse) {
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
|
|
|
|
|
isMyAppointmentsLoading = false;
|
|
|
|
|
isAppointmentDataToBeLoaded = false;
|
|
|
|
|
if (!isForTimeLine) {
|
|
|
|
|
isArrivedAppointmentDataLoaded = true;
|
|
|
|
|
isFullArrivedAppointmentsLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
|
patientArrivedAppointmentsHistoryList = apiResponse.data!;
|
|
|
|
|
isMyAppointmentsLoading = false;
|
|
|
|
|
@ -343,10 +386,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
patientAppointmentsHistoryList.addAll(patientUpcomingAppointmentsHistoryList);
|
|
|
|
|
patientAppointmentsHistoryList.addAll(patientArrivedAppointmentsHistoryList);
|
|
|
|
|
filteredAppointmentList.addAll(patientAppointmentsHistoryList);
|
|
|
|
|
|
|
|
|
|
// Build grouped list immediately so the UI has data for the default (By Clinic) view.
|
|
|
|
|
_groupAppointmentsByClinicAndHospital();
|
|
|
|
|
updateListWRTTab(selectedTabIndex);
|
|
|
|
|
|
|
|
|
|
// if (patientArrivedAppointmentsHistoryList.isNotEmpty) {
|
|
|
|
|
isPatientHasQueueAppointment = false;
|
|
|
|
|
@ -359,7 +399,6 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
getFiltersForSelectedAppointmentList(filteredAppointmentList);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|