|
|
|
|
@ -2,6 +2,7 @@ import 'dart:collection';
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:core';
|
|
|
|
|
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
@ -10,12 +11,15 @@ import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart' show Utils;
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/lab/lab_repo.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/lab/models/ai_overview_labresult_model_payload.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/lab/models/resp_models/ai_overview_labresults_by_ai_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/lab/models/resp_models/lab_result.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_order_response_by_ai_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/lab/models/resp_models/patient_lab_orders_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/codegen_loader.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/lab/lab_result_via_clinic/LabResultByClinic.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/lab/lab_results/lab_result_details.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/lab/lab_result_via_clinic/lab_ai_analysis_detailed_page.dart';
|
|
|
|
|
@ -23,9 +27,11 @@ import 'package:hmg_patient_app_new/services/cache_service.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/navigation_service.dart';
|
|
|
|
|
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:intl/intl.dart' show DateFormat;
|
|
|
|
|
import 'package:open_filex/open_filex.dart';
|
|
|
|
|
|
|
|
|
|
class LabViewModel extends ChangeNotifier {
|
|
|
|
|
bool isLabOrdersLoading = false;
|
|
|
|
|
@ -238,12 +244,12 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
final result = await labRepo.getLabResultAttachmentPDF(labResult: labResult, selectedIndex: selectedIndex);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async => await errorHandlerService.handleError(
|
|
|
|
|
failure: failure,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
onError!(failure.message);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
// (failure) async => await errorHandlerService.handleError(
|
|
|
|
|
(failure) async {
|
|
|
|
|
if (onError != null) {
|
|
|
|
|
onError(failure.message)!;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
(apiResponse) {
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
onError!(apiResponse.errorMessage!);
|
|
|
|
|
@ -994,4 +1000,73 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void openLabResultsAttachmentSheet({required LabResult labResult}) {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
getIt
|
|
|
|
|
.get<NavigationService>()
|
|
|
|
|
.navigatorKey
|
|
|
|
|
.currentContext!,
|
|
|
|
|
title: LocaleKeys.selectAttachment.tr(),
|
|
|
|
|
child: (labResult.uploadedDocuments ?? []).isNotEmpty
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
ListView.builder(
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: (labResult.uploadedDocuments ?? []).length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 12),
|
|
|
|
|
child: "Attachment ${(index + 1)}".toText16(color: AppColors.primaryRedColor, isBold: true, isUnderLine: true),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
|
getLabResultAttachmentPDF(
|
|
|
|
|
labResult: labResult,
|
|
|
|
|
selectedIndex: index,
|
|
|
|
|
onError: (err) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}).then((val) async {
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
if (getIt.get<LabViewModel>().patientLabResultAttachmentPDFBase64.isNotEmpty) {
|
|
|
|
|
String path = await Utils.createFileFromString(getIt.get<LabViewModel>().patientLabResultAttachmentPDFBase64, "pdf");
|
|
|
|
|
try {
|
|
|
|
|
OpenFilex.open(path);
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
getIt.get<NavigationService>().navigatorKey.currentContext!,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: "Cannot open file"),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
getIt.get<NavigationService>().navigatorKey.currentContext!,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: "Attachment not available"),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: Utils.getErrorWidget(loadingText: "No attachments found"),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|