diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index 4db0cf8b..1c712978 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -211,7 +211,7 @@ class ApiClientImp implements ApiClient { } // body['TokenID'] = "@dm!n"; - // body['PatientID'] = 1307867; + // body['PatientID'] = 4774985; // body['PatientID'] = 53320; // body['PatientTypeID'] = 1; // body['PatientOutSA'] = 0; diff --git a/lib/features/lab/lab_view_model.dart b/lib/features/lab/lab_view_model.dart index bb21c100..29e0dfcc 100644 --- a/lib/features/lab/lab_view_model.dart +++ b/lib/features/lab/lab_view_model.dart @@ -615,7 +615,9 @@ class LabViewModel extends ChangeNotifier { StringBuffer htmlbuffer = StringBuffer(""); apiResponse.data?.forEach((element) { - if (element.resultDataHTML != null && element.resultDataHTML?.isNotEmpty == true) htmlbuffer.write("${element.resultDataHTML}

"); + if (element.resultDataHTML != null && element.resultDataHTML?.isNotEmpty == true) { + htmlbuffer.write("${element.resultDataHTML}

"); + } }); labSpecialResult = htmlbuffer.toString(); @@ -1080,34 +1082,48 @@ class LabViewModel extends ChangeNotifier { } 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, - ); + final bool isVP = Utils.isVidaPlusProject(int.parse(projectID.toString())); + + final List<({LabResult labResult, int index, String name})> attachments = []; + for (var labRes in patientSpecialLabResultsList) { + final lr = LabResult( + projectID: projectID, + setupID: setupID, + accessionNo: labRes.accessionNo, + uploadedDocuments: labRes.uploadedDocuments, + fileNameWithExtensionList: labRes.fileNameWithExtensionList, + ); + if (isVP) { + final docs = labRes.uploadedDocuments ?? []; + for (int i = 0; i < docs.length; i++) { + attachments.add((labResult: lr, index: i, name: docs[i].fileName ?? "")); + } + } else { + final files = labRes.fileNameWithExtensionList ?? []; + for (int i = 0; i < files.length; i++) { + attachments.add((labResult: lr, index: i, name: files[i].fileNameWithExtension ?? "")); + } + } + } showCommonBottomSheetWithoutHeight( getIt.get().navigatorKey.currentContext!, title: LocaleKeys.selectAttachment.tr(), - child: (Utils.isVidaPlusProject(int.parse(projectID)) ? (specialLabResult.uploadedDocuments ?? []).isNotEmpty : (specialLabResult.fileNameWithExtensionList ?? []).isNotEmpty) + child: attachments.isNotEmpty ? Column( children: [ ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: Utils.isVidaPlusProject(int.parse(projectID)) ? (specialLabResult.uploadedDocuments ?? []).length : (specialLabResult.fileNameWithExtensionList ?? []).length, + itemCount: attachments.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), + child: attachments[index].name.toText16(color: AppColors.primaryRedColor, isBold: true, isUnderLine: true), ).onPress(() { LoaderBottomSheet.showLoader(); getLabResultAttachmentPDF( - labResult: labResult, + labResult: attachments[index].labResult, selectedIndex: index, onError: (err) { LoaderBottomSheet.hideLoader();