|
|
|
|
@ -20,6 +20,7 @@ import 'package:hmg_patient_app_new/features/lab/models/resp_models/ai_overview_
|
|
|
|
|
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/features/lab/models/resp_models/patient_lab_special_result.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';
|
|
|
|
|
@ -51,6 +52,7 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
List<PatientLabOrdersResponseModel> patientLabOrders = [];
|
|
|
|
|
List<PatientLabOrdersResponseModel> filteredLabOrders = [];
|
|
|
|
|
List<PatientLabOrdersResponseModel> tempLabOrdersList = [];
|
|
|
|
|
|
|
|
|
|
String labSpecialResult = "";
|
|
|
|
|
List<String> labOrderTests = [];
|
|
|
|
|
String patientLabResultReportPDFBase64 = "";
|
|
|
|
|
@ -66,7 +68,9 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
// Flat list for UI compatibility
|
|
|
|
|
List<LabResult> mainLabResultsByHospitalsList = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<PatientLabSpecialResult> patientSpecialLabResultsList = [];
|
|
|
|
|
|
|
|
|
|
// Grouped map by package name for efficient lookups
|
|
|
|
|
Map<String, List<LabResult>> mainLabResultsByPackageName = {};
|
|
|
|
|
|
|
|
|
|
@ -591,6 +595,7 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
Future<void> getPatientSpecialResult(PatientLabOrdersResponseModel laborder) async {
|
|
|
|
|
isSpecialResultsLoading = true;
|
|
|
|
|
labSpecialResult = "";
|
|
|
|
|
patientSpecialLabResultsList.clear();
|
|
|
|
|
notifyListeners();
|
|
|
|
|
final result = await labRepo.getSpecialLabResult(
|
|
|
|
|
laborder,
|
|
|
|
|
@ -614,6 +619,7 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
labSpecialResult = htmlbuffer.toString();
|
|
|
|
|
patientSpecialLabResultsList = apiResponse.data ?? [];
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
@ -1072,4 +1078,80 @@ class LabViewModel extends ChangeNotifier {
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void openSpecialLabResultsAttachmentSheet({required PatientLabSpecialResult specialLabResult, required projectID, required setupID}) {
|
|
|
|
|
LabResult labResult = LabResult(
|
|
|
|
|
projectID: projectID,
|
|
|
|
|
setupID: setupID,
|
|
|
|
|
accessionNo: specialLabResult.accessionNo,
|
|
|
|
|
uploadedDocuments: specialLabResult.uploadedDocuments,
|
|
|
|
|
fileNameWithExtensionList: specialLabResult.fileNameWithExtensionList,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
getIt.get<NavigationService>().navigatorKey.currentContext!,
|
|
|
|
|
title: LocaleKeys.selectAttachment.tr(),
|
|
|
|
|
child: (Utils.isVidaPlusProject(int.parse(projectID)) ? (specialLabResult.uploadedDocuments ?? []).isNotEmpty : (specialLabResult.fileNameWithExtensionList ?? []).isNotEmpty)
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
ListView.builder(
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: Utils.isVidaPlusProject(int.parse(projectID)) ? (specialLabResult.uploadedDocuments ?? []).length : (specialLabResult.fileNameWithExtensionList ?? []).length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.only(right: 12.h, bottom: 12.h),
|
|
|
|
|
child:
|
|
|
|
|
"${Utils.isVidaPlusProject(int.parse(projectID)) ? specialLabResult.uploadedDocuments![index].fileName : specialLabResult.fileNameWithExtensionList![index].fileNameWithExtension}"
|
|
|
|
|
.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,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|