From 4901163b7c5ea824cbaff51104bbf551b3ffa372 Mon Sep 17 00:00:00 2001 From: Haroon Amjad <> Date: Mon, 27 Jul 2026 15:27:50 +0300 Subject: [PATCH] Inpatient services contd. --- assets/langs/ar-SA.json | 6 +- assets/langs/en-US.json | 5 +- .../inpatient_services_repo.dart | 214 +++++++++++++++++- .../inpatient_services_view_model.dart | 211 ++++++++++++++++- ...atient_advance_history_response_model.dart | 71 ++++++ ...tient_advance_requests_response_model.dart | 74 ++++++ ...t_medical_instructions_response_model.dart | 85 +++++++ lib/generated/locale_keys.g.dart | 1 + lib/presentation/home/landing_page.dart | 1 + .../general_instructions_page.dart | 21 +- .../inpatient_advance_payment_page.dart | 45 ++++ .../inpatient_services_homepage.dart | 122 +++++++++- .../medical_instructions_page.dart | 62 +++++ .../patient_relation_office_widget.dart | 103 +++++++++ 14 files changed, 992 insertions(+), 29 deletions(-) create mode 100644 lib/features/inpatient_services/models/get_inpatient_advance_history_response_model.dart create mode 100644 lib/features/inpatient_services/models/get_inpatient_advance_requests_response_model.dart create mode 100644 lib/features/inpatient_services/models/get_medical_instructions_response_model.dart create mode 100644 lib/presentation/inpatient_services/inpatient_advance_payment_page.dart create mode 100644 lib/presentation/inpatient_services/medical_instructions_page.dart create mode 100644 lib/presentation/inpatient_services/widgets/patient_relation_office_widget.dart diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 905aa11a..2026e85c 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -2008,10 +2008,10 @@ "copyLink": "نسخ الوصلة:", "paymentLinkCopied": "تم نسخ رابط الدفع إلى الحافظة الخاصة بك!", "copyLinkTxt": "أو يمكنك نسخ رابط الدفع من الأسفل وإرساله إلى شخص يمكنه الدفع نيابة عنك:", - "proErrorMessage": "عزيزي المريض ، طاقم العمل لدينا خارج المكتب حاليًا ، يرجى ملاحظة أن ساعات العمل لدينا من 7:00 صباحًا إلى 10:00 مساءً ، ويسعدنا مساعدتك خلال هذا الوقت ، أو يمكنك الاتصال بـ <أدخل الرقم هنا>", + "proErrorMessage": "عزيزي المريض ، طاقم العمل لدينا خارج المكتب حاليًا ، يرجى ملاحظة أن ساعات العمل لدينا من 7:00 صباحًا إلى 10:00 مساءً ، ويسعدنا مساعدتك خلال هذا الوقت ، أو يمكنك الاتصال", "InPatient": "مريض منوم", "admissionReq": "طلب القبول", "admissionDate": "تاريخ القبول", - "admissionRequestDate": "تاريخ القبول المتوقع" - + "admissionRequestDate": "تاريخ القبول المتوقع", + "noAdvancePaymentRequestsFound": "ليس لديك أي طلبات دفع مسبق حتى الآن." } diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 2b72c5ef..59b8dc1c 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -1998,11 +1998,12 @@ "copyLink": "COPY LINK", "paymentLinkCopied": "Payment link copied to your clipboard!'", "copyLinkTxt": "Or you can copy the payment link from below & send it to someone who can pay on your behalf: ", - "proErrorMessage": "Dear patient, Our staff is currently out of office, please note that our working hours are from 7:00 AM to 10:00 PM, and we'd love to help you during that time, or you can call ", + "proErrorMessage": "Dear patient, Our staff is currently out of office, please note that our working hours are from 7:00 AM to 10:00 PM, and we'd love to help you during that time, or you can call us.", "InPatient": "InPatient", "admissionReq": "Admission Request", "admissionDate": "Admission Date", - "admissionRequestDate": "Expected Admission Date" + "admissionRequestDate": "Expected Admission Date", + "noAdvancePaymentRequestsFound": "You don't have any advance payment requests yet." } diff --git a/lib/features/inpatient_services/inpatient_services_repo.dart b/lib/features/inpatient_services/inpatient_services_repo.dart index 67fc02b2..997c1cec 100644 --- a/lib/features/inpatient_services/inpatient_services_repo.dart +++ b/lib/features/inpatient_services/inpatient_services_repo.dart @@ -3,16 +3,41 @@ import 'package:hmg_patient_app_new/core/api/api_client.dart'; import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart'; import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; +import 'package:hmg_patient_app_new/features/inpatient_services/models/get_admission_info_response_model.dart'; import 'package:hmg_patient_app_new/features/inpatient_services/models/get_general_instructions_response_model.dart'; +import 'package:hmg_patient_app_new/features/inpatient_services/models/get_inpatient_advance_requests_response_model.dart'; +import 'package:hmg_patient_app_new/features/inpatient_services/models/get_medical_instructions_response_model.dart'; import 'package:hmg_patient_app_new/services/logger_service.dart'; abstract class InpatientServicesRepo { Future>> checkIfIsInPatient(); Future>>> getGeneralInstructions({required int projectID}); -} -// List getGeneralInstructionsList = []; + Future>>> getMedicalInstructions({required int projectID}); + + Future>> getDischargeMedicationOrder({required GetAdmissionInfoResponseModel getAdmissionInfoResponseModel}); + + Future>> insertInPatientOrder( + {required GetAdmissionInfoResponseModel getAdmissionInfoResponseModel, + required int typeID, + required String patientName, + required String patientNameAR, + required String patientMobileNo, + required String comments}); + + Future>> getInPatientAdvancePaymentRequests({ + required int projectID, + required int admissionNo, + required int admissionReqNo, + }); + + Future>> getInPatientAdvancePaymentPaid({ + required int projectID, + required int admissionNo, + required int admissionReqNo, + }); +} class InpatientServicesRepoImp implements InpatientServicesRepo { final ApiClient apiClient; @@ -92,4 +117,189 @@ class InpatientServicesRepoImp implements InpatientServicesRepo { return Left(UnknownFailure(e.toString())); } } + + @override + Future>>> getMedicalInstructions({required int projectID}) async { + Map mapDevice = {"ProjectID": projectID}; + + try { + GenericApiModel>? apiResponse; + Failure? failure; + await apiClient.post( + GET_MEDICAL_INSTRUCTIONS, + body: mapDevice, + onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, + onSuccess: (response, statusCode, {messageStatus, errorMessage}) { + try { + List getMedicalInstructionsList = []; + response['MedicalInstruction'].forEach((v) { + getMedicalInstructionsList.add(GetMedicalInstructions.fromJson(v)); + }); + + apiResponse = GenericApiModel>( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: getMedicalInstructionsList, + ); + } 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())); + } + } + + @override + Future> getDischargeMedicationOrder({required GetAdmissionInfoResponseModel getAdmissionInfoResponseModel}) async { + Map mapDevice = { + "ProjectID": getAdmissionInfoResponseModel.projectID, + "ClinicID": getAdmissionInfoResponseModel.clinicID, + "DoctorID": getAdmissionInfoResponseModel.doctorID, + "AdmissionNo": getAdmissionInfoResponseModel.admissionNo + }; + + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post(INPATIENT_DISCHARGE_MEDICATIONS, body: mapDevice, onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, onSuccess: (response, statusCode, {messageStatus, errorMessage}) { + try { + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: response, + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, isAllowAny: true); + if (failure != null) return Left(failure!); + if (apiResponse == null) return Left(ServerFailure("Unknown error")); + return Right(apiResponse!); + } catch (e) { + return Left(UnknownFailure(e.toString())); + } + } + + @override + Future> insertInPatientOrder( + {required GetAdmissionInfoResponseModel getAdmissionInfoResponseModel, + required int typeID, + required String patientName, + required String patientNameAR, + required String patientMobileNo, + required String comments}) async { + Map mapDevice = { + "ProjectID": getAdmissionInfoResponseModel.projectID, + "TypeID": typeID, + "RoomNo": getAdmissionInfoResponseModel.roomID, + "GenderId": 2, + "AdmissionNo": getAdmissionInfoResponseModel.admissionNo, + "prescriptionNo": 250420, + "patientName": patientName, + "patientNameN": patientNameAR, + "PatientMobileNumber": patientMobileNo, + "comments": comments + }; + + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post(INSERT_INPATIENT_ORDER, body: mapDevice, onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, onSuccess: (response, statusCode, {messageStatus, errorMessage}) { + try { + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: response, + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, isAllowAny: true); + if (failure != null) return Left(failure!); + if (apiResponse == null) return Left(ServerFailure("Unknown error")); + return Right(apiResponse!); + } catch (e) { + return Left(UnknownFailure(e.toString())); + } + } + + @override + Future> getInPatientAdvancePaymentRequests({required int projectID, required int admissionNo, required int admissionReqNo}) async { + Map mapDevice = { + "ProjectID": projectID, + "AdmissionReqNo": admissionReqNo, + "AdmissionNo": admissionNo, + }; + + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post(GET_INPATIENT_ADVANCE_PAYMENT_REQUESTS, body: mapDevice, onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, onSuccess: (res, statusCode, {messageStatus, errorMessage}) { + try { + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: res, + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, isAllowAny: true); + if (failure != null) return Left(failure!); + if (apiResponse == null) return Left(ServerFailure("Unknown error")); + return Right(apiResponse!); + } catch (e) { + return Left(UnknownFailure(e.toString())); + } + } + + @override + Future> getInPatientAdvancePaymentPaid({required int projectID, required int admissionNo, required int admissionReqNo}) async { + Map mapDevice = { + "ProjectID": projectID, + "AdmissionReqNo": admissionReqNo, + "AdmissionNo": admissionNo, + }; + + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post(GET_INPATIENT_PAID_ADVANCE_PAYMENT, body: mapDevice, onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, onSuccess: (res, statusCode, {messageStatus, errorMessage}) { + try { + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: res, + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, isAllowAny: true); + 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/inpatient_services/inpatient_services_view_model.dart b/lib/features/inpatient_services/inpatient_services_view_model.dart index 799108ee..f8da1dab 100644 --- a/lib/features/inpatient_services/inpatient_services_view_model.dart +++ b/lib/features/inpatient_services/inpatient_services_view_model.dart @@ -1,10 +1,23 @@ +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_state.dart'; +import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; +import 'package:hmg_patient_app_new/core/utils/utils.dart'; +import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/features/inpatient_services/inpatient_services_repo.dart'; import 'package:hmg_patient_app_new/features/inpatient_services/models/get_admission_info_response_model.dart'; import 'package:hmg_patient_app_new/features/inpatient_services/models/get_admission_request_info_response_model.dart'; import 'package:hmg_patient_app_new/features/inpatient_services/models/get_general_instructions_response_model.dart'; +import 'package:hmg_patient_app_new/features/inpatient_services/models/get_inpatient_advance_history_response_model.dart'; +import 'package:hmg_patient_app_new/features/inpatient_services/models/get_inpatient_advance_requests_response_model.dart'; +import 'package:hmg_patient_app_new/features/inpatient_services/models/get_medical_instructions_response_model.dart'; import 'package:hmg_patient_app_new/services/error_handler_service.dart'; +import 'package:hmg_patient_app_new/services/navigation_service.dart'; +import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; + +import '../../generated/locale_keys.g.dart'; class InpatientServicesViewModel extends ChangeNotifier { InpatientServicesRepo inpatientServicesRepo; @@ -13,12 +26,21 @@ class InpatientServicesViewModel extends ChangeNotifier { GetAdmissionInfoResponseModel? getAdmissionInfoResponseModel; GetAdmissionRequestInfoResponseModel? getAdmissionRequestInfoResponseModel; + InPatientAdvanceResponseModel? inPatientAdvanceResponseModel; + InPatientAdvanceHistoryResponseModel? inPatientAdvanceHistoryResponseModel; bool isAdmitted = false; bool hasAdmissionRequest = false; bool isGeneralInstructionsLoading = true; + bool isMedicalInstructionsLoading = true; + bool isAdvancePaymentHistoryLoading = true; + + bool hasDischargeMedicationOrder = false; List getGeneralInstructionsList = []; + List getMedicalInstructionsList = []; + + int advancePaymentSelectedTabIndex = 0; InpatientServicesViewModel({required this.inpatientServicesRepo, required this.errorHandlerService, required this.appState}); @@ -26,6 +48,21 @@ class InpatientServicesViewModel extends ChangeNotifier { isAdmitted = false; hasAdmissionRequest = false; isGeneralInstructionsLoading = true; + isMedicalInstructionsLoading = true; + hasDischargeMedicationOrder = false; + advancePaymentSelectedTabIndex = 0; + isAdvancePaymentHistoryLoading = true; + notifyListeners(); + } + + void onTabChanged(int index) { + advancePaymentSelectedTabIndex = index; + if (index == 1) { + getInPatientAdvancePaymentHistory( + projectID: isAdmitted ? getAdmissionInfoResponseModel!.projectID! : getAdmissionRequestInfoResponseModel!.projectId!, + admissionNo: isAdmitted ? getAdmissionInfoResponseModel!.admissionNo! : 0, + admissionReqNo: isAdmitted ? getAdmissionInfoResponseModel!.admissionRequestNo! : getAdmissionRequestInfoResponseModel!.admissionRequestNo!); + } notifyListeners(); } @@ -70,7 +107,6 @@ class InpatientServicesViewModel extends ChangeNotifier { getGeneralInstructionsList.clear(); notifyListeners(); - final result = await inpatientServicesRepo.getGeneralInstructions(projectID: projectID); result.fold( @@ -92,4 +128,177 @@ class InpatientServicesViewModel extends ChangeNotifier { }, ); } + + Future getMedicalInstructions({required int projectID, Function(dynamic)? onSuccess, Function(String)? onError}) async { + isMedicalInstructionsLoading = true; + getMedicalInstructionsList.clear(); + notifyListeners(); + + final result = await inpatientServicesRepo.getMedicalInstructions(projectID: projectID); + + result.fold( + (failure) async { + isMedicalInstructionsLoading = false; + notifyListeners(); + }, + (apiResponse) { + if (apiResponse.messageStatus == 2) { + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + isMedicalInstructionsLoading = false; + getMedicalInstructionsList = apiResponse.data!; + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } + + Future checkDischargeMedications({required GetAdmissionInfoResponseModel getAdmissionInfoResponseModel, Function(dynamic)? onSuccess, Function(String)? onError}) async { + LoaderBottomSheet.showLoader(); + final result = await inpatientServicesRepo.getDischargeMedicationOrder(getAdmissionInfoResponseModel: getAdmissionInfoResponseModel); + + result.fold( + (failure) async { + LoaderBottomSheet.hideLoader(); + if (onError != null) { + onError(failure.message.toString()); + } + }, + (apiResponse) async { + if (apiResponse.messageStatus == 2) { + LoaderBottomSheet.hideLoader(); + if (onError != null) { + onError("You don't have any discharge medication orders yet."); + } + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + if (apiResponse.data["PatientHasDischargeMedicineList"].length != 0) { + hasDischargeMedicationOrder = true; + + await insertInPatientOrder( + getAdmissionInfoResponseModel: getAdmissionInfoResponseModel, + typeID: 1, + patientName: "${appState.getAuthenticatedUser()!.firstName!} ${appState.getAuthenticatedUser()!.lastName!}", + patientNameAR: "${appState.getAuthenticatedUser()!.firstNameN!} ${appState.getAuthenticatedUser()!.lastNameN!}", + patientMobileNo: appState.getAuthenticatedUser()!.mobileNumber!, + comments: "I need my medicines", + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight(GetIt.instance().navigatorKey.currentContext!, + child: Utils.getSuccessWidget(loadingText: LocaleKeys.requestSubmittedSuccessfully.tr()).paddingSymmetrical(0.h, 24.h), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: false, + isAutoDismiss: true); + }); + } + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } + + Future insertInPatientOrder( + {required GetAdmissionInfoResponseModel getAdmissionInfoResponseModel, + required int typeID, + required String patientName, + required String patientNameAR, + required String patientMobileNo, + required String comments, + Function(dynamic)? onSuccess, + Function(String)? onError}) async { + final result = await inpatientServicesRepo.insertInPatientOrder( + getAdmissionInfoResponseModel: getAdmissionInfoResponseModel, typeID: typeID, patientName: patientName, patientNameAR: patientNameAR, patientMobileNo: patientMobileNo, comments: comments); + + result.fold( + (failure) async { + if (onError != null) { + onError(failure.message.toString()); + } + }, + (apiResponse) { + if (apiResponse.messageStatus == 2) { + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } + }, + ); + } + + Future getInPatientAdvancePaymentRequests({required int projectID, required int admissionNo, required int admissionReqNo, Function(dynamic)? onSuccess, Function(String)? onError}) async { + final result = await inpatientServicesRepo.getInPatientAdvancePaymentRequests(projectID: projectID, admissionNo: admissionNo, admissionReqNo: admissionReqNo); + + result.fold( + (failure) async { + notifyListeners(); + }, + (apiResponse) { + if (apiResponse.messageStatus == 2) { + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + if (apiResponse.data['responseInpatient'] != null && + apiResponse.data['responseInpatient']['responseInpatientAdvanceInfo'] != null && + apiResponse.data['responseInpatient']['responseInpatientAdvanceInfo'].length != 0) { + inPatientAdvanceResponseModel = InPatientAdvanceResponseModel.fromJson(apiResponse.data["responseInpatient"]); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } else { + if (onSuccess != null) { + onSuccess(apiResponse); + } + + // if (onError != null) { + // onError(LocaleKeys.noAdvancePaymentRequestsFound.tr()); + // } + } + notifyListeners(); + } + }, + ); + } + + Future getInPatientAdvancePaymentHistory({required int projectID, required int admissionNo, required int admissionReqNo, Function(dynamic)? onSuccess, Function(String)? onError}) async { + isAdvancePaymentHistoryLoading = true; + notifyListeners(); + + final result = await inpatientServicesRepo.getInPatientAdvancePaymentPaid(projectID: projectID, admissionNo: admissionNo, admissionReqNo: admissionReqNo); + + result.fold( + (failure) async { + isAdvancePaymentHistoryLoading = false; + notifyListeners(); + }, + (apiResponse) { + if (apiResponse.messageStatus == 2) { + // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); + } else if (apiResponse.messageStatus == 1) { + isAdvancePaymentHistoryLoading = false; + if (apiResponse.data['responseInpatient'] != null && + apiResponse.data['responseInpatient']['responseInpatientAdvanceInfo'] != null && + apiResponse.data['responseInpatient']['responseInpatientAdvanceInfo'].length != 0) { + inPatientAdvanceHistoryResponseModel = InPatientAdvanceHistoryResponseModel.fromJson(apiResponse.data["responseInpatient"]); + if (onSuccess != null) { + onSuccess(apiResponse); + } + } else { + if (onError != null) { + onError(LocaleKeys.noAdvancePaymentRequestsFound.tr()); + } + } + notifyListeners(); + } + }, + ); + } } diff --git a/lib/features/inpatient_services/models/get_inpatient_advance_history_response_model.dart b/lib/features/inpatient_services/models/get_inpatient_advance_history_response_model.dart new file mode 100644 index 00000000..d6753707 --- /dev/null +++ b/lib/features/inpatient_services/models/get_inpatient_advance_history_response_model.dart @@ -0,0 +1,71 @@ +class InPatientAdvanceHistoryResponseModel { + int? advanceNumber; + int? errorCode; + String? message; + List? responseInpatientAdvanceInfo; + int? statusCode; + + InPatientAdvanceHistoryResponseModel({this.advanceNumber, this.errorCode, this.message, this.responseInpatientAdvanceInfo, this.statusCode}); + + InPatientAdvanceHistoryResponseModel.fromJson(Map json) { + advanceNumber = json['advanceNumber']; + errorCode = json['errorCode']; + message = json['message']; + if (json['responseInpatientAdvanceInfo'] != null) { + responseInpatientAdvanceInfo = []; + json['responseInpatientAdvanceInfo'].forEach((v) { + responseInpatientAdvanceInfo!.add(new ResponseInpatientAdvanceInfo.fromJson(v)); + }); + } + statusCode = json['statusCode']; + } + + Map toJson() { + final Map data = new Map(); + data['advanceNumber'] = this.advanceNumber; + data['errorCode'] = this.errorCode; + data['message'] = this.message; + if (this.responseInpatientAdvanceInfo != null) { + data['responseInpatientAdvanceInfo'] = this.responseInpatientAdvanceInfo!.map((v) => v.toJson()).toList(); + } + data['statusCode'] = this.statusCode; + return data; + } +} + +class ResponseInpatientAdvanceInfo { + int? admissionNo; + int? admissionReqNo; + String? createdOn; + int? patientId; + int? projectId; + num? requestedAmount; + String? setupId; + int? status; + + ResponseInpatientAdvanceInfo({this.admissionNo, this.admissionReqNo, this.createdOn, this.patientId, this.projectId, this.requestedAmount, this.setupId, this.status}); + + ResponseInpatientAdvanceInfo.fromJson(Map json) { + admissionNo = json['admissionNo']; + admissionReqNo = json['admissionReqNo']; + createdOn = json['createdOn']; + patientId = json['patientId']; + projectId = json['projectId']; + requestedAmount = json['requestedAmount']; + setupId = json['setupId']; + status = json['status']; + } + + Map toJson() { + final Map data = new Map(); + data['admissionNo'] = this.admissionNo; + data['admissionReqNo'] = this.admissionReqNo; + data['createdOn'] = this.createdOn; + data['patientId'] = this.patientId; + data['projectId'] = this.projectId; + data['requestedAmount'] = this.requestedAmount; + data['setupId'] = this.setupId; + data['status'] = this.status; + return data; + } +} diff --git a/lib/features/inpatient_services/models/get_inpatient_advance_requests_response_model.dart b/lib/features/inpatient_services/models/get_inpatient_advance_requests_response_model.dart new file mode 100644 index 00000000..658cbfa3 --- /dev/null +++ b/lib/features/inpatient_services/models/get_inpatient_advance_requests_response_model.dart @@ -0,0 +1,74 @@ +class InPatientAdvanceResponseModel { + int? advanceNumber; + Null errorCode; + String? message; + List? responseInpatientAdvanceInfo; + int? statusCode; + + InPatientAdvanceResponseModel({this.advanceNumber, this.errorCode, this.message, this.responseInpatientAdvanceInfo, this.statusCode}); + + InPatientAdvanceResponseModel.fromJson(Map json) { + advanceNumber = json['advanceNumber']; + errorCode = json['errorCode']; + message = json['message']; + if (json['responseInpatientAdvanceInfo'] != null) { + responseInpatientAdvanceInfo = []; + json['responseInpatientAdvanceInfo'].forEach((v) { + responseInpatientAdvanceInfo!.add(new ResponseInpatientAdvanceInfo.fromJson(v)); + }); + } + statusCode = json['statusCode']; + } + + Map toJson() { + final Map data = new Map(); + data['advanceNumber'] = this.advanceNumber; + data['errorCode'] = this.errorCode; + data['message'] = this.message; + if (this.responseInpatientAdvanceInfo != null) { + data['responseInpatientAdvanceInfo'] = this.responseInpatientAdvanceInfo!.map((v) => v.toJson()).toList(); + } + data['statusCode'] = this.statusCode; + return data; + } +} + +class ResponseInpatientAdvanceInfo { + int? admissionNo; + int? admissionReqNo; + String? createdOn; + int? patientId; + int? projectId; + num? requestedAmount; + String? setupId; + int? status; + int? paymentRequestID; + + ResponseInpatientAdvanceInfo({this.admissionNo, this.admissionReqNo, this.createdOn, this.patientId, this.projectId, this.requestedAmount, this.setupId, this.status, this.paymentRequestID}); + + ResponseInpatientAdvanceInfo.fromJson(Map json) { + admissionNo = json['admissionNo']; + admissionReqNo = json['admissionReqNo']; + createdOn = json['createdOn']; + patientId = json['patientId']; + projectId = json['projectId']; + requestedAmount = json['requestedAmount']; + setupId = json['setupId']; + status = json['status']; + paymentRequestID = json['PaymentRequestId']; + } + + Map toJson() { + final Map data = new Map(); + data['admissionNo'] = this.admissionNo; + data['admissionReqNo'] = this.admissionReqNo; + data['createdOn'] = this.createdOn; + data['patientId'] = this.patientId; + data['projectId'] = this.projectId; + data['requestedAmount'] = this.requestedAmount; + data['setupId'] = this.setupId; + data['status'] = this.status; + data['PaymentRequestId'] = this.paymentRequestID; + return data; + } +} diff --git a/lib/features/inpatient_services/models/get_medical_instructions_response_model.dart b/lib/features/inpatient_services/models/get_medical_instructions_response_model.dart new file mode 100644 index 00000000..110975ba --- /dev/null +++ b/lib/features/inpatient_services/models/get_medical_instructions_response_model.dart @@ -0,0 +1,85 @@ +class GetMedicalInstructions { + dynamic propertyChanged; + int? admissionRequestNoField; + String? clinicNameField; + String? doctorNameField; + String? expectedAdmissionDateField; + List? medicaLInstructionsField; + dynamic medicalInstructionsXMLField; + String? medicalRemarksField; + int? projectIdField; + String? projectNameField; + String? setupIdField; + + GetMedicalInstructions( + {this.propertyChanged, + this.admissionRequestNoField, + this.clinicNameField, + this.doctorNameField, + this.expectedAdmissionDateField, + this.medicaLInstructionsField, + this.medicalInstructionsXMLField, + this.medicalRemarksField, + this.projectIdField, + this.projectNameField, + this.setupIdField}); + + GetMedicalInstructions.fromJson(Map json) { + propertyChanged = json['PropertyChanged']; + admissionRequestNoField = json['admissionRequestNoField']; + clinicNameField = json['clinicNameField']; + doctorNameField = json['doctorNameField']; + expectedAdmissionDateField = json['expectedAdmissionDateField']; + if (json['medicaLInstructions'] != null) { + medicaLInstructionsField = []; + json['medicaLInstructions'].forEach((v) { + medicaLInstructionsField!.add(new MedicaLInstructionsField.fromJson(v)); + }); + } + medicalInstructionsXMLField = json['medicalInstructionsXMLField']; + medicalRemarksField = json['medicalRemarksField']; + projectIdField = json['projectIdField']; + projectNameField = json['projectNameField']; + setupIdField = json['setupIdField']; + } + + Map toJson() { + final Map data = new Map(); + data['PropertyChanged'] = this.propertyChanged; + data['admissionRequestNoField'] = this.admissionRequestNoField; + data['clinicNameField'] = this.clinicNameField; + data['doctorNameField'] = this.doctorNameField; + data['expectedAdmissionDateField'] = this.expectedAdmissionDateField; + if (this.medicaLInstructionsField != null) { + data['medicaLInstructionsField'] = this.medicaLInstructionsField!.map((v) => v.toJson()).toList(); + } + data['medicalInstructionsXMLField'] = this.medicalInstructionsXMLField; + data['medicalRemarksField'] = this.medicalRemarksField; + data['projectIdField'] = this.projectIdField; + data['projectNameField'] = this.projectNameField; + data['setupIdField'] = this.setupIdField; + return data; + } +} + +class MedicaLInstructionsField { + Null propertyChanged; + String? descriptionField; + int? parameterCodeField; + + MedicaLInstructionsField({this.propertyChanged, this.descriptionField, this.parameterCodeField}); + + MedicaLInstructionsField.fromJson(Map json) { + propertyChanged = json['PropertyChanged']; + descriptionField = json['description']; + parameterCodeField = json['parameterCodeField']; + } + + Map toJson() { + final Map data = new Map(); + data['PropertyChanged'] = this.propertyChanged; + data['descriptionField'] = this.descriptionField; + data['parameterCodeField'] = this.parameterCodeField; + return data; + } +} diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index d3d5cd09..f39c6aea 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -1993,5 +1993,6 @@ abstract class LocaleKeys { static const admissionReq = 'admissionReq'; static const admissionDate = 'admissionDate'; static const admissionRequestDate = 'admissionRequestDate'; + static const noAdvancePaymentRequestsFound = 'noAdvancePaymentRequestsFound'; } diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index 4d3998a4..95d2d3ba 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -213,6 +213,7 @@ class _LandingPageState extends State { color: AppColors.primaryRedColor, onRefresh: () async { if (appState.isAuthenticated) { + getIt.get().checkIfIsInPatient(); // Refresh Appointments Data myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true); myAppointmentsViewModel.initAppointmentsViewModel(); diff --git a/lib/presentation/inpatient_services/general_instructions_page.dart b/lib/presentation/inpatient_services/general_instructions_page.dart index ea74329f..ce922a46 100644 --- a/lib/presentation/inpatient_services/general_instructions_page.dart +++ b/lib/presentation/inpatient_services/general_instructions_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; +import 'package:hmg_patient_app_new/core/utils/utils.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/inpatient_services/inpatient_services_view_model.dart'; @@ -41,15 +42,17 @@ class GeneralInstructionsPage extends StatelessWidget { ).paddingSymmetrical(24.h, 16.h); }, ) - : ListView.builder( - padding: EdgeInsets.zero, - shrinkWrap: true, - itemCount: inpatientServicesVM.getGeneralInstructionsList.length, - itemBuilder: (context, index) { - final instruction = inpatientServicesVM.getGeneralInstructionsList[index]; - return "• ${instruction.text}".toText16(weight: FontWeight.w500).paddingSymmetrical(24.h, 16.h); - }, - ); + : inpatientServicesVM.getGeneralInstructionsList.isNotEmpty + ? ListView.builder( + padding: EdgeInsets.zero, + shrinkWrap: true, + itemCount: inpatientServicesVM.getGeneralInstructionsList.length, + itemBuilder: (context, index) { + final instruction = inpatientServicesVM.getGeneralInstructionsList[index]; + return "• ${instruction.text}".toText16(weight: FontWeight.w500).paddingSymmetrical(24.h, 16.h); + }, + ) + : Utils.getNoDataWidget(context); }), ), ), diff --git a/lib/presentation/inpatient_services/inpatient_advance_payment_page.dart b/lib/presentation/inpatient_services/inpatient_advance_payment_page.dart new file mode 100644 index 00000000..55b53a13 --- /dev/null +++ b/lib/presentation/inpatient_services/inpatient_advance_payment_page.dart @@ -0,0 +1,45 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; +import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; +import 'package:hmg_patient_app_new/features/inpatient_services/inpatient_services_view_model.dart'; +import 'package:hmg_patient_app_new/generated/codegen_loader.g.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/custom_tab_bar.dart'; +import 'package:provider/provider.dart'; + +class InpatientAdvancePaymentPage extends StatelessWidget { + const InpatientAdvancePaymentPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.bgScaffoldColor, + body: CollapsingListView( + title: LocaleKeys.advancePayment.tr(), + child: Consumer(builder: (context, inpatientServicesVM, child) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 16.h), + CustomTabBar( + activeTextColor: Color(0xffED1C2B), + activeBackgroundColor: Color(0xffED1C2B).withValues(alpha: .1), + initialIndex: 0, + tabs: [ + CustomTabBarModel(null, LocaleKeys.requests.tr(context: context)), + CustomTabBarModel(null, LocaleKeys.history.tr(context: context)), + ], + onTabChange: (index) { + inpatientServicesVM.onTabChanged(index); + }, + ).paddingSymmetrical(24.h, 0.h), + SizedBox(height: 24.h), + ], + ); + }), + ), + ); + } +} diff --git a/lib/presentation/inpatient_services/inpatient_services_homepage.dart b/lib/presentation/inpatient_services/inpatient_services_homepage.dart index 0e869060..bde31f7a 100644 --- a/lib/presentation/inpatient_services/inpatient_services_homepage.dart +++ b/lib/presentation/inpatient_services/inpatient_services_homepage.dart @@ -9,10 +9,16 @@ 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/inpatient_services/inpatient_services_view_model.dart'; import 'package:hmg_patient_app_new/presentation/inpatient_services/general_instructions_page.dart'; +import 'package:hmg_patient_app_new/presentation/inpatient_services/inpatient_advance_payment_page.dart'; +import 'package:hmg_patient_app_new/presentation/inpatient_services/medical_instructions_page.dart'; +import 'package:hmg_patient_app_new/presentation/inpatient_services/widgets/patient_relation_office_widget.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/common_bottom_sheet.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../../generated/locale_keys.g.dart'; @@ -64,7 +70,17 @@ class InpatientServicesHomepage extends StatelessWidget { icon: AppAssets.bloodSugarOnlyIcon, title: LocaleKeys.medicalInstructions.tr(context: context), description: LocaleKeys.trackYourGlucoseLevels.tr(context: context), - onTap: () {}, + onTap: () { + inPatientServicesViewModel.getMedicalInstructions( + projectID: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.projectID! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.projectId!); + Navigator.of(context).push( + CustomPageRoute( + page: MedicalInstructionsPage(), + ), + ); + }, ), SizedBox(height: 16.h), buildInpatientServicesCard( @@ -88,23 +104,77 @@ class InpatientServicesHomepage extends StatelessWidget { icon: AppAssets.bloodSugarOnlyIcon, title: LocaleKeys.advancePayment.tr(context: context), description: LocaleKeys.trackYourGlucoseLevels.tr(context: context), - onTap: () {}, - ), - SizedBox(height: 16.h), - buildInpatientServicesCard( - iconBgColor: AppColors.primaryRedColor, - icon: AppAssets.bloodSugarOnlyIcon, - title: LocaleKeys.admissionNoticeTitle.tr(context: context), - description: LocaleKeys.trackYourGlucoseLevels.tr(context: context), - onTap: () {}, + onTap: () { + LoaderBottomSheet.showLoader(); + inPatientServicesViewModel.getInPatientAdvancePaymentRequests( + projectID: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.projectID! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.projectId!, + admissionNo: inPatientServicesViewModel.isAdmitted ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.admissionNo! : 0, + admissionReqNo: inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.getAdmissionInfoResponseModel!.admissionRequestNo! + : inPatientServicesViewModel.getAdmissionRequestInfoResponseModel!.admissionRequestNo!, + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + Navigator.of(context).push( + CustomPageRoute( + page: InpatientAdvancePaymentPage(), + ), + ); + }, + onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget( + loadingText: err.toString(), + ), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }); + }, ), + // SizedBox(height: 16.h), + // buildInpatientServicesCard( + // iconBgColor: AppColors.primaryRedColor, + // icon: AppAssets.bloodSugarOnlyIcon, + // title: LocaleKeys.admissionNoticeTitle.tr(context: context), + // description: LocaleKeys.trackYourGlucoseLevels.tr(context: context), + // onTap: () {}, + // ), SizedBox(height: 16.h), buildInpatientServicesCard( iconBgColor: AppColors.primaryRedColor, icon: AppAssets.bloodSugarOnlyIcon, title: LocaleKeys.prescriptions.tr(context: context), description: LocaleKeys.trackYourGlucoseLevels.tr(context: context), - onTap: () {}, + onTap: () { + inPatientServicesViewModel.isAdmitted + ? inPatientServicesViewModel.checkDischargeMedications( + getAdmissionInfoResponseModel: inPatientServicesViewModel.getAdmissionInfoResponseModel!, + onError: (err) { + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget( + loadingText: err.toString(), + ), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }) + : showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget( + loadingText: LocaleKeys.onlyAdmitted.tr(context: context), + ), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }, ), SizedBox(height: 16.h), buildInpatientServicesCard( @@ -112,7 +182,35 @@ class InpatientServicesHomepage extends StatelessWidget { icon: AppAssets.bloodSugarOnlyIcon, title: LocaleKeys.patientRelationOffice.tr(context: context), description: LocaleKeys.trackYourGlucoseLevels.tr(context: context), - onTap: () {}, + onTap: () { + if (DateTime.now().hour >= 7 && DateTime.now().hour <= 22) { + showCommonBottomSheetWithoutHeight(context, + child: PatientRelationOfficeWidget( + inPatientServicesViewModel: inPatientServicesViewModel, + ), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + title: LocaleKeys.patientRelationOffice.tr(context: context)); + } else { + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getWarningWidget( + loadingText: LocaleKeys.proErrorMessage.tr(), + isShowActionButtons: true, + confirmText: LocaleKeys.callNow.tr(context: context), + onCancelTap: () { + Navigator.of(context).pop(); + }, + onConfirmTap: () async { + launchUrl(Uri.parse("tel://" + "011 525 9553")); + }), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + } + }, ), SizedBox(height: 16.h), ], diff --git a/lib/presentation/inpatient_services/medical_instructions_page.dart b/lib/presentation/inpatient_services/medical_instructions_page.dart new file mode 100644 index 00000000..b229b7fc --- /dev/null +++ b/lib/presentation/inpatient_services/medical_instructions_page.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; +import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; +import 'package:hmg_patient_app_new/core/utils/utils.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/inpatient_services/inpatient_services_view_model.dart'; +import 'package:hmg_patient_app_new/theme/colors.dart'; +import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; +import 'package:provider/provider.dart'; + +class MedicalInstructionsPage extends StatelessWidget { + const MedicalInstructionsPage({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.bgScaffoldColor, + body: CollapsingListView( + title: "Medical Instructions", + child: Padding( + padding: EdgeInsets.all(24.h), + child: Container( + decoration: RoundedRectangleBorder().toSmoothCornerDecoration( + color: AppColors.whiteColor, + borderRadius: 24.r, + hasShadow: true, + ), + child: Consumer(builder: (context, inpatientServicesVM, child) { + return inpatientServicesVM.isMedicalInstructionsLoading + ? ListView.builder( + padding: EdgeInsets.zero, + shrinkWrap: true, + itemCount: 5, + itemBuilder: (context, index) { + return Column( + children: [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit".toText16().toShimmer2(), + SizedBox( + height: 16.h, + ), + ], + ).paddingSymmetrical(24.h, 16.h); + }, + ) + : inpatientServicesVM.getMedicalInstructionsList.first.medicaLInstructionsField!.isNotEmpty + ? ListView.builder( + padding: EdgeInsets.zero, + shrinkWrap: true, + itemCount: inpatientServicesVM.getMedicalInstructionsList.first.medicaLInstructionsField!.length, + itemBuilder: (context, index) { + final instruction = inpatientServicesVM.getMedicalInstructionsList.first.medicaLInstructionsField![index]; + return "• ${instruction.descriptionField}".toText16(weight: FontWeight.w500).paddingSymmetrical(24.h, 16.h); + }, + ) + : Utils.getNoDataWidget(context); + }), + ), + ), + ), + ); + } +} diff --git a/lib/presentation/inpatient_services/widgets/patient_relation_office_widget.dart b/lib/presentation/inpatient_services/widgets/patient_relation_office_widget.dart new file mode 100644 index 00000000..0d46e733 --- /dev/null +++ b/lib/presentation/inpatient_services/widgets/patient_relation_office_widget.dart @@ -0,0 +1,103 @@ +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_state.dart'; +import 'package:hmg_patient_app_new/core/dependencies.dart'; +import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; +import 'package:hmg_patient_app_new/core/utils/utils.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/inpatient_services/inpatient_services_view_model.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/input_widget.dart'; +import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart'; + +import '../../../generated/locale_keys.g.dart'; + +class PatientRelationOfficeWidget extends StatelessWidget { + PatientRelationOfficeWidget({super.key, required this.inPatientServicesViewModel}); + + InpatientServicesViewModel inPatientServicesViewModel; + final TextEditingController notesTextController = TextEditingController(); + late AppState appState; + + @override + Widget build(BuildContext context) { + appState = getIt.get(); + return Padding( + padding: EdgeInsets.all(16.h), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "How we may assist you?".toText16(isBold: true), + SizedBox( + height: 16.h, + ), + TextInputWidget( + padding: EdgeInsets.all(8.h), + labelText: LocaleKeys.details.tr(context: context), + hintText: "", + controller: notesTextController, + keyboardType: TextInputType.text, + isEnable: true, + prefix: null, + autoFocus: true, + isAllowRadius: true, + isBorderAllowed: false, + isAllowLeadingIcon: true, + leadingIcon: AppAssets.notes_icon, + hasError: false, + errorMessage: "", + ), + SizedBox( + height: 24.h, + ), + CustomButton( + text: LocaleKeys.send.tr(context: context), + onPressed: () { + LoaderBottomSheet.showLoader(); + inPatientServicesViewModel.insertInPatientOrder( + getAdmissionInfoResponseModel: inPatientServicesViewModel.getAdmissionInfoResponseModel!, + typeID: 1, + patientName: "${appState.getAuthenticatedUser()!.firstName!} ${appState.getAuthenticatedUser()!.lastName!}", + patientNameAR: "${appState.getAuthenticatedUser()!.firstNameN!} ${appState.getAuthenticatedUser()!.lastNameN!}", + patientMobileNo: appState.getAuthenticatedUser()!.mobileNumber!, + comments: notesTextController.text, + onError: (String errorMessage) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight(GetIt.instance().navigatorKey.currentContext!, + child: Utils.getErrorWidget(loadingText: errorMessage).paddingSymmetrical(0.h, 24.h), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: false, + isAutoDismiss: true); + }, + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight(GetIt.instance().navigatorKey.currentContext!, + child: Utils.getSuccessWidget(loadingText: LocaleKeys.requestSubmittedSuccessfully.tr()).paddingSymmetrical(0.h, 24.h), callBackFunc: () { + Navigator.of(context).pop(); + }, isFullScreen: false, isCloseButtonVisible: false, isAutoDismiss: true); + }); + }, + backgroundColor: AppColors.primaryRedColor, + borderColor: AppColors.primaryRedColor, + textColor: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w600, + borderRadius: 12, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 50.h, + icon: AppAssets.sendEmailIcon, + iconColor: Colors.white, + iconSize: 18.h, + ), + ], + ), + ); + } +}