From dd79b1dfca1aa453faafc64bf0f538df19ed5887 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 15 Aug 2023 09:39:56 +0300 Subject: [PATCH] InPatient pending advance payment done --- lib/config/config.dart | 4 +- lib/config/localized_values.dart | 6 +- lib/core/service/client/base_app_client.dart | 2 +- ...tient_advance_requests_response_model.dart | 71 ++++++ .../inpatient_pending_advance_payment.dart | 212 +++++++++++++++++- .../inpatient_advance_payment.dart | 10 +- .../InPatientServices/inpatient_home.dart | 26 ++- .../clinic_services/get_clinic_service.dart | 14 ++ lib/uitl/translations_delegate_base.dart | 3 + 9 files changed, 338 insertions(+), 10 deletions(-) create mode 100644 lib/models/InPatientServices/get_inpatient_advance_requests_response_model.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 59773264..da9781e8 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -611,9 +611,11 @@ var CHECK_IF_PATIENT_ADMITTED = 'Services/Inps.svc/REST/chekIsPatientAdmitted'; // Get General Instructions API var GET_GENERAL_INSTRUCTIONS = 'Services/INPs.svc/REST/getGeneralInstructions'; -// Get General Instructions API +// Get Medical Instructions API var GET_MEDICAL_INSTRUCTIONS = 'Services/INPs.svc/REST/getPatientAdmissionRequest'; +var GET_INPATIENT_ADVANCE_PAYMENT_REQUESTS = 'Services/INPs.svc/REST/getInpatientAdvancePendingPayment'; + var INSERT_INPATIENT_ORDER = 'Services/INPs.svc/REST/Inpcp_insertOrder'; var GET_BIRTH_NOTIFICATION = 'Services/INPs.svc/REST/getBirthNotification_bymothermrn'; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 7e7d6767..95ee02e4 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -175,7 +175,7 @@ const Map localizedValues = { "reminderCancelSuccess": {"en": "The reminder has been cancelled successfully", "ar": "تم إلغاء التذكير بنجاح"}, "patientShareToDo": {"en": "Amount before tax: ", "ar": "المبلغ قبل الضريبة:"}, "patientTaxToDo": {"en": "Tax amount: ", "ar": "قيمة الضريبة:"}, - "patientShareTotalToDo": {"en": "Total amount Due: ", "ar": "المبلغ الإجمالي المستحق:"}, + "patientShareTotalToDo": {"en": "Total amount due: ", "ar": "المبلغ الإجمالي المستحق:"}, 'paymentMethod': {'en': 'Payment Method', 'ar': 'طريقة الدفع او السداد'}, 'noNeedToWaitInLine': {'en': 'No need to stand in line.', 'ar': 'لا داعي للوقوف في الطابور.'}, 'useQRAppoAttend': {'en': 'Use the QR code to register the appointment attendance.', 'ar': 'استخدم الكود لتسجيل الحضور في المستشفى.'}, @@ -1923,7 +1923,9 @@ const Map localizedValues = { "isFasting": {"en": "Are you fasting?", "ar": "هل أنت صائم؟"}, "noGeneralInstructions": {"en": "You do not have any general instructions right now.", "ar": "ليس لديك أي تعليمات عامة في الوقت الحالي."}, "noMedicalInstructions": {"en": "You do not have any medical instructions right now.", "ar": "ليس لديك أي تعليمات طبية في الوقت الحالي."}, - "medicalInstructions": {"en": "Medical Instructions:", "ar": "تعليمات طبية:"}, "generalInstructions": {"en": "General Instructions:", "ar": "تعليمات عامة:"}, + "copyLink": {"en": "COPY LINK", "ar": "نسخ الوصلة:"}, + "paymentLinkCopied": {"en": "Payment link copied to your clipboard!'", "ar": "تم نسخ رابط الدفع إلى الحافظة الخاصة بك!"}, + "copyLinkTxt": {"en": "Or you can copy the payment link from below & send it to someone who can pay on your behalf: ", "ar": "أو يمكنك نسخ رابط الدفع من الأسفل وإرساله إلى شخص يمكنه الدفع نيابة عنك:"}, }; \ No newline at end of file diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 7b8874d3..bd53bcf2 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -152,7 +152,7 @@ class BaseAppClient { // body['PatientID'] = 2480363; //3844083 // body['TokenID'] = "@dm!n"; - // body['PatientID'] = 3649689; //3844083 + // body['PatientID'] = 4767347; //3844083 // body['AdmissionNo'] = 2023000040; //3844083 // body['TokenID'] = "@dm!n"; diff --git a/lib/models/InPatientServices/get_inpatient_advance_requests_response_model.dart b/lib/models/InPatientServices/get_inpatient_advance_requests_response_model.dart new file mode 100644 index 00000000..a78f116b --- /dev/null +++ b/lib/models/InPatientServices/get_inpatient_advance_requests_response_model.dart @@ -0,0 +1,71 @@ +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; + int 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/pages/InPatientServices/components/inpatient_pending_advance_payment.dart b/lib/pages/InPatientServices/components/inpatient_pending_advance_payment.dart index 0db5bb17..35620ea0 100644 --- a/lib/pages/InPatientServices/components/inpatient_pending_advance_payment.dart +++ b/lib/pages/InPatientServices/components/inpatient_pending_advance_payment.dart @@ -1,15 +1,223 @@ +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/InPatientServices/get_inpatient_advance_requests_response_model.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:provider/provider.dart'; class InPatientPendingAdvancePayment extends StatefulWidget { - const InPatientPendingAdvancePayment({Key key}) : super(key: key); + InPatientAdvanceResponseModel inPatientAdvanceResponseModel; + + InPatientPendingAdvancePayment({@required this.inPatientAdvanceResponseModel}); @override State createState() => _InPatientPendingAdvancePaymentState(); } class _InPatientPendingAdvancePaymentState extends State { + ProjectViewModel projectViewModel; + InAppBrowser browser = new InAppBrowser(); + + var _InAppBrowserOptions = InAppBrowserClassOptions( + inAppWebViewGroupOptions: InAppWebViewGroupOptions( + crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true, transparentBackground: false), + ios: IOSInAppWebViewOptions(applePayAPIEnabled: true, isFraudulentWebsiteWarningEnabled: false)), + crossPlatform: InAppBrowserOptions(hideUrlBar: true, toolbarTopBackgroundColor: Colors.black), + android: AndroidInAppBrowserOptions(), + ios: + IOSInAppBrowserOptions(hideToolbarBottom: true, toolbarBottomBackgroundColor: Colors.white, closeButtonColor: Colors.white, presentationStyle: IOSUIModalPresentationStyle.OVER_FULL_SCREEN)); + + @override + void initState() { + browser = new InAppBrowser(); + super.initState(); + } + @override Widget build(BuildContext context) { - return Container(); + projectViewModel = Provider.of(context); + return Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + child: Container( + decoration: cardRadius(12), + margin: EdgeInsets.zero, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Payment request for: ", + // TranslationBase.of(context).covidBookAppo, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + letterSpacing: -0.64, + ), + ), + mHeight(6), + Row( + children: [ + Text( + TranslationBase.of(context).patientName + ":", + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 10, + letterSpacing: -0.6, + color: CustomColors.grey, + ), + ), + mWidth(3), + Text( + projectViewModel.user.firstName + " " + projectViewModel.user.lastName, + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 12, + letterSpacing: -0.48, + ), + ), + ], + ), + Row( + children: [ + Text( + TranslationBase.of(context).identificationNumber + ":", + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 10, + letterSpacing: -0.6, + color: CustomColors.grey, + ), + ), + mWidth(3), + Text( + projectViewModel.user.patientIdentificationNo, + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 12, + letterSpacing: -0.48, + ), + ), + ], + ), + Row( + children: [ + Text( + TranslationBase.of(context).mrn + ":", + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 10, + letterSpacing: -0.6, + color: CustomColors.grey, + ), + ), + mWidth(3), + Text( + projectViewModel.user.patientID.toString(), + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 12, + letterSpacing: -0.48, + ), + ), + ], + ), + ], + ), + ), + ), + ), + mHeight(12), + // Expanded(child: Container()), + Container( + decoration: cardRadius(12.0), + margin: EdgeInsets.zero, + padding: EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + TranslationBase.of(context).patientShareTotalToDo, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 16, + letterSpacing: -0.64, + ), + ), + Text( + TranslationBase.of(context).sar + " ${widget.inPatientAdvanceResponseModel.responseInpatientAdvanceInfo[0].requestedAmount}", + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 24, + letterSpacing: -0.64, + ), + ), + ], + ), + SizedBox(height: 12), + Text( + TranslationBase.of(context).YouCanPayByTheFollowingOptions, + style: TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.64, + ), + ), + SizedBox(height: 12), + SizedBox( + width: MediaQuery.of(context).size.width * 0.75, + child: getPaymentMethods(), + ), + SizedBox(height: 12), + DefaultButton( + TranslationBase.of(context).payNow.toUpperCase(), + () { + this.browser.openUrlRequest(urlRequest: URLRequest(url: Uri.parse("https://google.com/")), options: _InAppBrowserOptions); + }, + // : null, + color: CustomColors.green, + disabledColor: CustomColors.grey2, + ), + SizedBox(height: 12), + Text( + TranslationBase.of(context).copyLinkTxt, + style: TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.64, + ), + ), + SizedBox(height: 12), + DefaultButton( + TranslationBase.of(context).copyLink.toUpperCase(), + () { + Clipboard.setData(const ClipboardData(text: "https://google.com/")).then((_) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(TranslationBase.of(context).paymentLinkCopied))); + }); + }, + svgIcon: "assets/images/new/copy.svg", + color: CustomColors.accentColor, + disabledColor: CustomColors.grey2, + ), + ], + ), + ), + ], + ), + ); } } diff --git a/lib/pages/InPatientServices/inpatient_advance_payment.dart b/lib/pages/InPatientServices/inpatient_advance_payment.dart index 3aed7934..736d7242 100644 --- a/lib/pages/InPatientServices/inpatient_advance_payment.dart +++ b/lib/pages/InPatientServices/inpatient_advance_payment.dart @@ -1,12 +1,18 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/InPatientServices/get_inpatient_advance_requests_response_model.dart'; import 'package:diplomaticquarterapp/pages/InPatientServices/components/inpatient_pending_advance_payment.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class InPatientAdvancePayment extends StatefulWidget { - const InPatientAdvancePayment({Key key}) : super(key: key); + InPatientAdvanceResponseModel inPatientAdvanceResponseModel; + + InPatientAdvancePayment({@required this.inPatientAdvanceResponseModel}); @override State createState() => _InPatientAdvancePaymentState(); @@ -59,7 +65,7 @@ class _InPatientAdvancePaymentState extends State with physics: BouncingScrollPhysics(), controller: _tabController, children: [ - InPatientPendingAdvancePayment(), + InPatientPendingAdvancePayment(inPatientAdvanceResponseModel: widget.inPatientAdvanceResponseModel), Container(), ], ), diff --git a/lib/pages/InPatientServices/inpatient_home.dart b/lib/pages/InPatientServices/inpatient_home.dart index 711a45df..683acfa6 100644 --- a/lib/pages/InPatientServices/inpatient_home.dart +++ b/lib/pages/InPatientServices/inpatient_home.dart @@ -17,10 +17,12 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../models/InPatientServices/get_inpatient_advance_requests_response_model.dart'; import '../../models/InPatientServices/get_medical_instructions_response_model.dart'; class InPatientServicesHome extends StatelessWidget { ProjectViewModel projectViewModel; + InPatientAdvanceResponseModel inPatientAdvanceResponseModel; @override Widget build(BuildContext context) { @@ -158,7 +160,7 @@ class InPatientServicesHome extends StatelessWidget { serviceList.add( InkWell( onTap: () { - Navigator.push(context, FadePage(page: InPatientAdvancePayment())); + getInPatientAdvancePaymentRequests(context); }, child: MedicalProfileItem( title: "Advance", @@ -239,7 +241,7 @@ class InPatientServicesHome extends StatelessWidget { GifLoaderDialogUtils.showMyDialog(context); service.getBirthNotification(projectViewModel.user.patientID, context).then((res) { GifLoaderDialogUtils.hideDialog(context); - if(res["MessageStatus"] == 1) { + if (res["MessageStatus"] == 1) { print(res['birthNotification']); Navigator.push(context, FadePage(page: BirthNotification())); } else { @@ -289,4 +291,24 @@ class InPatientServicesHome extends StatelessWidget { print(err); }); } + + void getInPatientAdvancePaymentRequests(BuildContext context) { + ClinicListService service = new ClinicListService(); + GifLoaderDialogUtils.showMyDialog(context); + service + .getInPatientAdvancePaymentRequests( + projectViewModel.inPatientProjectID, projectViewModel.getAdmissionInfoResponseModel.admissionNo, projectViewModel.getAdmissionInfoResponseModel.admissionRequestNo, context) + .then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res["MessageStatus"] == 1) { + inPatientAdvanceResponseModel = InPatientAdvanceResponseModel.fromJson(res["responseInpatient"]); + Navigator.push(context, FadePage(page: InPatientAdvancePayment(inPatientAdvanceResponseModel: inPatientAdvanceResponseModel))); + } else { + AppToast.showErrorToast(message: res["endUserMessage"]); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } } diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 73103aea..db813581 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -93,6 +93,20 @@ class ClinicListService extends BaseService { return Future.value(localRes); } + Future getInPatientAdvancePaymentRequests(int projectID, int admissionNo, int admissionReqNo, context) async { + Map request; + request = {"ProjectID": projectID, "AdmissionReqNo": admissionReqNo, "AdmissionNo": admissionNo}; + + dynamic localRes; + + await baseAppClient.post(GET_INPATIENT_ADVANCE_PAYMENT_REQUESTS, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request, isAllowAny: true); + return Future.value(localRes); + } + Future getMedicalInstructions(int projectID, context) async { Map request; request = {"ProjectID": projectID}; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index a9b9f334..8ef54102 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2930,6 +2930,9 @@ class TranslationBase { String get noMedicalInstructions => localizedValues["noMedicalInstructions"][locale.languageCode]; String get medicalInstructions => localizedValues["medicalInstructions"][locale.languageCode]; String get generalInstructions => localizedValues["generalInstructions"][locale.languageCode]; + String get copyLink => localizedValues["copyLink"][locale.languageCode]; + String get copyLinkTxt => localizedValues["copyLinkTxt"][locale.languageCode]; + String get paymentLinkCopied => localizedValues["paymentLinkCopied"][locale.languageCode]; }