|
|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/get_tamara_installments_details_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/appointemnet_filters.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/get_tamara_installments_details_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_share_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_repo.dart';
|
|
|
|
|
@ -29,8 +29,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
List<AppointmentListingFilters> availableFilters = [];
|
|
|
|
|
List<AppointmentListingFilters>? selectedFilter = [];
|
|
|
|
|
bool isDateFilterSelected = false;
|
|
|
|
|
DateTime? start =null;
|
|
|
|
|
DateTime? end =null;
|
|
|
|
|
DateTime? start = null;
|
|
|
|
|
DateTime? end = null;
|
|
|
|
|
|
|
|
|
|
List<PatientAppointmentHistoryResponseModel> patientAppointmentsHistoryList = [];
|
|
|
|
|
List<PatientAppointmentHistoryResponseModel> filteredAppointmentList = [];
|
|
|
|
|
@ -171,40 +171,36 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
getFiltersForSelectedAppointmentList(filteredAppointmentList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getFiltersForSelectedAppointmentList(
|
|
|
|
|
List<PatientAppointmentHistoryResponseModel> filteredAppointmentList) {
|
|
|
|
|
void getFiltersForSelectedAppointmentList(List<PatientAppointmentHistoryResponseModel> filteredAppointmentList) {
|
|
|
|
|
availableFilters.clear();
|
|
|
|
|
if (filteredAppointmentList.isEmpty == true) return;
|
|
|
|
|
availableFilters.add(AppointmentListingFilters.DATESELECTION);
|
|
|
|
|
if (filteredAppointmentList
|
|
|
|
|
.any((element) => element.isLiveCareAppointment == true)) {
|
|
|
|
|
if (filteredAppointmentList.any((element) => element.isLiveCareAppointment == true)) {
|
|
|
|
|
availableFilters.add(AppointmentListingFilters.LIVECARE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (filteredAppointmentList
|
|
|
|
|
.any((element) => element.isLiveCareAppointment == false)) {
|
|
|
|
|
if (filteredAppointmentList.any((element) => element.isLiveCareAppointment == false)) {
|
|
|
|
|
availableFilters.add(AppointmentListingFilters.WALKIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (filteredAppointmentList
|
|
|
|
|
.any((element) => AppointmentType.isArrived(element) == true)) {
|
|
|
|
|
if (filteredAppointmentList.any((element) => AppointmentType.isArrived(element) == true)) {
|
|
|
|
|
availableFilters.add(AppointmentListingFilters.ARRIVED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (filteredAppointmentList
|
|
|
|
|
.any((element) => AppointmentType.isBooked(element) == true)) {
|
|
|
|
|
if (filteredAppointmentList.any((element) => AppointmentType.isBooked(element) == true)) {
|
|
|
|
|
availableFilters.add(AppointmentListingFilters.BOOKED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (filteredAppointmentList
|
|
|
|
|
.any((element) => AppointmentType.isConfirmed(element) == true)) {
|
|
|
|
|
if (filteredAppointmentList.any((element) => AppointmentType.isConfirmed(element) == true)) {
|
|
|
|
|
availableFilters.add(AppointmentListingFilters.CONFIRMED);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getPatientShareAppointment(int projectID, int clinicID, String appointmentNo, bool isLiveCareAppointment, {Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.getPatientShareAppointment(projectID: projectID, clinicID: clinicID, appointmentNo: appointmentNo, isLiveCareAppointment: isLiveCareAppointment);
|
|
|
|
|
Future<void> getPatientShareAppointment(int projectID, int clinicID, String appointmentNo, bool isLiveCareAppointment,
|
|
|
|
|
{Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.getPatientShareAppointment(
|
|
|
|
|
projectID: projectID, clinicID: clinicID, appointmentNo: appointmentNo, isLiveCareAppointment: isLiveCareAppointment);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async {
|
|
|
|
|
@ -230,8 +226,13 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> addAdvanceNumberRequest(
|
|
|
|
|
{required String advanceNumber, required String paymentReference, required String appointmentNo, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.addAdvanceNumberRequest(advanceNumber: advanceNumber, paymentReference: paymentReference, appointmentNo: appointmentNo);
|
|
|
|
|
{required String advanceNumber,
|
|
|
|
|
required String paymentReference,
|
|
|
|
|
required String appointmentNo,
|
|
|
|
|
Function(dynamic)? onSuccess,
|
|
|
|
|
Function(String)? onError}) async {
|
|
|
|
|
final result =
|
|
|
|
|
await myAppointmentsRepo.addAdvanceNumberRequest(advanceNumber: advanceNumber, paymentReference: paymentReference, appointmentNo: appointmentNo);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async => await errorHandlerService.handleError(failure: failure),
|
|
|
|
|
@ -249,8 +250,14 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> generateAppointmentQR(
|
|
|
|
|
{required int clinicID, required int projectID, required String appointmentNo, required int isFollowUp, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.generateAppointmentQR(clinicID: clinicID, projectID: projectID, appointmentNo: appointmentNo, isFollowUp: isFollowUp);
|
|
|
|
|
{required int clinicID,
|
|
|
|
|
required int projectID,
|
|
|
|
|
required String appointmentNo,
|
|
|
|
|
required int isFollowUp,
|
|
|
|
|
Function(dynamic)? onSuccess,
|
|
|
|
|
Function(String)? onError}) async {
|
|
|
|
|
final result =
|
|
|
|
|
await myAppointmentsRepo.generateAppointmentQR(clinicID: clinicID, projectID: projectID, appointmentNo: appointmentNo, isFollowUp: isFollowUp);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async => await errorHandlerService.handleError(failure: failure),
|
|
|
|
|
@ -267,7 +274,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> cancelAppointment({required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
Future<void> cancelAppointment(
|
|
|
|
|
{required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.cancelAppointment(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
@ -286,7 +294,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> confirmAppointment({required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
Future<void> confirmAppointment(
|
|
|
|
|
{required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.confirmAppointment(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
@ -347,7 +356,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
required int checkInType,
|
|
|
|
|
Function(dynamic)? onSuccess,
|
|
|
|
|
Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.sendCheckInNfcRequest(patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel, scannedCode: scannedCode, checkInType: checkInType);
|
|
|
|
|
final result = await myAppointmentsRepo.sendCheckInNfcRequest(
|
|
|
|
|
patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel, scannedCode: scannedCode, checkInType: checkInType);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async => await errorHandlerService.handleError(failure: failure),
|
|
|
|
|
@ -393,8 +403,12 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> insertLiveCareVIDARequest(
|
|
|
|
|
{required clientRequestID, required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.insertLiveCareVIDARequest(clientRequestID: clientRequestID, patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel);
|
|
|
|
|
{required clientRequestID,
|
|
|
|
|
required PatientAppointmentHistoryResponseModel patientAppointmentHistoryResponseModel,
|
|
|
|
|
Function(dynamic)? onSuccess,
|
|
|
|
|
Function(String)? onError}) async {
|
|
|
|
|
final result = await myAppointmentsRepo.insertLiveCareVIDARequest(
|
|
|
|
|
clientRequestID: clientRequestID, patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async => await errorHandlerService.handleError(failure: failure),
|
|
|
|
|
@ -441,7 +455,7 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
selectedFilter?.add(availableFilter) ;
|
|
|
|
|
selectedFilter?.add(availableFilter);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -461,14 +475,14 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
if (start == null && end == null) {
|
|
|
|
|
isDateFilterSelected = false;
|
|
|
|
|
filteredAppointmentList.clear();
|
|
|
|
|
sourceList.forEach((element) {
|
|
|
|
|
for (var element in sourceList) {
|
|
|
|
|
if (isUnderFilter(element)) {
|
|
|
|
|
filteredAppointmentList.add(element);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
filteredAppointmentList.clear();
|
|
|
|
|
sourceList.forEach((element) {
|
|
|
|
|
for (var element in sourceList) {
|
|
|
|
|
try {
|
|
|
|
|
var dateTime = DateUtil.convertStringToDate(element.appointmentDate).provideDateOnly();
|
|
|
|
|
|
|
|
|
|
@ -479,14 +493,14 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (start != null && end != null) {
|
|
|
|
|
if ((dateTime.isAfter(start)) && ((dateTime.isBefore(end))||((dateTime.isAtSameMomentAs(end))))) {
|
|
|
|
|
if ((dateTime.isAfter(start)) && ((dateTime.isBefore(end)) || ((dateTime.isAtSameMomentAs(end))))) {
|
|
|
|
|
if (isUnderFilter(element)) {
|
|
|
|
|
filteredAppointmentList.add(element);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
@ -496,27 +510,24 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isUnderFilter(PatientAppointmentHistoryResponseModel element) {
|
|
|
|
|
bool isUnderTheFilter = false;
|
|
|
|
|
if (selectedFilter == null || selectedFilter!.isEmpty) return true;
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (var filter in selectedFilter ?? []) {
|
|
|
|
|
switch (filter) {
|
|
|
|
|
case AppointmentListingFilters.WALKIN:
|
|
|
|
|
if (element.isLiveCareAppointment == false) return true;
|
|
|
|
|
case AppointmentListingFilters.BOOKED:
|
|
|
|
|
if (AppointmentType.isBooked(element))return true;
|
|
|
|
|
if (AppointmentType.isBooked(element)) return true;
|
|
|
|
|
|
|
|
|
|
case AppointmentListingFilters.CONFIRMED:
|
|
|
|
|
if (AppointmentType.isConfirmed(element))return true;
|
|
|
|
|
if (AppointmentType.isConfirmed(element)) return true;
|
|
|
|
|
|
|
|
|
|
case AppointmentListingFilters.ARRIVED:
|
|
|
|
|
if (AppointmentType.isArrived(element))return true;
|
|
|
|
|
if (AppointmentType.isArrived(element)) return true;
|
|
|
|
|
|
|
|
|
|
case AppointmentListingFilters.LIVECARE:
|
|
|
|
|
if (element.isLiveCareAppointment == true) return true;
|
|
|
|
|
|
|
|
|
|
case AppointmentListingFilters.DATESELECTION:
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
|