VIDA 3 attachments implemented

CR-20974-PDF-Results-In-Lab
haroon amjad 2 months ago
parent 7c3d6de8a8
commit a1c276b16b

@ -1969,5 +1969,6 @@
"hide": "إخفاء",
"viewPatientQR": "عرض رمز الاستجابة السريعة للمريض",
"patientQR": "رمز الاستجابة السريعة للمريض",
"forText": "عن"
"forText": "عن",
"viewAttachment": "المرفقات"
}

@ -1959,7 +1959,8 @@
"hide": "Hide",
"viewPatientQR": "View Patient QR Code",
"patientQR": "Patient QR Code",
"forText": "For"
"forText": "For",
"viewAttachment": "Attachments"
}

@ -1023,6 +1023,8 @@ const DOWNLOAD_PHARMACY_INVOICE_PDF = 'Services/Notifications.svc/REST/DownloadI
const GET_APPOINTMENT_PARKING_QR = 'Services/outps.svc/rest/pms_getParkingTicketByAppointmentNo';
const GET_LAB_RESULT_PDF_ATTACHMENT = 'Services/Patients.svc/REST/GetVidaLabResultAttachment';
class ApiKeyConstants {
static final String googleMapsApiKey = 'AIzaSyB6TERnxIr0yJ3qG4ULBZbu0sAD4tGqtng';
}

@ -8,6 +8,7 @@ import 'package:hmg_patient_app_new/core/utils/utils.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/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_result_attachment_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/services/logger_service.dart';
@ -29,7 +30,10 @@ abstract class LabRepo {
Future<Either<Failure, GenericApiModel<LabOrdersResponseByAi>>> getPatientAiOverViewLabOrders({required int langId, required dynamic payload});
Future<Either<Failure, GenericApiModel<LabOrderResponseByAi>>> getPatientAiOverViewLabOrder(var payloa);
Map<String, List<LabResult>> groupLabResultsByPackageName(List<LabResult> labResults);
Future<Either<Failure, GenericApiModel<String>>> getLabResultAttachmentPDF({required LabResult labResult, required int selectedIndex});
}
class LabRepoImp implements LabRepo {
@ -57,8 +61,8 @@ class LabRepoImp implements LabRepo {
// Group results by package name
for (var labResult in labResults) {
String packageName = labResult.PackageName ?? 'Unknown Package';
String packageName = labResult.packageName ?? 'Unknown Package';
if (groupedResults.containsKey(packageName)) {
// Package name exists, add to existing list
groupedResults[packageName]!.add(labResult);
@ -450,4 +454,48 @@ class LabRepoImp implements LabRepo {
return Left(UnknownFailure(e.toString()));
}
}
@override
Future<Either<Failure, GenericApiModel<String>>> getLabResultAttachmentPDF({required LabResult labResult, required selectedIndex}) async {
Map<String, dynamic> mapDevice = {
"ProjectID": labResult.projectID,
"SetupID": labResult.setupID,
"LabAccessionNumber": labResult.accessionNo,
"FileName": labResult.fileNameWithExtension,
"Lang": Utils.appState.isArabic() ? "ar" : "en",
"Internationalization": "false",
"FileHash": Utils.isVidaPlusProject(int.parse(labResult.projectID!)) ? [labResult.uploadedDocuments?[selectedIndex]] : [],
};
try {
GenericApiModel<String>? apiResponse;
Failure? failure;
await apiClient.post(
GET_LAB_RESULT_PDF_ATTACHMENT,
body: mapDevice,
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
PatientLabResultPDFAttachmentResponse? labResultAttachmentResponse = PatientLabResultPDFAttachmentResponse.fromJson(response['GetVidaLabAttachment']);
apiResponse = GenericApiModel<String>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: null,
data: labResultAttachmentResponse.data?.first.base64Content,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
}
},
);
if (failure != null) return Left(failure!);
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
return Right(apiResponse!);
} catch (e) {
return Left(UnknownFailure(e.toString()));
}
}
}

@ -95,6 +95,8 @@ class LabViewModel extends ChangeNotifier {
bool isLabAIAnalysisNeedsToBeShown = true;
bool isLabResultsHistoryShowMore = false;
String patientLabResultAttachmentPDFBase64 = "";
LabViewModel({required this.labRepo, required this.errorHandlerService, required this.navigationService});
initLabProvider() {
@ -148,6 +150,8 @@ class LabViewModel extends ChangeNotifier {
uniqueTests.clear();
labOrderTests.clear();
uniqueTests = {};
filteredUniqueTestsList.clear();
filteredIndexedCharacterForUniqueTest.clear();
patientLabOrdersByClinic.clear();
patientLabOrdersByHospital.clear();
patientLabOrdersViewList.clear();
@ -230,6 +234,31 @@ class LabViewModel extends ChangeNotifier {
);
}
Future<void> getLabResultAttachmentPDF({required LabResult labResult, required selectedIndex, Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await labRepo.getLabResultAttachmentPDF(labResult: labResult, selectedIndex: selectedIndex);
result.fold(
(failure) async => await errorHandlerService.handleError(
failure: failure,
onOkPressed: () {
onError!(failure.message);
},
),
(apiResponse) {
if (apiResponse.messageStatus == 2) {
onError!(apiResponse.errorMessage!);
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
patientLabResultAttachmentPDFBase64 = apiResponse.data!;
notifyListeners();
if (onSuccess != null) {
onSuccess(apiResponse);
}
}
},
);
}
filterSuggestions() {
final List<String> labels = patientLabOrders.expand((order) => order.testDetails ?? []).map((detail) => detail.description).whereType<String>().toList();
_labSuggestionsList = labels.toSet().toList();

@ -1,127 +1,236 @@
class LabResult {
String? accessionNo;
String? calculatedResultFlag;
dynamic changeResult;
String? collectedOn;
dynamic criticalHigh;
dynamic criticalLow;
String? description;
dynamic femaleInterpretativeData;
String? fileNameWithExtension;
int? gender;
dynamic genderDesc;
String? header;
dynamic interpretativeData;
String? invoiceType;
bool? isCertificateAllowed;
bool? isLabTestAttachment;
bool? isPregnant;
bool? isVisibleComponent;
int? lineItemNo;
dynamic maleInterpretativeData;
dynamic notes;
dynamic needMedicalVerificationForAbnResult;
String? notes;
int? orderLineItemNo;
int? orderNo;
String? packageID;
String? packageName;
String? packageShortDescription;
int? patientID;
String? projectID;
String? receivedOn;
String? referanceRange;
dynamic referenceHigh;
dynamic referenceLow;
String? registeredOn;
String? reportedOn;
String? resultSymbol;
int? resultTypeID;
String? resultValue;
int? resultValueBasedLineItemNo;
String? resultValueFlag;
String? rptTestCode;
String? sampleCollectedOn;
String? sampleReceivedOn;
String? setupID;
int? status;
dynamic statusDesc;
dynamic statusDescription;
String? subHeader;
dynamic superVerifiedOn;
String? testCode;
int? testID;
String? testShortDescription;
String? uOM;
List<String>? uploadedDocuments;
String? verifiedOn;
String? verifiedOnDateTime;
String? changeResult;
String? calculatedResultFlag;
String? criticalHigh;
String? referenceHigh;
String? criticalLow;
String? referenceLow;
num? resultTypeID;
String? packageShortDescription;
int? testId;
String? testShortDescription;
String? PackageName;
dynamic verifiedOnDateTime;
LabResult(
{this.description,
this.femaleInterpretativeData,
this.gender,
this.lineItemNo,
this.maleInterpretativeData,
this.notes,
this.packageID,
this.patientID,
this.projectID,
this.referanceRange,
this.resultValue,
this.sampleCollectedOn,
this.sampleReceivedOn,
{this.accessionNo,
this.calculatedResultFlag,
this.changeResult,
this.collectedOn,
this.criticalHigh,
this.criticalLow,
this.description,
this.femaleInterpretativeData,
this.fileNameWithExtension,
this.gender,
this.genderDesc,
this.header,
this.interpretativeData,
this.invoiceType,
this.isCertificateAllowed,
this.isLabTestAttachment,
this.isPregnant,
this.isVisibleComponent,
this.lineItemNo,
this.maleInterpretativeData,
this.needMedicalVerificationForAbnResult,
this.notes,
this.orderLineItemNo,
this.orderNo,
this.packageID,
this.packageName,
this.packageShortDescription,
this.patientID,
this.projectID,
this.receivedOn,
this.referanceRange,
this.referenceHigh,
this.referenceLow,
this.registeredOn,
this.reportedOn,
this.resultSymbol,
this.resultTypeID,
this.resultValue,
this.resultValueBasedLineItemNo,
this.resultValueFlag,
this.rptTestCode,
this.sampleCollectedOn,
this.sampleReceivedOn,
this.setupID,
this.superVerifiedOn,
this.testCode,
this.uOM,
this.verifiedOn,
this.calculatedResultFlag,
this.verifiedOnDateTime,
this.criticalHigh,
this.referenceHigh,
this.criticalLow,
this.referenceLow,
this.testId,
this.testShortDescription,
this.PackageName
});
this.status,
this.statusDesc,
this.statusDescription,
this.subHeader,
this.superVerifiedOn,
this.testCode,
this.testID,
this.testShortDescription,
this.uOM,
this.uploadedDocuments,
this.verifiedOn,
this.verifiedOnDateTime});
LabResult.fromJson(Map<String, dynamic> json) {
accessionNo = json['AccessionNo'];
calculatedResultFlag = json['CalculatedResultFlag'];
changeResult = json['ChangeResult'];
collectedOn = json['CollectedOn'];
criticalHigh = json['CriticalHigh'];
criticalLow = json['CriticalLow'];
description = json['Description'];
femaleInterpretativeData = json['FemaleInterpretativeData'];
fileNameWithExtension = json['FileNameWithExtension'];
gender = json['Gender'];
genderDesc = json['GenderDesc'];
header = json['Header'];
interpretativeData = json['InterpretativeData'];
invoiceType = json['InvoiceType'];
isCertificateAllowed = json['IsCertificateAllowed'];
isLabTestAttachment = json['IsLabTestAttachment'];
isPregnant = json['IsPregnant'];
isVisibleComponent = json['IsVisibleComponent'];
lineItemNo = json['LineItemNo'];
maleInterpretativeData = json['MaleInterpretativeData'];
needMedicalVerificationForAbnResult = json['NeedMedicalVerificationForAbnResult'];
notes = json['Notes'];
orderLineItemNo = json['OrderLineItemNo'];
orderNo = json['OrderNo'];
packageID = json['PackageID'];
packageName = json['PackageName'];
packageShortDescription = json['PackageShortDescription'];
patientID = json['PatientID'];
projectID = json['ProjectID'];
receivedOn = json['ReceivedOn'];
referanceRange = json['ReferanceRange'];
referenceHigh = json['ReferenceHigh'];
referenceLow = json['ReferenceLow'];
registeredOn = json['RegisteredOn'];
reportedOn = json['ReportedOn'];
resultSymbol = json['ResultSymbol'];
resultTypeID = json['ResultTypeID'];
resultValue = json['ResultValue'];
resultValueBasedLineItemNo = json['ResultValueBasedLineItemNo'];
resultValueFlag = json['ResultValueFlag'];
rptTestCode = json['RptTestCode'];
sampleCollectedOn = json['SampleCollectedOn'];
sampleReceivedOn = json['SampleReceivedOn'];
setupID = json['SetupID'];
status = json['Status'];
statusDesc = json['StatusDesc'];
statusDescription = json['StatusDescription'];
subHeader = json['SubHeader'];
superVerifiedOn = json['SuperVerifiedOn'];
testCode = json['TestCode'];
testID = json['TestID'];
testShortDescription = json['TestShortDescription'];
uOM = json['UOM'];
uploadedDocuments = json['UploadedDocuments'] ?? [];
verifiedOn = json['VerifiedOn'];
verifiedOnDateTime = json['VerifiedOnDateTime'];
changeResult = json['ChangeResult'];
calculatedResultFlag = json['CalculatedResultFlag'];
criticalHigh = json['CriticalHigh'];
referenceHigh = json['ReferenceHigh'];
criticalLow = json['CriticalLow'];
referenceLow = json['ReferenceLow'];
packageShortDescription = json['PackageShortDescription'];
resultTypeID = json['ResultTypeID'];
testId = json['TestID'];
testShortDescription = json['TestShortDescription'];
PackageName = json['PackageName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['AccessionNo'] = this.accessionNo;
data['CalculatedResultFlag'] = this.calculatedResultFlag;
data['ChangeResult'] = this.changeResult;
data['CollectedOn'] = this.collectedOn;
data['CriticalHigh'] = this.criticalHigh;
data['CriticalLow'] = this.criticalLow;
data['Description'] = this.description;
data['FemaleInterpretativeData'] = this.femaleInterpretativeData;
data['FileNameWithExtension'] = this.fileNameWithExtension;
data['Gender'] = this.gender;
data['GenderDesc'] = this.genderDesc;
data['Header'] = this.header;
data['InterpretativeData'] = this.interpretativeData;
data['InvoiceType'] = this.invoiceType;
data['IsCertificateAllowed'] = this.isCertificateAllowed;
data['IsLabTestAttachment'] = this.isLabTestAttachment;
data['IsPregnant'] = this.isPregnant;
data['IsVisibleComponent'] = this.isVisibleComponent;
data['LineItemNo'] = this.lineItemNo;
data['MaleInterpretativeData'] = this.maleInterpretativeData;
data['NeedMedicalVerificationForAbnResult'] = this.needMedicalVerificationForAbnResult;
data['Notes'] = this.notes;
data['OrderLineItemNo'] = this.orderLineItemNo;
data['OrderNo'] = this.orderNo;
data['PackageID'] = this.packageID;
data['PackageName'] = this.packageName;
data['PackageShortDescription'] = this.packageShortDescription;
data['PatientID'] = this.patientID;
data['ProjectID'] = this.projectID;
data['ReceivedOn'] = this.receivedOn;
data['ReferanceRange'] = this.referanceRange;
data['ReferenceHigh'] = this.referenceHigh;
data['ReferenceLow'] = this.referenceLow;
data['RegisteredOn'] = this.registeredOn;
data['ReportedOn'] = this.reportedOn;
data['ResultSymbol'] = this.resultSymbol;
data['ResultTypeID'] = this.resultTypeID;
data['ResultValue'] = this.resultValue;
data['ResultValueBasedLineItemNo'] = this.resultValueBasedLineItemNo;
data['ResultValueFlag'] = this.resultValueFlag;
data['RptTestCode'] = this.rptTestCode;
data['SampleCollectedOn'] = this.sampleCollectedOn;
data['SampleReceivedOn'] = this.sampleReceivedOn;
data['SetupID'] = this.setupID;
data['Status'] = this.status;
data['StatusDesc'] = this.statusDesc;
data['StatusDescription'] = this.statusDescription;
data['SubHeader'] = this.subHeader;
data['SuperVerifiedOn'] = this.superVerifiedOn;
data['TestCode'] = this.testCode;
data['TestID'] = this.testID;
data['TestShortDescription'] = this.testShortDescription;
data['UOM'] = this.uOM;
data['UploadedDocuments'] = this.uploadedDocuments;
data['VerifiedOn'] = this.verifiedOn;
data['VerifiedOnDateTime'] = this.verifiedOnDateTime;
data['ChangeResult'] = this.changeResult;
data['CriticalHigh'] = this.criticalHigh;
data['ReferenceHigh'] = this.referenceHigh;
data['CriticalLow'] = this.criticalLow;
data['ReferenceLow'] = this.referenceLow;
data['TestID'] = this.testId;
data['TestShortDescription'] = this.testShortDescription;
data['PackageName'] = this.PackageName;
return data;
}
@ -145,3 +254,151 @@ class LabResult {
return 'LabOrderResult(flag: $calculatedResultFlag, value: $resultValue, verifiedOn: $verifiedOnDateTime)';
}
}
// class LabResult {
// String? description;
// dynamic femaleInterpretativeData;
// int? gender;
// int? lineItemNo;
// dynamic maleInterpretativeData;
// dynamic notes;
// String? packageID;
// int? patientID;
// String? projectID;
// String? referanceRange;
// String? resultValue;
// String? sampleCollectedOn;
// String? sampleReceivedOn;
// String? setupID;
// dynamic superVerifiedOn;
// String? testCode;
// String? uOM;
// String? verifiedOn;
// String? verifiedOnDateTime;
// String? changeResult;
// String? calculatedResultFlag;
// String? criticalHigh;
// String? referenceHigh;
// String? criticalLow;
// String? referenceLow;
// num? resultTypeID;
// String? packageShortDescription;
// int? testId;
// String? testShortDescription;
// String? PackageName;
//
// LabResult(
// {this.description,
// this.femaleInterpretativeData,
// this.gender,
// this.lineItemNo,
// this.maleInterpretativeData,
// this.notes,
// this.packageID,
// this.patientID,
// this.projectID,
// this.referanceRange,
// this.resultValue,
// this.sampleCollectedOn,
// this.sampleReceivedOn,
// this.setupID,
// this.superVerifiedOn,
// this.testCode,
// this.uOM,
// this.verifiedOn,
// this.calculatedResultFlag,
// this.verifiedOnDateTime,
// this.criticalHigh,
// this.referenceHigh,
// this.criticalLow,
// this.referenceLow,
// this.testId,
// this.testShortDescription,
// this.PackageName
// });
//
// LabResult.fromJson(Map<String, dynamic> json) {
// description = json['Description'];
// femaleInterpretativeData = json['FemaleInterpretativeData'];
// gender = json['Gender'];
// lineItemNo = json['LineItemNo'];
// maleInterpretativeData = json['MaleInterpretativeData'];
// notes = json['Notes'];
// packageID = json['PackageID'];
// patientID = json['PatientID'];
// projectID = json['ProjectID'];
// referanceRange = json['ReferanceRange'];
// resultValue = json['ResultValue'];
// sampleCollectedOn = json['SampleCollectedOn'];
// sampleReceivedOn = json['SampleReceivedOn'];
// setupID = json['SetupID'];
// superVerifiedOn = json['SuperVerifiedOn'];
// testCode = json['TestCode'];
// uOM = json['UOM'];
// verifiedOn = json['VerifiedOn'];
// verifiedOnDateTime = json['VerifiedOnDateTime'];
// changeResult = json['ChangeResult'];
// calculatedResultFlag = json['CalculatedResultFlag'];
// criticalHigh = json['CriticalHigh'];
// referenceHigh = json['ReferenceHigh'];
// criticalLow = json['CriticalLow'];
// referenceLow = json['ReferenceLow'];
// packageShortDescription = json['PackageShortDescription'];
// resultTypeID = json['ResultTypeID'];
// testId = json['TestID'];
// testShortDescription = json['TestShortDescription'];
// PackageName = json['PackageName'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// data['Description'] = this.description;
// data['FemaleInterpretativeData'] = this.femaleInterpretativeData;
// data['Gender'] = this.gender;
// data['LineItemNo'] = this.lineItemNo;
// data['MaleInterpretativeData'] = this.maleInterpretativeData;
// data['Notes'] = this.notes;
// data['PackageID'] = this.packageID;
// data['PatientID'] = this.patientID;
// data['ProjectID'] = this.projectID;
// data['ReferanceRange'] = this.referanceRange;
// data['ResultValue'] = this.resultValue;
// data['SampleCollectedOn'] = this.sampleCollectedOn;
// data['SampleReceivedOn'] = this.sampleReceivedOn;
// data['SetupID'] = this.setupID;
// data['SuperVerifiedOn'] = this.superVerifiedOn;
// data['TestCode'] = this.testCode;
// data['UOM'] = this.uOM;
// data['VerifiedOn'] = this.verifiedOn;
// data['VerifiedOnDateTime'] = this.verifiedOnDateTime;
// data['ChangeResult'] = this.changeResult;
// data['CriticalHigh'] = this.criticalHigh;
// data['ReferenceHigh'] = this.referenceHigh;
// data['CriticalLow'] = this.criticalLow;
// data['ReferenceLow'] = this.referenceLow;
// data['TestID'] = this.testId;
// data['TestShortDescription'] = this.testShortDescription;
// data['PackageName'] = this.PackageName;
// return data;
// }
//
// bool checkIfGraphShouldBeDisplayed(){
// if (resultTypeID == null) return false;
// if (resultTypeID == 6) return false;
// if (referanceRange == null || referanceRange == "" || referanceRange == "\n") return false;
// bool isDigit = RegExp(r"\\d+").hasMatch("$resultValue");
// if(isDigit) return true;
// try {
// num.parse(resultValue ?? "");
// } catch (e) {
// return false;
// }
//
// return true;
// }
//
// @override
// String toString() {
// return 'LabOrderResult(flag: $calculatedResultFlag, value: $resultValue, verifiedOn: $verifiedOnDateTime)';
// }
// }

@ -0,0 +1,44 @@
class PatientLabResultPDFAttachmentResponse {
List<Data>? data;
PatientLabResultPDFAttachmentResponse({this.data});
PatientLabResultPDFAttachmentResponse.fromJson(Map<String, dynamic> json) {
if (json['data'] != null) {
data = <Data>[];
json['data'].forEach((v) {
data!.add(new Data.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.data != null) {
data['data'] = this.data!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Data {
String? base64Content;
String? fileName;
int? fileSize;
Data({this.base64Content, this.fileName, this.fileSize});
Data.fromJson(Map<String, dynamic> json) {
base64Content = json['base64Content'];
fileName = json['fileName'];
fileSize = json['fileSize'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['base64Content'] = base64Content;
data['fileName'] = fileName;
data['fileSize'] = fileSize;
return data;
}
}

@ -1951,5 +1951,6 @@ abstract class LocaleKeys {
static const viewPatientQR = 'viewPatientQR';
static const patientQR = 'patientQR';
static const forText = 'forText';
static const viewAttachment = 'viewAttachment';
}

@ -1,8 +1,5 @@
import 'dart:ui' as ui;
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
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_view_model.dart';
@ -11,7 +8,6 @@ import 'package:hmg_patient_app_new/presentation/lab/lab_result_via_clinic/lab_o
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/date_range_selector/viewmodel/date_range_view_model.dart';
import 'package:provider/provider.dart';
import '../../../core/dependencies.dart' show getIt;
import '../../../core/utils/size_utils.dart' show ResponsiveExtension;
import '../../../generated/locale_keys.g.dart' show LocaleKeys;

@ -1,5 +1,6 @@
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_assets.dart';
import 'package:hmg_patient_app_new/core/app_export.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
@ -11,9 +12,12 @@ import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/lab/lab_view_model.dart' show LabViewModel;
import 'package:hmg_patient_app_new/features/lab/models/resp_models/lab_result.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.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/buttons/custom_button.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:open_filex/open_filex.dart';
import 'package:provider/provider.dart';
import 'dart:ui' as ui;
@ -116,9 +120,11 @@ class LabOrderResultItem extends StatelessWidget {
SizedBox(height: 12.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: [
Flexible(
flex: 2,
flex: (tests?.isLabTestAttachment ?? false) ? 1 : 2,
child: Visibility(
visible: tests?.checkIfGraphShouldBeDisplayed() == true,
child: Column(
@ -134,7 +140,7 @@ class LabOrderResultItem extends StatelessWidget {
),
),
Flexible(
flex:2,
flex: 2,
child: Visibility(
visible: tests?.checkIfGraphShouldBeDisplayed() == true,
child: CustomButton(
@ -148,14 +154,73 @@ class LabOrderResultItem extends StatelessWidget {
backgroundColor: AppColors.infoColor.withAlpha(20),
borderColor: AppColors.infoColor.withAlpha(0),
textColor: AppColors.infoColor,
fontSize: 14,
fontSize: 13.f,
fontWeight: FontWeight.w600,
borderRadius: 12,
borderRadius: 12.r,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
height: 40.h,
),
),
),
if (tests?.isLabTestAttachment ?? false)
Flexible(
flex: 2,
child: Visibility(
visible: tests?.checkIfGraphShouldBeDisplayed() == true,
child: CustomButton(
icon: AppAssets.document,
iconColor: AppColors.primaryRedColor,
iconSize: 16.h,
text: LocaleKeys.viewAttachment.tr(context: context),
onPressed: () async {
if (Utils.isVidaPlusProject(int.parse(tests!.projectID!))) {
} else {
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.generatingReport.tr(context: context));
await getIt
.get<LabViewModel>()
.getLabResultAttachmentPDF(
labResult: tests!,
selectedIndex: 0,
onError: (err) {
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: err),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
})
.then((val) async {
LoaderBottomSheet.hideLoader();
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,
);
}
}
});
}
},
backgroundColor: AppColors.primaryRedColor.withAlpha(20),
borderColor: AppColors.primaryRedColor.withAlpha(0),
textColor: AppColors.primaryRedColor,
fontSize: 13.f,
fontWeight: FontWeight.w600,
borderRadius: 12.r,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
height: 40.h,
),
),
),
],
),
],

Loading…
Cancel
Save