diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index 24f682b..ac1327c 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -160,7 +160,7 @@ class ApiClientImp implements ApiClient { // body['VersionID'] = ApiConsts.appVersionID.toString(); if (!isExternal) { - body['VersionID'] = "50.0"; + body['VersionID'] = "19.1"; body['Channel'] = ApiConsts.appChannelId.toString(); body['IPAdress'] = ApiConsts.appIpAddress; body['generalid'] = ApiConsts.appGeneralId; @@ -174,7 +174,7 @@ class ApiClientImp implements ApiClient { } // body['TokenID'] = "@dm!n"; - // body['PatientID'] = 4772172; + // body['PatientID'] = 3966014; // body['PatientTypeID'] = 1; // // body['PatientOutSA'] = 0; diff --git a/lib/features/lab/lab_repo.dart b/lib/features/lab/lab_repo.dart index 2618ab6..35de165 100644 --- a/lib/features/lab/lab_repo.dart +++ b/lib/features/lab/lab_repo.dart @@ -13,13 +13,12 @@ abstract class LabRepo { Future>>> getPatientLabOrders(); Future>>> getPatientLabResults(PatientLabOrdersResponseModel laborder, bool isVidaPlus, String procedureName); - Future>>> - getPatientLabResultsByHospitals( - PatientLabOrdersResponseModel laborder, bool isVidaPlus); + Future>>> getPatientLabResultsByHospitals(PatientLabOrdersResponseModel laborder, bool isVidaPlus); + + Future>>> getSpecialLabResult(PatientLabOrdersResponseModel laborder, bool isVidaPlus); + + Future>> getLabResultReportPDF({required PatientLabOrdersResponseModel labOrder}); - Future>>> - getSpecialLabResult( - PatientLabOrdersResponseModel laborder, bool isVidaPlus); } class LabRepoImp implements LabRepo { @@ -223,4 +222,10 @@ class LabRepoImp implements LabRepo { return Left(UnknownFailure(e.toString())); } } + + @override + Future>> getLabResultReportPDF({required PatientLabOrdersResponseModel labOrder}) async { + // TODO: implement getLabResultReportPDF + throw UnimplementedError(); + } } diff --git a/lib/features/prescriptions/prescriptions_repo.dart b/lib/features/prescriptions/prescriptions_repo.dart index 0c8dc93..2e3f1aa 100644 --- a/lib/features/prescriptions/prescriptions_repo.dart +++ b/lib/features/prescriptions/prescriptions_repo.dart @@ -3,6 +3,7 @@ import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart'; import 'package:dartz/dartz.dart'; +import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/features/prescriptions/models/resp_models/patient_prescriptions_response_model.dart'; import 'package:hmg_patient_app_new/features/prescriptions/models/resp_models/prescription_detail_response_model.dart'; import 'package:hmg_patient_app_new/services/logger_service.dart'; @@ -13,6 +14,8 @@ abstract class PrescriptionsRepo { Future>>> getPatientPrescriptionDetails({required PatientPrescriptionsResponseModel prescriptionsResponseModel}); Future>> getPrescriptionInstructionsPDF({required PatientPrescriptionsResponseModel prescriptionsResponseModel}); + + Future>> getPrescriptionPDF({required PatientPrescriptionsResponseModel prescriptionsResponseModel, required List prescriptionDetailsList}); } class PrescriptionsRepoImp implements PrescriptionsRepo { @@ -153,4 +156,54 @@ class PrescriptionsRepoImp implements PrescriptionsRepo { return Left(UnknownFailure(e.toString())); } } + + @override + Future> getPrescriptionPDF({required PatientPrescriptionsResponseModel prescriptionsResponseModel, required List prescriptionDetailsList}) async { + Map mapDevice = { + "AppointmentDate": prescriptionsResponseModel.appointmentDate, + "ClinicName": prescriptionsResponseModel.clinicDescription, + "DoctorName": prescriptionsResponseModel.doctorName, + "ProjectID": prescriptionsResponseModel.projectID, + "DoctorID": prescriptionsResponseModel.doctorID, + "ClinicID": prescriptionsResponseModel.clinicID, + "DateofBirth": Utils.appState.getAuthenticatedUser()!.dateofBirth, + "ListPrescriptions": prescriptionDetailsList, + "PatientIditificationNum": Utils.appState.getAuthenticatedUser()!.patientIdentificationNo, + "PatientMobileNumber": Utils.appState.getAuthenticatedUser()!.mobileNumber, + "PatientName": "${Utils.appState.getAuthenticatedUser()!.firstName!} ${Utils.appState.getAuthenticatedUser()!.lastName!}", + "To": Utils.appState.getAuthenticatedUser()!.emailAddress, + "SetupID": prescriptionsResponseModel.setupID, + "IsDownload": true, + }; + + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post( + SEND_PRESCRIPTION_EMAIL, + body: mapDevice, + onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, + onSuccess: (response, statusCode, {messageStatus, errorMessage}) { + try { + final prescriptionPDFData = response["Base64Data"]; + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: prescriptionPDFData, + ); + } 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())); + } + } } diff --git a/lib/features/prescriptions/prescriptions_view_model.dart b/lib/features/prescriptions/prescriptions_view_model.dart index 00facf1..aac25c1 100644 --- a/lib/features/prescriptions/prescriptions_view_model.dart +++ b/lib/features/prescriptions/prescriptions_view_model.dart @@ -25,6 +25,8 @@ class PrescriptionsViewModel extends ChangeNotifier { String prescriptionInstructionsPDFLink = ""; + String prescriptionPDFBase64Data = ""; + PrescriptionsViewModel({required this.prescriptionsRepo, required this.errorHandlerService}); initPrescriptionsViewModel() { @@ -150,4 +152,25 @@ class PrescriptionsViewModel extends ChangeNotifier { }, ); } + + Future getPrescriptionPDFBase64(PatientPrescriptionsResponseModel prescriptionsResponseModel, {Function(dynamic)? onSuccess, Function(String)? onError}) async { + final result = await prescriptionsRepo.getPrescriptionPDF(prescriptionsResponseModel: prescriptionsResponseModel, prescriptionDetailsList: prescriptionDetailsList); + + result.fold( + (failure) async { + onError!(failure.message); + }, + (apiResponse) { + if (apiResponse.messageStatus == 2) { + onError!(apiResponse.errorMessage!); + } else if (apiResponse.messageStatus == 1) { + prescriptionPDFBase64Data = apiResponse.data; + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } } diff --git a/lib/presentation/lab/lab_result_via_hospital/LabResultByHospital.dart b/lib/presentation/lab/lab_result_via_hospital/LabResultByHospital.dart index fb88908..c854239 100644 --- a/lib/presentation/lab/lab_result_via_hospital/LabResultByHospital.dart +++ b/lib/presentation/lab/lab_result_via_hospital/LabResultByHospital.dart @@ -2,6 +2,7 @@ import 'package:easy_localization/easy_localization.dart' show tr, StringTranslateExtension; import 'package:flutter/material.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; +import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; @@ -12,58 +13,119 @@ import 'package:hmg_patient_app_new/presentation/lab/lab_result_via_hospital/Lab import 'package:hmg_patient_app_new/presentation/lab/lab_result_via_hospital/lab_order_specialResult.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; +import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; import 'package:provider/provider.dart'; class LabResultByHospitals extends StatelessWidget { @override Widget build(BuildContext context) { - return CollapsingListView( - title: LocaleKeys.labResults.tr(), - child: SingleChildScrollView( - child: Column( - spacing: 8.h, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Selector( - selector: (_, model) => model.isLabResultByHospitalLoading, - builder: (_, isLoading, __) { - if (isLoading) { - return Column( - children: [ - LabResultItemView( - onTap: () {}, - labOrder: null, - index: 0, - isLoading: true, - ), - LabResultItemView( - onTap: () {}, - labOrder: null, - index: 0, - isLoading: true, - ), - LabResultItemView( - onTap: () {}, - labOrder: null, - index: 0, - isLoading: true, - ), - LabResultItemView( - onTap: () {}, - labOrder: null, - index: 0, - isLoading: true, - ), - ], - ); - } else { - return LabResultList(); - } - }, - ), - LabOrderSpecialResult() - ], - ).paddingAll(24.h), - )); + return Scaffold( + backgroundColor: AppColors.bgScaffoldColor, + body: Column( + children: [ + Expanded( + child: CollapsingListView( + title: LocaleKeys.labResults.tr(), + child: SingleChildScrollView( + child: Column( + spacing: 8.h, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Selector( + selector: (_, model) => model.isLabResultByHospitalLoading, + builder: (_, isLoading, __) { + if (isLoading) { + return Column( + children: [ + LabResultItemView( + onTap: () {}, + labOrder: null, + index: 0, + isLoading: true, + ), + LabResultItemView( + onTap: () {}, + labOrder: null, + index: 0, + isLoading: true, + ), + LabResultItemView( + onTap: () {}, + labOrder: null, + index: 0, + isLoading: true, + ), + LabResultItemView( + onTap: () {}, + labOrder: null, + index: 0, + isLoading: true, + ), + ], + ); + } else { + return LabResultList(); + } + }, + ), + LabOrderSpecialResult() + ], + ).paddingAll(24.h), + )), + ), + Container( + decoration: RoundedRectangleBorder().toSmoothCornerDecoration( + color: AppColors.whiteColor, + borderRadius: 24.h, + hasShadow: true, + ), + child: CustomButton( + text: "Download report".needTranslation, + onPressed: () async { + // LoaderBottomSheet.showLoader(); + // await radiologyViewModel.getRadiologyPDF(patientRadiologyResponseModel: widget.patientRadiologyResponseModel, authenticatedUser: _appState.getAuthenticatedUser()!, onError: (err) { + // LoaderBottomSheet.hideLoader(); + // showCommonBottomSheetWithoutHeight( + // context, + // child: Utils.getErrorWidget(loadingText: err), + // callBackFunc: () {}, + // isFullScreen: false, + // isCloseButtonVisible: true, + // ); + // }).then((val) async { + // LoaderBottomSheet.hideLoader(); + // if (radiologyViewModel.patientRadiologyReportPDFBase64.isNotEmpty) { + // String path = await Utils.createFileFromString(radiologyViewModel.patientRadiologyReportPDFBase64, "pdf"); + // try { + // OpenFilex.open(path); + // } catch (ex) { + // showCommonBottomSheetWithoutHeight( + // context, + // child: Utils.getErrorWidget(loadingText: "Cannot open file".needTranslation), + // callBackFunc: () {}, + // isFullScreen: false, + // isCloseButtonVisible: true, + // ); + // } + // } + // }); + }, + backgroundColor: AppColors.successColor, + borderColor: AppColors.successColor, + textColor: AppColors.whiteColor, + fontSize: 16, + fontWeight: FontWeight.w500, + borderRadius: 12, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 45.h, + icon: AppAssets.download, + iconColor: AppColors.whiteColor, + iconSize: 20.h, + ).paddingSymmetrical(24.h, 24.h), + ), + ], + ), + ); } } diff --git a/lib/presentation/medical_file/widgets/patient_sick_leave_card.dart b/lib/presentation/medical_file/widgets/patient_sick_leave_card.dart index 87794ef..a818ae5 100644 --- a/lib/presentation/medical_file/widgets/patient_sick_leave_card.dart +++ b/lib/presentation/medical_file/widgets/patient_sick_leave_card.dart @@ -77,6 +77,7 @@ class PatientSickLeaveCard extends StatelessWidget { AppCustomChipWidget( icon: AppAssets.doctor_calendar_icon, labelText: DateUtil.formatDateToDate(DateUtil.convertStringToDate(patientSickLeavesResponseModel.appointmentDate), false), + labelPadding: EdgeInsetsDirectional.only(start: -4.h, end: 8.h), ).toShimmer2(isShow: isLoading), AppCustomChipWidget(labelText: isLoading ? "Pending Activation" : patientSickLeavesResponseModel.clinicName!).toShimmer2(isShow: isLoading), ], diff --git a/lib/presentation/prescriptions/prescription_detail_page.dart b/lib/presentation/prescriptions/prescription_detail_page.dart index 0d2b0ff..473f79a 100644 --- a/lib/presentation/prescriptions/prescription_detail_page.dart +++ b/lib/presentation/prescriptions/prescription_detail_page.dart @@ -22,6 +22,7 @@ import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.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/shimmer/movies_shimmer_widget.dart'; +import 'package:open_filex/open_filex.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -127,6 +128,7 @@ class _PrescriptionDetailPageState extends State { AppCustomChipWidget( icon: AppAssets.doctor_calendar_icon, labelText: DateUtil.formatDateToDate(DateUtil.convertStringToDate(widget.prescriptionsResponseModel.appointmentDate), false), + labelPadding: EdgeInsetsDirectional.only(start: -4.h, end: 8.h), ), AppCustomChipWidget( labelText: widget.prescriptionsResponseModel.clinicDescription!, @@ -141,6 +143,41 @@ class _PrescriptionDetailPageState extends State { ), ], ), + SizedBox(height: 16.h), + CustomButton( + text: "Download Prescription".needTranslation, + onPressed: () async { + LoaderBottomSheet.showLoader(); + await prescriptionVM.getPrescriptionPDFBase64(widget.prescriptionsResponseModel).then((val) async { + LoaderBottomSheet.hideLoader(); + if (prescriptionVM.prescriptionPDFBase64Data.isNotEmpty) { + String path = await Utils.createFileFromString(prescriptionVM.prescriptionPDFBase64Data, "pdf"); + try { + OpenFilex.open(path); + } catch (ex) { + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: "Cannot open file".needTranslation), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + } + } + }); + }, + backgroundColor: AppColors.successColor.withValues(alpha: 0.15), + borderColor: AppColors.successColor.withValues(alpha: 0.01), + textColor: AppColors.successColor, + fontSize: 14, + fontWeight: FontWeight.w500, + borderRadius: 12, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 40.h, + icon: AppAssets.download, + iconColor: AppColors.successColor, + iconSize: 14.h, + ), ], ), ), diff --git a/lib/presentation/radiology/radiology_result_page.dart b/lib/presentation/radiology/radiology_result_page.dart index e15c8d6..df34164 100644 --- a/lib/presentation/radiology/radiology_result_page.dart +++ b/lib/presentation/radiology/radiology_result_page.dart @@ -68,7 +68,7 @@ class _RadiologyResultPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox(height: 16.h), - widget.patientRadiologyResponseModel.description!.toText16(isBold: true), + // widget.patientRadiologyResponseModel.description!.toText16(isBold: true), SizedBox(height: 8.h), widget.patientRadiologyResponseModel.reportData!.trim().toText12(isBold: true, color: AppColors.textColorLight), SizedBox(height: 16.h),