From 6249a16bd9c24fa49802cceca317766a7eeb00fb Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 26 Aug 2026 12:04:25 +0300 Subject: [PATCH] PDF lab attachment for VIDA 4 done. --- lib/features/lab/lab_repo.dart | 3 +- lib/features/lab/lab_view_model.dart | 2 +- .../lab/models/resp_models/lab_result.dart | 33 +++++++++++++++++-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/features/lab/lab_repo.dart b/lib/features/lab/lab_repo.dart index c61341ea..d3eea15a 100644 --- a/lib/features/lab/lab_repo.dart +++ b/lib/features/lab/lab_repo.dart @@ -460,11 +460,12 @@ class LabRepoImp implements LabRepo { Map mapDevice = { "ProjectID": labResult.projectID, "SetupID": labResult.setupID, + // "SetupID": "105", "LabAccessionNumber": labResult.accessionNo ?? "", "FileName": labResult.fileNameWithExtension ?? "", "Lang": Utils.appState.isArabic() ? "ar" : "en", "Internationalization": "false", - "FileHash": Utils.isVidaPlusProject(int.parse(labResult.projectID!)) ? [labResult.uploadedDocuments?[selectedIndex]] : [], + "FileHash": Utils.isVidaPlusProject(int.parse(labResult.projectID!)) ? [(labResult.uploadedDocuments?[selectedIndex].fileData)] : [], }; try { diff --git a/lib/features/lab/lab_view_model.dart b/lib/features/lab/lab_view_model.dart index 4aca8a0d..c6843b5b 100644 --- a/lib/features/lab/lab_view_model.dart +++ b/lib/features/lab/lab_view_model.dart @@ -1018,7 +1018,7 @@ class LabViewModel extends ChangeNotifier { itemBuilder: (context, index) { return Padding( padding: const EdgeInsets.only(right: 12), - child: "Attachment ${(index + 1)}".toText16(color: AppColors.primaryRedColor, isBold: true, isUnderLine: true), + child: "${labResult.uploadedDocuments![index].fileName}".toText16(color: AppColors.primaryRedColor, isBold: true, isUnderLine: true), ).onPress(() { LoaderBottomSheet.showLoader(); getLabResultAttachmentPDF( diff --git a/lib/features/lab/models/resp_models/lab_result.dart b/lib/features/lab/models/resp_models/lab_result.dart index 3d63ddb6..bdc64baf 100644 --- a/lib/features/lab/models/resp_models/lab_result.dart +++ b/lib/features/lab/models/resp_models/lab_result.dart @@ -52,7 +52,7 @@ class LabResult { int? testID; String? testShortDescription; String? uOM; - List? uploadedDocuments; + List? uploadedDocuments; String? verifiedOn; dynamic verifiedOnDateTime; @@ -168,7 +168,14 @@ class LabResult { testID = json['TestID']; testShortDescription = json['TestShortDescription']; uOM = json['UOM']; - uploadedDocuments = json['UploadedDocuments'] ?? []; + + if (json['UploadedDocuments'] != null) { + uploadedDocuments = []; + json['UploadedDocuments'].forEach((v) { + uploadedDocuments!.add(LabResultAttachment.fromJson(v)); + }); + } + verifiedOn = json['VerifiedOn']; verifiedOnDateTime = json['VerifiedOnDateTime']; } @@ -255,6 +262,28 @@ class LabResult { } } +class LabResultAttachment { + String? fileData; + String? fileName; + String? fileType; + + LabResultAttachment({this.fileData, this.fileName, this.fileType}); + + LabResultAttachment.fromJson(Map json) { + fileData = json['FileData']; + fileName = json['FileName']; + fileType = json['FileType']; + } + + Map toJson() { + final Map data = new Map(); + data['FileData'] = this.fileData; + data['FileName'] = this.fileName; + data['FileType'] = this.fileType; + return data; + } +} + // class LabResult { // String? description; // dynamic femaleInterpretativeData;