diff --git a/lib/config/config.dart b/lib/config/config.dart index 28d0f6bf..1047ec66 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -599,6 +599,9 @@ var CHECK_IF_INPATIENT = 'Services/Patients.svc/REST/GetInPatientAdmissionInfo'; // Get General Instructions API var GET_GENERAL_INSTRUCTIONS = 'Services/INPs.svc/REST/getGeneralInstructions'; + +var INSERT_INPATIENT_ORDER = 'Services/INPs.svc/REST/Inpcp_insertOrder'; + class AppGlobal { static var context; diff --git a/lib/core/viewModels/project_view_model.dart b/lib/core/viewModels/project_view_model.dart index f5e3f802..6c78da7f 100644 --- a/lib/core/viewModels/project_view_model.dart +++ b/lib/core/viewModels/project_view_model.dart @@ -9,14 +9,15 @@ import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/laser_body_parts.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart'; +import 'package:diplomaticquarterapp/models/InPatientServices/get_admission_info_response_model.dart'; import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; var isAppArabic = false; -class ProjectViewModel extends BaseViewModel { +class ProjectViewModel extends BaseViewModel { GAnalytics get analytics => locator(); // Platform Bridge @@ -37,14 +38,19 @@ class ProjectViewModel extends BaseViewModel { int laserSelectionDuration; bool isPatientAdmitted = false; int inPatientProjectID = 0; + GetAdmissionInfoResponseModel getAdmissionInfoResponseModel; double _latitude; double _longitude; - RegisterInfoResponse _registerInfo =RegisterInfoResponse(); + RegisterInfoResponse _registerInfo = RegisterInfoResponse(); + double get latitude => _latitude; + double get longitude => _longitude; - RegisterInfoResponse get registerInfo=> _registerInfo; + + RegisterInfoResponse get registerInfo => _registerInfo; + dynamic get searchValue => searchvalue; Locale get appLocal => _appLocale; @@ -57,8 +63,7 @@ class ProjectViewModel extends BaseViewModel { List privilegeRootUser = List(); List privilegeChildUser = List(); - List get privileges => - isLoginChild ? privilegeChildUser : privilegeChildUser; + List get privileges => isLoginChild ? privilegeChildUser : privilegeChildUser; List selectedBodyPartList = []; @@ -66,9 +71,7 @@ class ProjectViewModel extends BaseViewModel { ProjectViewModel() { loadSharedPrefLanguage(); - subscription = Connectivity() - .onConnectivityChanged - .listen((ConnectivityResult result) { + subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) { switch (result) { case ConnectivityResult.wifi: isInternetConnection = true; @@ -91,8 +94,7 @@ class ProjectViewModel extends BaseViewModel { } Future loadSharedPrefLanguage() async { - currentLanguage = - await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + currentLanguage = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); _appLocale = Locale(currentLanguage); isAppArabic = _isArabic = currentLanguage == 'ar'; notifyListeners(); @@ -124,6 +126,11 @@ class ProjectViewModel extends BaseViewModel { notifyListeners(); } + setInPatientAdmissionInfo(GetAdmissionInfoResponseModel _getAdmissionInfoResponseModel) { + this.getAdmissionInfoResponseModel = _getAdmissionInfoResponseModel; + notifyListeners(); + } + setPrivilegeModelList({List privilege}) { this.isLoginChild = isLoginChild; privilegeRootUser = privilege; @@ -178,8 +185,9 @@ class ProjectViewModel extends BaseViewModel { searchvalue = data; notifyListeners(); } - setRegisterData(RegisterInfoResponse data){ - _registerInfo =data; + + setRegisterData(RegisterInfoResponse data) { + _registerInfo = data; notifyListeners(); } } diff --git a/lib/models/InPatientServices/get_admission_info_response_model.dart b/lib/models/InPatientServices/get_admission_info_response_model.dart new file mode 100644 index 00000000..118f8737 --- /dev/null +++ b/lib/models/InPatientServices/get_admission_info_response_model.dart @@ -0,0 +1,60 @@ +class GetAdmissionInfoResponseModel { + int admissionNo; + String admissionDate; + String infotainmentIBMSLink; + String infotainmentIBMSLinkAr; + int projectID; + String roomID; + String bedID; + int clinicID; + int doctorID; + int patientID; + String bMIUrl; + String mOPUrl; + + GetAdmissionInfoResponseModel( + {this.admissionNo, + this.admissionDate, + this.infotainmentIBMSLink, + this.infotainmentIBMSLinkAr, + this.projectID, + this.roomID, + this.bedID, + this.clinicID, + this.doctorID, + this.patientID, + this.bMIUrl, + this.mOPUrl}); + + GetAdmissionInfoResponseModel.fromJson(Map json) { + admissionNo = json['AdmissionNo']; + admissionDate = json['AdmissionDate']; + infotainmentIBMSLink = json['InfotainmentIBMSLink']; + infotainmentIBMSLinkAr = json['InfotainmentIBMSLinkAr']; + projectID = json['ProjectID']; + roomID = json['RoomID']; + bedID = json['BedID']; + clinicID = json['ClinicID']; + doctorID = json['DoctorID']; + patientID = json['PatientID']; + bMIUrl = json['BMIUrl']; + mOPUrl = json['MOPUrl']; + } + + Map toJson() { + final Map data = new Map(); + data['AdmissionNo'] = this.admissionNo; + data['AdmissionDate'] = this.admissionDate; + data['InfotainmentIBMSLink'] = this.infotainmentIBMSLink; + data['InfotainmentIBMSLinkAr'] = this.infotainmentIBMSLinkAr; + data['ProjectID'] = this.projectID; + data['RoomID'] = this.roomID; + data['BedID'] = this.bedID; + data['ClinicID'] = this.clinicID; + data['DoctorID'] = this.doctorID; + data['PatientID'] = this.patientID; + data['BMIUrl'] = this.bMIUrl; + data['MOPUrl'] = this.mOPUrl; + return data; + } +} diff --git a/lib/pages/InPatientServices/help_PRO.dart b/lib/pages/InPatientServices/help_PRO.dart index 954550ef..a9d192a7 100644 --- a/lib/pages/InPatientServices/help_PRO.dart +++ b/lib/pages/InPatientServices/help_PRO.dart @@ -1,7 +1,13 @@ +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class HelpPRO extends StatefulWidget { const HelpPRO({Key key}) : super(key: key); @@ -11,11 +17,12 @@ class HelpPRO extends StatefulWidget { } class _HelpPROState extends State { - TextEditingController assistText = new TextEditingController(); + ProjectViewModel projectViewModel; @override Widget build(BuildContext context) { + projectViewModel = Provider.of(context); return AppScaffold( isShowAppBar: true, isShowDecPage: false, @@ -43,6 +50,17 @@ class _HelpPROState extends State { ), mHeight(16), inputWidget(TranslationBase.of(context).enterDetails, "", assistText), + mHeight(16), + DefaultButton( + TranslationBase.of(context).send, + () { + if (assistText.text.isNotEmpty) { + callReceivePrescriptionAPI(context); + } else { + Utils.showErrorToast(TranslationBase.of(context).emptyMessage); + } + }, + ), ], ), ), @@ -107,15 +125,15 @@ class _HelpPROState extends State { prefixIcon: prefix == null ? null : Text( - "+" + prefix, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontWeight: FontWeight.w500, - color: Color(0xff2E303A), - letterSpacing: -0.56, - ), - ), + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), contentPadding: EdgeInsets.zero, border: InputBorder.none, focusedBorder: InputBorder.none, @@ -132,4 +150,15 @@ class _HelpPROState extends State { ); } + void callReceivePrescriptionAPI(BuildContext context) { + ClinicListService service = new ClinicListService(); + GifLoaderDialogUtils.showMyDialog(context); + service + .insertInPatientOrder(projectViewModel.getAdmissionInfoResponseModel, 1, (projectViewModel.user.firstName + " " + projectViewModel.user.lastName), + (projectViewModel.user.firstNameN + " " + projectViewModel.user.lastNameN), projectViewModel.user.mobileNumber, assistText.text, context) + .then((res) {}) + .catchError((err) { + print(err); + }); + } } diff --git a/lib/pages/InPatientServices/inpatient_home.dart b/lib/pages/InPatientServices/inpatient_home.dart index eeba37ab..2098d350 100644 --- a/lib/pages/InPatientServices/inpatient_home.dart +++ b/lib/pages/InPatientServices/inpatient_home.dart @@ -216,6 +216,20 @@ class InPatientServicesHome extends StatelessWidget { dialog.showAlertDialog(context); } + void callReceivePrescriptionAPI(BuildContext context) { + ClinicListService service = new ClinicListService(); + GifLoaderDialogUtils.showMyDialog(context); + service + .insertInPatientOrder(projectViewModel.getAdmissionInfoResponseModel, 2, (projectViewModel.user.firstName + " " + projectViewModel.user.lastName), + (projectViewModel.user.firstNameN + " " + projectViewModel.user.lastNameN), projectViewModel.user.mobileNumber, "I need my medicines", context) + .then((res) { + GifLoaderDialogUtils.hideDialog(context); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + }); + } + void openGeneralInstructions(BuildContext context) { ClinicListService service = new ClinicListService(); GifLoaderDialogUtils.showMyDialog(context); diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index e45cc333..ef3378bb 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -13,6 +13,7 @@ import 'package:diplomaticquarterapp/models/Authentication/check_activation_code import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/models/Authentication/send_activation_request.dart'; +import 'package:diplomaticquarterapp/models/InPatientServices/get_admission_info_response_model.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/login/register_new.dart'; import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart'; @@ -671,13 +672,16 @@ class _ConfirmLogin extends State { } checkIfIsInPatient() { + GetAdmissionInfoResponseModel getAdmissionInfoResponseModel; ClinicListService service = new ClinicListService(); service.checkIfInPatientAPI(context).then((res) { if (res['MessageStatus'] == 1) { if (res['List_PatientAdmissionInfo'].length != 0) { print("INPATIENT!!!"); + getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel.fromJson(res['List_PatientAdmissionInfo'][0]); projectViewModel.setIsPatientAdmitted(true); projectViewModel.setInPatientProjectID(res['List_PatientAdmissionInfo'][0]['ProjectID']); + projectViewModel.setInPatientAdmissionInfo(getAdmissionInfoResponseModel); } else { print("OUTPATIENT!!!"); projectViewModel.setIsPatientAdmitted(false); diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 7507382b..fefce667 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; +import 'package:diplomaticquarterapp/models/InPatientServices/get_admission_info_response_model.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/login/confirm-login.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart'; @@ -393,13 +394,16 @@ class _Login extends State { } checkIfIsInPatient() { + GetAdmissionInfoResponseModel getAdmissionInfoResponseModel; ClinicListService service = new ClinicListService(); service.checkIfInPatientAPI(context).then((res) { if (res['MessageStatus'] == 1) { if (res['List_PatientAdmissionInfo'].length != 0) { print("INPATIENT!!!"); + getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel.fromJson(res['List_PatientAdmissionInfo'][0]); projectViewModel.setIsPatientAdmitted(true); projectViewModel.setInPatientProjectID(res['List_PatientAdmissionInfo'][0]['ProjectID']); + projectViewModel.setInPatientAdmissionInfo(getAdmissionInfoResponseModel); } else { print("OUTPATIENT!!!"); projectViewModel.setIsPatientAdmitted(false); diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 6d22a472..d4a4f8ed 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/models/InPatientServices/get_admission_info_response_model.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; @@ -79,9 +80,7 @@ class ClinicListService extends BaseService { Future getGeneralInstructions(int projectID, context) async { Map request; - request = { - "ProjectID": projectID - }; + request = {"ProjectID": projectID}; dynamic localRes; @@ -199,14 +198,41 @@ class ClinicListService extends BaseService { }, body: request); return Future.value(localRes); } + Future getCountries() async { - Map request ={}; + Map request = {}; dynamic localRes; - await baseAppClient.post(GET_NATIONALITY, onSuccess: (response, statusCode) async { - localRes = response; - }, onFailure: (String error, int statusCode) { - throw error; - }, body: request); - return Future.value(localRes); -} + await baseAppClient.post(GET_NATIONALITY, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + + Future insertInPatientOrder( + GetAdmissionInfoResponseModel getAdmissionInfoResponseModel, int typeID, String patientName, String patientNameAR, String patientMobileNo, String comments, context) async { + Map request; + request = { + "ProjectID": getAdmissionInfoResponseModel.projectID, + "TypeID": typeID, + "RoomNo": getAdmissionInfoResponseModel.roomID, + "GenderId": 2, + "AdmissionNo": getAdmissionInfoResponseModel.admissionNo, + "prescriptionNo": 250420, + "patientName": patientName, + "patientNameN": patientNameAR, + "PatientMobileNumber": patientMobileNo, + "comments": comments + }; + + dynamic localRes; + + await baseAppClient.post(INSERT_INPATIENT_ORDER, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request, isAllowAny: true); + return Future.value(localRes); + } }