From 6310c1c6150d1c646bb405294e5690978f4e267b Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 7 Mar 2024 16:35:13 +0300 Subject: [PATCH] InPatient General Consent API implemented --- lib/config/config.dart | 2 + .../inpatient_general_consent.dart | 82 ++++++++++++++++++- .../clinic_services/get_clinic_service.dart | 24 ++++++ 3 files changed, 106 insertions(+), 2 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 4b51460f..eda25558 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -631,6 +631,8 @@ var GET_BIRTH_NOTIFICATION = 'Services/INPs.svc/REST/getBirthNotification_bymoth var SAVE_BIRTH_NOTIFICATION = 'Services/INPs.svc/REST/SaveBirthNotification'; +var INSERT_GENERAL_ADMISSION_CONSENT = 'Services/INPs.svc/REST/Inp_insertAAForGeneralAdmissionConsent'; + //Meal Plan APIs var GET_ADMITTED_PATIENTS = 'Services/MOP.svc/REST/GetAdmittedPatients'; var GET_CURRENT_WEEKID_WEEKDAY = 'Services/MOP.svc/REST/GetCurrentWeekAndDayHMGMP'; diff --git a/lib/pages/InPatientServices/inpatient_general_consent.dart b/lib/pages/InPatientServices/inpatient_general_consent.dart index c1ab6167..64f2262c 100644 --- a/lib/pages/InPatientServices/inpatient_general_consent.dart +++ b/lib/pages/InPatientServices/inpatient_general_consent.dart @@ -1,13 +1,23 @@ +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/theme/colors.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/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/custom_text_button.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class InPatientGeneralConsent extends StatelessWidget { - const InPatientGeneralConsent(); + InPatientGeneralConsent(); + + ProjectViewModel projectViewModel; @override Widget build(BuildContext context) { + projectViewModel = Provider.of(context); return AppScaffold( isShowAppBar: true, isShowDecPage: false, @@ -443,9 +453,77 @@ class InPatientGeneralConsent extends StatelessWidget { ), ), ), - ) + ), + Padding( + padding: const EdgeInsets.only(left: 21.0, right: 21.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Expanded( + flex: 1, + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + height: 45.0, + child: CustomTextButton( + backgroundColor: Color(0xffc5272d), + elevation: 0, + onPressed: () { + acceptRejectConsent(context, 0); + }, + child: Text(TranslationBase.of(context).reject, style: TextStyle(fontSize: 16.0, color: Colors.white)), + ), + ), + ), + mWidth(7), + Expanded( + flex: 1, + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10.0), + ), + height: 45.0, + child: CustomTextButton( + backgroundColor: CustomColors.green, + elevation: 0, + onPressed: () { + acceptRejectConsent(context, 1); + }, + child: Text(TranslationBase.of(context).acceptLbl, style: TextStyle(fontSize: 16.0, color: Colors.white)), + ), + ), + ), + ], + ), + ), ], ), ); } + + void acceptRejectConsent(BuildContext context, int status) { + ClinicListService service = new ClinicListService(); + GifLoaderDialogUtils.showMyDialog(context); + service + .insertForGeneralAdmissionConsent( + projectViewModel.user.patientID, + projectViewModel.isPatientAdmitted ? projectViewModel.getAdmissionInfoResponseModel.admissionRequestNo : projectViewModel.getAdmissionRequestInfoResponseModel.admissionRequestNo, + projectViewModel.isPatientAdmitted ? projectViewModel.getAdmissionInfoResponseModel.clinicID : projectViewModel.getAdmissionRequestInfoResponseModel.clinicId, + projectViewModel.isPatientAdmitted ? projectViewModel.getAdmissionInfoResponseModel.projectID : projectViewModel.getAdmissionRequestInfoResponseModel.projectId, + status, + context) + .then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res["MessageStatus"] == 1) { + AppToast.showErrorToast(message: res["SuccessMsg"]); + } else { + AppToast.showErrorToast(message: res["endUserMessage"]); + } + Navigator.pop(context); + }).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 c31bfe7c..f176e853 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -313,6 +313,30 @@ class ClinicListService extends BaseService { return Future.value(localRes); } + Future insertForGeneralAdmissionConsent(num patientID, num admissionReqNo, int clinicID, int projectID, int status, context) async { + Map request; + request = { + "AdmissionRequestNo": admissionReqNo, + "ClinicID": clinicID, + "CreatedBy": 102, + "PatientID": patientID, + "ProjectID": projectID, + "status": status, + "searchKey": "", + "pageIndex": 0, + "pageSize": 0, + }; + + dynamic localRes; + + await baseAppClient.post(INSERT_GENERAL_ADMISSION_CONSENT, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request, isAllowAny: true); + return Future.value(localRes); + } + Future submitBirthNotification(num motherMRN, int projectID, String fatherNameAR, String fatherNameEN, String babyNameAR, String babyNameEN, String contactNum, String idImage, context) async { Map request; request = {