|
|
|
|
@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:get_it/get_it.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/calender_utils_new.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
|
|
|
@ -17,6 +18,8 @@ import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_queue_details_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_repo.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_appointments/utils/appointment_type.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_invoices/models/get_invoices_list_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/my_invoices/my_invoices_repo.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/insurance/insurance_home_page.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
|
|
|
|
|
@ -25,6 +28,7 @@ import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
|
|
|
|
import 'package:open_filex/open_filex.dart';
|
|
|
|
|
|
|
|
|
|
class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
int selectedTabIndex = 0;
|
|
|
|
|
@ -1519,4 +1523,74 @@ class MyAppointmentsViewModel extends ChangeNotifier {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getAppointmentInvoice({required num appointmentNum, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
String? downloadInvoicePDFBase64 = "";
|
|
|
|
|
final result = await myAppointmentsRepo.getAppointmentInvoice(appointmentNum);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async {
|
|
|
|
|
if (onError != null) {
|
|
|
|
|
onError(failure.message ?? "Unknown error");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
(apiResponse) async {
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
if (onError != null) {
|
|
|
|
|
onError(apiResponse.errorMessage ?? "Unknown error");
|
|
|
|
|
}
|
|
|
|
|
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
|
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
|
if (apiResponse.data!.isNotEmpty) {
|
|
|
|
|
GetInvoicesListResponseModel getInvoicesListResponseModel = apiResponse.data!.first;
|
|
|
|
|
final result = await getIt
|
|
|
|
|
.get<MyInvoicesRepo>()
|
|
|
|
|
.downloadInvoice(setupId: getInvoicesListResponseModel.setupId!, invoiceNo: getInvoicesListResponseModel.invoiceNo!, projectID: getInvoicesListResponseModel.projectId!);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async {
|
|
|
|
|
if (onError != null) {
|
|
|
|
|
onError(failure.message);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
(apiResponse) async {
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
|
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
|
if (apiResponse.data != null && apiResponse.data!.isNotEmpty) {
|
|
|
|
|
downloadInvoicePDFBase64 = apiResponse.data!;
|
|
|
|
|
String path = await Utils.createFileFromString(downloadInvoicePDFBase64!, "pdf");
|
|
|
|
|
try {
|
|
|
|
|
OpenFilex.open(path);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
GetIt.instance<NavigationService>().navigatorKey.currentContext!,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: "Cannot open file"),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
downloadInvoicePDFBase64 = "";
|
|
|
|
|
}
|
|
|
|
|
if (onSuccess != null) {
|
|
|
|
|
onSuccess(apiResponse);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
GetIt.instance<NavigationService>().navigatorKey.currentContext!,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: "Cannot open invoice"),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|