import 'dart:io'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/main.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request_register.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/Authentication/check_user_status_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/checkpatient_for_registration.dart'; import 'package:diplomaticquarterapp/models/Authentication/insert_device_imei_request.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_user_requet.dart'; import 'package:diplomaticquarterapp/models/Authentication/registered_authenticated_user_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/cupertino.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import '../../locator.dart'; // SharedPreferences sharedPref = new SharedPreferences(); enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } AppSharedPreferences sharedPref = AppSharedPreferences(); AppGlobal appGlobal = AppGlobal(); const String INSERT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI'; const String SELECT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_SELECTDeviceIMEIbyIMEI'; const String CHECK_PATIENT_AUTH = 'Services/Authentication.svc/REST/CheckPatientAuthentication'; const GET_MOBILE_INFO = 'Services/Authentication.svc/REST/GetMobileLoginInfo'; const SEND_ACTIVATION_CODE = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType'; const SEND_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationTypeForRegistration'; const CHECK_ACTIVATION_CODE = 'Services/Authentication.svc/REST/CheckActivationCode'; const CHECK_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/CheckActivationCodeForRegistration'; const FORGOT_PASSWORD = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo'; const CHECK_PATIENT_FOR_REGISTRATION = "Services/Authentication.svc/REST/CheckPatientForRegisteration"; const CHECK_USER_STATUS = "Services/NHIC.svc/REST/GetPatientInfo"; const REGISTER_USER = 'Services/Authentication.svc/REST/PatientRegistration'; const LOGGED_IN_USER_URL = 'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo'; const FORGOT_PATIENT_ID = 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber'; const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard'; const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate'; const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo'; const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_InsertUpdate'; class AuthProvider with ChangeNotifier { bool isLogin = false; bool isLoading = true; dynamic authenticatedUser; AuthenticatedUserObject authenticatedUserObject = locator(); var languageID; AuthProvider() { getUserAuthentication(); } void getUserAuthentication() async { Map profile = await sharedPref.getObject(USER_PROFILE) ?? Map(); languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); if (profile != null) { isLoading = false; isLogin = true; } else { isLoading = false; isLogin = false; } notifyListeners(); } APP_STATUS get stutas { if (isLoading) { return APP_STATUS.LOADING; } else { if (this.isLogin) { return APP_STATUS.AUTHENTICATED; } else { return APP_STATUS.UNAUTHENTICATED; } } } // Future login(UserModel userInfo) async { // try { // dynamic localRes; // await BaseAppClient.post(LOGIN_URL, // onSuccess: (dynamic response, int statusCode) { // localRes = response; // }, onFailure: (String error, int statusCode) { // throw error; // }, body: userInfo.toJson()); // return Future.value(localRes); // } catch (error) { // print(error); // throw error; // } // } Future insertDeviceImei(lstLogin) async { try { dynamic localRes; var lastLogin = lstLogin; //await sharedPref.getInt( // LAST_LOGIN); //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); //this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false); var request = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE)); var newRequest = INSERTDeviceIMEIRequest(); var imei = await sharedPref.getString(PUSH_TOKEN); // if (!request.) { newRequest.iMEI = imei; //imei!=null ? imei : ''; newRequest.firstName = request.firstName ?? "" + " " + request.lastName! ?? ""; newRequest.firstNameN = request.firstNameN ?? "" + " " + request.lastNameN! ?? ""; newRequest.lastNameN = request.lastNameN ?? ""; newRequest.outSA = request.outSA == 1 ? true : false; newRequest.biometricEnabled = false; newRequest.preferredLanguage = int.parse(request.preferredLanguage!) ?? 1; newRequest.logInTypeID = lastLogin ?? 1; newRequest.patientID = request.patientID; newRequest.mobileNo = request.mobileNumber; newRequest.identificationNo = request.patientIdentificationNo; newRequest.patientIdentificationNo = request.patientIdentificationNo; newRequest.patientType = request.patientType; newRequest.setupID = request.setupID; newRequest.tokenID = await sharedPref.getString(TOKEN); // } await new BaseAppClient().post(INSERT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: newRequest.toJson()); return Future.value(localRes); } catch (error) { print(error); throw error; } } Future selectDeviceImei(imei, {int languageID = 1}) async { SelectDeviceIMEIRES? selectDeviceIMEIRES; try { // SelectDeviceIMEIRES? localRes; print(imei); Map request = {}; request['IMEI'] = imei; request['LanguageID'] = languageID; await BaseAppClient().post(SELECT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) async { // localRes = Map(); print("Here response: ${response['Patient_SELECTDeviceIMEIbyIMEIList'][0]}"); if (response['Patient_SELECTDeviceIMEIbyIMEIList'][0] != null) { selectDeviceIMEIRES = SelectDeviceIMEIRES.fromJson(response['Patient_SELECTDeviceIMEIbyIMEIList'][0]); sharedPref.setObject(IMEI_USER_DATA, selectDeviceIMEIRES); } else { print("ELSE TRIGERRED!!!!!!!!!"); selectDeviceIMEIRES = null; } // await new BaseAppClient().post(SELECT_DEVICE_IMEI, // onSuccess: (dynamic response, int statusCode) { // localRes = SelectDeviceIMEIRES.fromJson( // response['Patient_SELECTDeviceIMEIbyIMEIList'][0]); // }, onFailure: (String error, int statusCode) { // throw error; // }, body: request); }, onFailure: (String error, int statusCode) { print("in the failure with : $error and $statusCode"); }, body: request); } catch (error) { print("in the error"); // return Future.error(error); } return Future.value(selectDeviceIMEIRES); } Future checkPatientAuthentication(CheckPatientAuthenticationReq request) async { request.versionID = VERSION_ID; request.channel = CHANNEL; request.iPAdress = IP_ADDRESS; request.generalid = GENERAL_ID; request.languageID = (languageID == 'ar' ? 1 : 2); request.patientOutSA = (request.zipCode == '966' || request.zipCode == '+966') ? 0 : 1; try { dynamic localRes; await new BaseAppClient().post(CHECK_PATIENT_AUTH, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: request.toJson()); return Future.value(localRes); } catch (error) { throw error; //throw error; } } Future getLoginInfo(request) async { request.versionID = VERSION_ID; request.channel = CHANNEL; request.iPAdress = IP_ADDRESS; request.generalid = GENERAL_ID; request.languageID = (languageID == 'ar' ? 1 : 2); request.deviceTypeID = Platform.isIOS ? 1 : 2; request.patientOutSA = request.zipCode == '966' ? 0 : 1; request.isDentalAllowedBackend = false; // request.patientTypeID = request.patientType; // request.patientType = request.patientType; dynamic localRes; await new BaseAppClient().post(GET_MOBILE_INFO, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: request.toJson()); return Future.value(localRes); } Future sendActivationCode(request) async { request.versionID = VERSION_ID; request.channel = CHANNEL; request.iPAdress = IP_ADDRESS; request.generalid = GENERAL_ID; // request.languageID = (languageID == 'ar' ? 1 : 2); request.languageID = 2; request.deviceTypeID = Platform.isIOS ? 1 : 2; request.patientOutSA = request.zipCode == '966' ? 0 : 1; request.isDentalAllowedBackend = false; dynamic localRes; await new BaseAppClient().post(SEND_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) { localRes = response; authenticatedUser = CheckActivationCode.fromJson(localRes); }, onFailure: (String error, int statusCode) { throw error; }, body: request.toJson()); return Future.value(localRes); } Future sendActivationCodeRegister(request) async { request.versionID = VERSION_ID; request.channel = CHANNEL; request.iPAdress = IP_ADDRESS; request.generalid = GENERAL_ID; request.languageID = (languageID == 'ar' ? 1 : 2); request.deviceTypeID = Platform.isIOS ? 1 : 2; request.patientOutSA = request.zipCode == '966' ? 0 : 1; request.isDentalAllowedBackend = false; dynamic localRes; await new BaseAppClient().post(SEND_ACTIVATION_CODE_REGISTER, onSuccess: (dynamic response, int statusCode) { localRes = response; authenticatedUser = CheckActivationCode.fromJson(localRes); }, onFailure: (String error, int statusCode) { throw error; }, body: request.toJson()); return Future.value(localRes); } Future checkActivationCode(request, [value]) async { var neRequest = CheckActivationCodeReq.fromJson(request); neRequest.activationCode = value ?? "0000"; neRequest.isSilentLogin = value != null ? false : true; neRequest.versionID = VERSION_ID; neRequest.channel = CHANNEL; neRequest.iPAdress = IP_ADDRESS; neRequest.generalid = GENERAL_ID; neRequest.deviceTypeID = Platform.isIOS ? 1 : 2; neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1; neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true; neRequest.isDentalAllowedBackend = false; // neRequest.deviceToken = null; neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false; neRequest.isRegister = false; dynamic localRes; try { await new BaseAppClient().post(CHECK_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) { localRes = response; //CheckActivationCode.fromJson(); }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); // throw error; }, body: neRequest.toJson()); return Future.value(localRes); } catch (error) { throw localRes; } } Future checkActivationCodeRegister(request, [value]) async { var neRequest = CheckActivationCodeRegisterReq.fromJson(request); neRequest.activationCode = value ?? "0000"; neRequest.isSilentLogin = value != null ? false : true; neRequest.versionID = VERSION_ID; neRequest.channel = CHANNEL; neRequest.iPAdress = IP_ADDRESS; neRequest.generalid = GENERAL_ID; // request.languageID = (languageID == 'ar' ? 1 : 2); neRequest.deviceTypeID = Platform.isIOS ? 1 : 2; neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1; neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true; neRequest.isDentalAllowedBackend = false; // neRequest.deviceToken = null; neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false; neRequest.isRegister = false; dynamic localRes; try { await new BaseAppClient().post(CHECK_ACTIVATION_CODE_REGISTER, onSuccess: (dynamic response, int statusCode) { localRes = response; //CheckActivationCode.fromJson(); }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); // throw error; }, body: neRequest.toJson()); // sharedPref.setString(BLOOD_TYPE, localRes['PatientBloodType']); return Future.value(localRes); } catch (error) { throw localRes; //return Future.value(error); } } AuthenticatedUser getAuthenticatedUser() { this.isLogin = true; return authenticatedUser; } Future checkPatientForRegisteration(CheckPatientForRegistration request, int languageID) async { request.versionID = VERSION_ID; request.channel = CHANNEL; request.iPAdress = IP_ADDRESS; request.generalid = GENERAL_ID; request.languageID = languageID; request.deviceTypeID = Platform.isIOS ? 1 : 2; request.isRegister = false; // request.tokenID = ''; dynamic localRes; try { await new BaseAppClient().post(CHECK_PATIENT_FOR_REGISTRATION, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); }, body: request.toJson()); return Future.value(localRes); } catch (error) { throw error; } } Future checkUserStatus(CheckUserStatusRequest request) async { request.versionID = VERSION_ID; request.channel = CHANNEL; request.iPAdress = IP_ADDRESS; request.generalid = GENERAL_ID; request.languageID = (languageID == 'ar' ? 1 : 2); request.deviceTypeID = Platform.isIOS ? 1 : 2; // request.tokenID = ''; dynamic localRes; try { await new BaseAppClient().post(CHECK_USER_STATUS, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); }, body: request.toJson()); return Future.value(localRes); } catch (error) { throw error; } } Future registerUser(request) async { request['VersionID'] = VERSION_ID; request['Channel'] = CHANNEL; request['IPAdress'] = IP_ADDRESS; request['Generalid'] = GENERAL_ID; request['DeviceTypeID'] = Platform.isIOS ? 1 : 2; request['LanguageID'] = (languageID == 'ar' ? 1 : 2); request['LogInTokenID'] = await sharedPref.getString(LOGIN_TOKEN_ID); var nhic = await sharedPref.getObject(NHIC_DATA); var requestN = RegisterUserRequest.fromJson(request); requestN.patientOutSA = requestN.patientobject!.patientOutSA!; final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); if (nhic != null) { requestN.dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); requestN.isHijri = nhic['IsHijri'] ? 1 : 0; requestN.healthId = requestN.patientobject!.eHealthIDField!; } requestN.zipCode = requestN.patientOutSA == 1 ? '971' : '966'; await sharedPref.remove(USER_PROFILE); dynamic localRes; try { // localRes = { // "Date": null, // "LanguageID": 0, // "ServiceName": 0, // "Time": null, // "AndroidLink": null, // "AuthenticationTokenID": "d+TXwG6BFkSjRuFPvTdSwA==", // "Data": null, // "Dataw": false, // "DietType": 0, // "DietTypeID": 0, // "ErrorCode": null, // "ErrorEndUserMessage": "Patient verified Successfully", // "ErrorEndUserMessageN": null, // "ErrorMessage": null, // "ErrorStatusCode": 0, // "ErrorType": 0, // "FoodCategory": 0, // "IOSLink": null, // "IsAuthenticated": true, // "MealOrderStatus": 0, // "MealType": 0, // "MessageStatus": 1, // "NumberOfResultRecords": 0, // "PatientBlodType": null, // "SuccessMsg": null, // "SuccessMsgN": null, // "VidaUpdatedResponse": null, // "DoctorInformation_List": null, // "GetAllPendingRecordsList": null, // "GetAllSharedRecordsByStatusList": null, // "GetResponseFileList": null, // "IsHMGPatient": false, // "IsLoginSuccessfully": false, // "IsNeedUpdateIdintificationNo": false, // "IsPatientAuthorized": false, // "IsVidaPlus": false, // "KioskSendSMS": false, // "List": [ // { // "SetupID": "010266", // "PatientType": 1, // "PatientID": 5318335, // "FirstName": "SYED TAHA", // "MiddleName": "ALAM", // "LastName": "ALAM", // "FirstNameN": "سيد طه", // "MiddleNameN": "علام", // "LastNameN": "علام", // "RelationshipID": 0, // "Gender": 1, // "DateofBirth": "/Date(839106000000+0300)/", // "DateofBirthN": null, // "NationalityID": "PAK", // "PhoneResi": " ", // "PhoneOffice": " ", // "MobileNumber": "0560960398", // "FaxNumber": " ", // "EmailAddress": "testtaha@gmail.com", // "BloodGroup": null, // "RHFactor": null, // "IsEmailAlertRequired": false, // "IsSMSAlertRequired": true, // "PreferredLanguage": "1", // "IsPrivilegedMember": false, // "MemberID": null, // "ExpiryDate": null, // "IsHmgEmployee": null, // "EmployeeID": null, // "EmergencyContactName": "", // "EmergencyContactNo": "", // "PatientPayType": 0, // "DHCCPatientRefID": null, // "IsPatientDummy": false, // "Status": 2, // "IsStatusCleared": null, // "PatientIdentificationType": 2, // "PatientIdentificationNo": "2579628724", // "ProjectID": 15, // "InfoSourceID": 0, // "Address": "", // "Age": 28, // "AgeDesc": "28 Yr", // "AreaID": 0, // "CRSVerificationStatus": 2, // "CRSVerificationStatusDesc": "verified", // "CRSVerificationStatusDescN": "تم التوثيق", // "CreatedBy": 0, // "GenderDescription": "Male", // "HealthIDFromNHICViaVida": "2bcc1b1a-96b7-4f33-86e2-fa955d0e3764", // "IR": null, // "ISOCityID": null, // "ISOCountryID": null, // "IsVerfiedFromNHIC": true, // "ListPrivilege": [ // { // "ID": 1, // "ServiceName": "Notifications", // "Previlege": true, // "Region": null // }, // { // "ID": 2, // "ServiceName": "Family Files", // "Previlege": true, // "Region": null // }, // { // "ID": 3, // "ServiceName": "Settings", // "Previlege": true, // "Region": null // }, // { // "ID": 4, // "ServiceName": "My Profile", // "Previlege": true, // "Region": null // }, // { // "ID": 5, // "ServiceName": "My Appointment", // "Previlege": true, // "Region": null // }, // { // "ID": 6, // "ServiceName": "My Doctors", // "Previlege": true, // "Region": null // }, // { // "ID": 7, // "ServiceName": "Radiology", // "Previlege": true, // "Region": null // }, // { // "ID": 8, // "ServiceName": "Radiology Email", // "Previlege": true, // "Region": null // }, // { // "ID": 9, // "ServiceName": "Radiology View Image", // "Previlege": true, // "Region": null // }, // { // "ID": 10, // "ServiceName": "Lab Results", // "Previlege": true, // "Region": null // }, // { // "ID": 11, // "ServiceName": "Lab Results Email", // "Previlege": true, // "Region": null // }, // { // "ID": 12, // "ServiceName": "Precriptions", // "Previlege": true, // "Region": null // }, // { // "ID": 13, // "ServiceName": "Precriptions Email", // "Previlege": true, // "Region": null // }, // { // "ID": 14, // "ServiceName": "Eye Measurments", // "Previlege": true, // "Region": null // }, // { // "ID": 15, // "ServiceName": "Eye Measurments Email", // "Previlege": true, // "Region": null // }, // { // "ID": 16, // "ServiceName": "Sick Leaves", // "Previlege": true, // "Region": null // }, // { // "ID": 17, // "ServiceName": "Sick Leaves Email", // "Previlege": true, // "Region": null // }, // { // "ID": 18, // "ServiceName": "Approvals", // "Previlege": true, // "Region": null // }, // { // "ID": 19, // "ServiceName": "Monthly Reports", // "Previlege": true, // "Region": null // }, // { // "ID": 20, // "ServiceName": "Request Medical Report", // "Previlege": true, // "Region": null // }, // { // "ID": 21, // "ServiceName": "Request Medical Report Email", // "Previlege": true, // "Region": null // }, // { // "ID": 22, // "ServiceName": "Insurance Cards", // "Previlege": true, // "Region": null // }, // { // "ID": 23, // "ServiceName": "Allergies", // "Previlege": true, // "Region": null // }, // { // "ID": 24, // "ServiceName": "My Trackers", // "Previlege": true, // "Region": null // }, // { // "ID": 25, // "ServiceName": "Vital Signs", // "Previlege": true, // "Region": null // }, // { // "ID": 26, // "ServiceName": "My Vaccines", // "Previlege": true, // "Region": null // }, // { // "ID": 27, // "ServiceName": "My Vaccines Email", // "Previlege": true, // "Region": null // }, // { // "ID": 28, // "ServiceName": "Ask Doctors", // "Previlege": true, // "Region": null // }, // { // "ID": 29, // "ServiceName": "Live Chat", // "Previlege": true, // "Region": null // }, // { // "ID": 30, // "ServiceName": "Health Data", // "Previlege": true, // "Region": null // }, // { // "ID": 31, // "ServiceName": "Online Check-in", // "Previlege": true, // "Region": null // }, // { // "ID": 32, // "ServiceName": "Connect to internet", // "Previlege": true, // "Region": null // }, // { // "ID": 33, // "ServiceName": "Advance Payment", // "Previlege": true, // "Region": null // }, // { // "ID": 34, // "ServiceName": "Book Appointment", // "Previlege": true, // "Region": null // }, // { // "ID": 35, // "ServiceName": "Child Vaccines", // "Previlege": true, // "Region": null // }, // { // "ID": 36, // "ServiceName": "Blood Donation", // "Previlege": true, // "Region": null // }, // { // "ID": 38, // "ServiceName": "H2O", // "Previlege": true, // "Region": null // }, // { // "ID": 40, // "ServiceName": "ChatBot", // "Previlege": false, // "Region": null // }, // { // "ID": 41, // "ServiceName": "Parking", // "Previlege": true, // "Region": null // }, // { // "ID": 42, // "ServiceName": "SymptomChecker", // "Previlege": false, // "Region": null // }, // { // "ID": 47, // "ServiceName": "AdvanceBalance", // "Previlege": true, // "Region": null // }, // { // "ID": 48, // "ServiceName": "ActiveMedications", // "Previlege": true, // "Region": null // }, // { // "ID": 49, // "ServiceName": "VaccineAvailability", // "Previlege": false, // "Region": null // }, // { // "ID": 51, // "ServiceName": "UpcomingAppointment", // "Previlege": true, // "Region": null // }, // { // "ID": 52, // "ServiceName": "PushNotificationCount", // "Previlege": true, // "Region": null // }, // { // "ID": 53, // "ServiceName": "ActiveMedicationCount", // "Previlege": true, // "Region": null // }, // { // "ID": 54, // "ServiceName": "LabOrderUnreadCount", // "Previlege": true, // "Region": null // }, // { // "ID": 55, // "ServiceName": "RadOrderUnreadCount", // "Previlege": true, // "Region": null // }, // { // "ID": 56, // "ServiceName": "MedicalReportUnreadCount", // "Previlege": true, // "Region": null // }, // { // "ID": 57, // "ServiceName": "ERWaittingTimeShowing", // "Previlege": false, // "Region": null // }, // { // "ID": 58, // "ServiceName": "OnlinePayment", // "Previlege": true, // "Region": null // }, // { // "ID": 59, // "ServiceName": "RadiologyDisplayImage", // "Previlege": true, // "Region": null // }, // { // "ID": 60, // "ServiceName": "EmergencyConsultation", // "Previlege": true, // "Region": null // }, // { // "ID": 61, // "ServiceName": "PatientQueueCall", // "Previlege": true, // "Region": null // }, // { // "ID": 62, // "ServiceName": "OnlinePrescriptionOrder", // "Previlege": true, // "Region": null // }, // { // "ID": 63, // "ServiceName": "Transportations", // "Previlege": true, // "Region": null // }, // { // "ID": 64, // "ServiceName": "HomeHealthCareService", // "Previlege": true, // "Region": null // }, // { // "ID": 65, // "ServiceName": "Al-HabibPharmacyOnline", // "Previlege": true, // "Region": null // }, // { // "ID": 66, // "ServiceName": "Al-HabibOffers", // "Previlege": false, // "Region": null // }, // { // "ID": 67, // "ServiceName": "ComprehensiveMedicalCheckup", // "Previlege": true, // "Region": null // }, // { // "ID": 68, // "ServiceName": "RRT", // "Previlege": true, // "Region": null // }, // { // "ID": 72, // "ServiceName": "CancelLiveCareRequest", // "Previlege": false, // "Region": null // }, // { // "ID": 74, // "ServiceName": "Exacart", // "Previlege": true, // "Region": null // }, // { // "ID": 76, // "ServiceName": "Covid19-CarThrow", // "Previlege": true, // "Region": null // }, // { // "ID": 77, // "ServiceName": "VoiceBot", // "Previlege": true, // "Region": null // }, // { // "ID": 78, // "ServiceName": "LiveCareBookOnDoctorSchedule", // "Previlege": true, // "Region": null // }, // { // "ID": 79, // "ServiceName": "CheckIn_QR", // "Previlege": true, // "Region": null // }, // { // "ID": 80, // "ServiceName": "CheckIn_NFC", // "Previlege": true, // "Region": null // }, // { // "ID": 81, // "ServiceName": "ED", // "Previlege": false, // "Region": null // }, // { // "ID": 82, // "ServiceName": "Packages_&_Offers", // "Previlege": false, // "Region": null // }, // { // "ID": 83, // "ServiceName": "Lakum_Points", // "Previlege": false, // "Region": null // }, // { // "ID": 84, // "ServiceName": "QR_Reader", // "Previlege": true, // "Region": null // }, // { // "ID": 85, // "ServiceName": "AncillaryOrders", // "Previlege": true, // "Region": null // }, // { // "ID": 86, // "ServiceName": "Payment-MADA", // "Previlege": true, // "Region": null // }, // { // "ID": 87, // "ServiceName": "Payment-VISA", // "Previlege": true, // "Region": null // }, // { // "ID": 88, // "ServiceName": "Payment-MasterCard", // "Previlege": true, // "Region": null // }, // { // "ID": 89, // "ServiceName": "Payment-ApplePay", // "Previlege": true, // "Region": null // }, // { // "ID": 90, // "ServiceName": "Payment-Tamara", // "Previlege": true, // "Region": null // }, // { // "ID": 91, // "ServiceName": "Payment-Installment", // "Previlege": true, // "Region": null // }, // { // "ID": 92, // "ServiceName": "ED-Checkin", // "Previlege": false, // "Region": null // }, // { // "ID": 93, // "ServiceName": "NetworkDebug", // "Previlege": true, // "Region": null // }, // { // "ID": 94, // "ServiceName": "TamaraAncillary", // "Previlege": false, // "Region": null // }, // { // "ID": 95, // "ServiceName": "Verif-Face", // "Previlege": true, // "Region": null // }, // { // "ID": 96, // "ServiceName": "Verif-Finger", // "Previlege": true, // "Region": null // }, // { // "ID": 97, // "ServiceName": "Verif-SMS", // "Previlege": true, // "Region": null // }, // { // "ID": 98, // "ServiceName": "Verif-WhatsApp", // "Previlege": true, // "Region": null // }, // { // "ID": 99, // "ServiceName": "PharmacyLivecare", // "Previlege": true, // "Region": null // }, // { // "ID": 100, // "ServiceName": "ePharmacy", // "Previlege": true, // "Region": null // }, // { // "ID": 102, // "ServiceName": "CheckIn_Geofence", // "Previlege": true, // "Region": null // }, // { // "ID": 103, // "ServiceName": "Payment-ApplePay-Web", // "Previlege": true, // "Region": null // }, // { // "ID": 104, // "ServiceName": "Livecare_Zoom", // "Previlege": false, // "Region": null // }, // { // "ID": 105, // "ServiceName": "Dental Virtual Tour", // "Previlege": true, // "Region": null // }, // { // "ID": 106, // "ServiceName": "Dental Medical Instructions", // "Previlege": true, // "Region": null // }, // { // "ID": 107, // "ServiceName": "Navigation Service", // "Previlege": false, // "Region": null // } // ], // "Marital": null, // "OutSA": 0, // "POBox": "", // "ReceiveHealthSummaryReport": false, // "SourceType": 0, // "StrDateofBirth": null, // "TempAddress": "", // "ZipCode": "", // "eHealthIDField": null, // "patientPayType": null, // "patientType": null, // "status": null // } // ], // "List_AskHabibMobileLoginInfo": null, // "List_AskHabibPatientFile": null, // "List_FamilyRelationships": null, // "List_MergeFiles": null, // "List_MobileLoginInfo": null, // "List_PatientCount": null, // "LogInTokenID": null, // "MohemmPrivilege_List": null, // "PateintID": 5318335, // "PatientBloodType": "", // "PatientER_AdminDriverFileList": null, // "PatientER_AdminFile": null, // "PatientER_DriverFile": null, // "PatientER_DriverFileList": null, // "PatientHasFile": false, // "PatientMergedIDs": null, // "PatientOutSA": false, // "PatientShareRequestID": 0, // "PatientType": 0, // "ProjectIDOut": 0, // "ReturnMessage": null, // "SMSLoginRequired": false, // "ServicePrivilege_List": [ // { // "ID": 1, // "ServiceName": "Notifications", // "Previlege": true, // "Region": null // }, // { // "ID": 2, // "ServiceName": "Family Files", // "Previlege": true, // "Region": null // }, // { // "ID": 3, // "ServiceName": "Settings", // "Previlege": true, // "Region": null // }, // { // "ID": 4, // "ServiceName": "My Profile", // "Previlege": true, // "Region": null // }, // { // "ID": 5, // "ServiceName": "My Appointment", // "Previlege": true, // "Region": null // }, // { // "ID": 6, // "ServiceName": "My Doctors", // "Previlege": true, // "Region": null // }, // { // "ID": 7, // "ServiceName": "Radiology", // "Previlege": true, // "Region": null // }, // { // "ID": 8, // "ServiceName": "Radiology Email", // "Previlege": true, // "Region": null // }, // { // "ID": 9, // "ServiceName": "Radiology View Image", // "Previlege": true, // "Region": null // }, // { // "ID": 10, // "ServiceName": "Lab Results", // "Previlege": true, // "Region": null // }, // { // "ID": 11, // "ServiceName": "Lab Results Email", // "Previlege": true, // "Region": null // }, // { // "ID": 12, // "ServiceName": "Precriptions", // "Previlege": true, // "Region": null // }, // { // "ID": 13, // "ServiceName": "Precriptions Email", // "Previlege": true, // "Region": null // }, // { // "ID": 14, // "ServiceName": "Eye Measurments", // "Previlege": true, // "Region": null // }, // { // "ID": 15, // "ServiceName": "Eye Measurments Email", // "Previlege": true, // "Region": null // }, // { // "ID": 16, // "ServiceName": "Sick Leaves", // "Previlege": true, // "Region": null // }, // { // "ID": 17, // "ServiceName": "Sick Leaves Email", // "Previlege": true, // "Region": null // }, // { // "ID": 18, // "ServiceName": "Approvals", // "Previlege": true, // "Region": null // }, // { // "ID": 19, // "ServiceName": "Monthly Reports", // "Previlege": true, // "Region": null // }, // { // "ID": 20, // "ServiceName": "Request Medical Report", // "Previlege": true, // "Region": null // }, // { // "ID": 21, // "ServiceName": "Request Medical Report Email", // "Previlege": true, // "Region": null // }, // { // "ID": 22, // "ServiceName": "Insurance Cards", // "Previlege": true, // "Region": null // }, // { // "ID": 23, // "ServiceName": "Allergies", // "Previlege": true, // "Region": null // }, // { // "ID": 24, // "ServiceName": "My Trackers", // "Previlege": true, // "Region": null // }, // { // "ID": 25, // "ServiceName": "Vital Signs", // "Previlege": true, // "Region": null // }, // { // "ID": 26, // "ServiceName": "My Vaccines", // "Previlege": true, // "Region": null // }, // { // "ID": 27, // "ServiceName": "My Vaccines Email", // "Previlege": true, // "Region": null // }, // { // "ID": 28, // "ServiceName": "Ask Doctors", // "Previlege": true, // "Region": null // }, // { // "ID": 29, // "ServiceName": "Live Chat", // "Previlege": true, // "Region": null // }, // { // "ID": 30, // "ServiceName": "Health Data", // "Previlege": true, // "Region": null // }, // { // "ID": 31, // "ServiceName": "Online Check-in", // "Previlege": true, // "Region": null // }, // { // "ID": 32, // "ServiceName": "Connect to internet", // "Previlege": true, // "Region": null // }, // { // "ID": 33, // "ServiceName": "Advance Payment", // "Previlege": true, // "Region": null // }, // { // "ID": 34, // "ServiceName": "Book Appointment", // "Previlege": true, // "Region": null // }, // { // "ID": 35, // "ServiceName": "Child Vaccines", // "Previlege": true, // "Region": null // }, // { // "ID": 36, // "ServiceName": "Blood Donation", // "Previlege": true, // "Region": null // }, // { // "ID": 38, // "ServiceName": "H2O", // "Previlege": true, // "Region": null // }, // { // "ID": 40, // "ServiceName": "ChatBot", // "Previlege": false, // "Region": null // }, // { // "ID": 41, // "ServiceName": "Parking", // "Previlege": true, // "Region": null // }, // { // "ID": 42, // "ServiceName": "SymptomChecker", // "Previlege": false, // "Region": null // }, // { // "ID": 47, // "ServiceName": "AdvanceBalance", // "Previlege": true, // "Region": null // }, // { // "ID": 48, // "ServiceName": "ActiveMedications", // "Previlege": true, // "Region": null // }, // { // "ID": 49, // "ServiceName": "VaccineAvailability", // "Previlege": false, // "Region": null // }, // { // "ID": 51, // "ServiceName": "UpcomingAppointment", // "Previlege": true, // "Region": null // }, // { // "ID": 52, // "ServiceName": "PushNotificationCount", // "Previlege": true, // "Region": null // }, // { // "ID": 53, // "ServiceName": "ActiveMedicationCount", // "Previlege": true, // "Region": null // }, // { // "ID": 54, // "ServiceName": "LabOrderUnreadCount", // "Previlege": true, // "Region": null // }, // { // "ID": 55, // "ServiceName": "RadOrderUnreadCount", // "Previlege": true, // "Region": null // }, // { // "ID": 56, // "ServiceName": "MedicalReportUnreadCount", // "Previlege": true, // "Region": null // }, // { // "ID": 57, // "ServiceName": "ERWaittingTimeShowing", // "Previlege": false, // "Region": null // }, // { // "ID": 58, // "ServiceName": "OnlinePayment", // "Previlege": true, // "Region": null // }, // { // "ID": 59, // "ServiceName": "RadiologyDisplayImage", // "Previlege": true, // "Region": null // }, // { // "ID": 60, // "ServiceName": "EmergencyConsultation", // "Previlege": true, // "Region": null // }, // { // "ID": 61, // "ServiceName": "PatientQueueCall", // "Previlege": true, // "Region": null // }, // { // "ID": 62, // "ServiceName": "OnlinePrescriptionOrder", // "Previlege": true, // "Region": null // }, // { // "ID": 63, // "ServiceName": "Transportations", // "Previlege": true, // "Region": null // }, // { // "ID": 64, // "ServiceName": "HomeHealthCareService", // "Previlege": true, // "Region": null // }, // { // "ID": 65, // "ServiceName": "Al-HabibPharmacyOnline", // "Previlege": true, // "Region": null // }, // { // "ID": 66, // "ServiceName": "Al-HabibOffers", // "Previlege": false, // "Region": null // }, // { // "ID": 67, // "ServiceName": "ComprehensiveMedicalCheckup", // "Previlege": true, // "Region": null // }, // { // "ID": 68, // "ServiceName": "RRT", // "Previlege": true, // "Region": null // }, // { // "ID": 72, // "ServiceName": "CancelLiveCareRequest", // "Previlege": false, // "Region": null // }, // { // "ID": 74, // "ServiceName": "Exacart", // "Previlege": true, // "Region": null // }, // { // "ID": 76, // "ServiceName": "Covid19-CarThrow", // "Previlege": true, // "Region": null // }, // { // "ID": 77, // "ServiceName": "VoiceBot", // "Previlege": true, // "Region": null // }, // { // "ID": 78, // "ServiceName": "LiveCareBookOnDoctorSchedule", // "Previlege": true, // "Region": null // }, // { // "ID": 79, // "ServiceName": "CheckIn_QR", // "Previlege": true, // "Region": null // }, // { // "ID": 80, // "ServiceName": "CheckIn_NFC", // "Previlege": true, // "Region": null // }, // { // "ID": 81, // "ServiceName": "ED", // "Previlege": false, // "Region": null // }, // { // "ID": 82, // "ServiceName": "Packages_&_Offers", // "Previlege": false, // "Region": null // }, // { // "ID": 83, // "ServiceName": "Lakum_Points", // "Previlege": false, // "Region": null // }, // { // "ID": 84, // "ServiceName": "QR_Reader", // "Previlege": true, // "Region": null // }, // { // "ID": 85, // "ServiceName": "AncillaryOrders", // "Previlege": true, // "Region": null // }, // { // "ID": 86, // "ServiceName": "Payment-MADA", // "Previlege": true, // "Region": null // }, // { // "ID": 87, // "ServiceName": "Payment-VISA", // "Previlege": true, // "Region": null // }, // { // "ID": 88, // "ServiceName": "Payment-MasterCard", // "Previlege": true, // "Region": null // }, // { // "ID": 89, // "ServiceName": "Payment-ApplePay", // "Previlege": true, // "Region": null // }, // { // "ID": 90, // "ServiceName": "Payment-Tamara", // "Previlege": true, // "Region": null // }, // { // "ID": 91, // "ServiceName": "Payment-Installment", // "Previlege": true, // "Region": null // }, // { // "ID": 92, // "ServiceName": "ED-Checkin", // "Previlege": false, // "Region": null // }, // { // "ID": 93, // "ServiceName": "NetworkDebug", // "Previlege": true, // "Region": null // }, // { // "ID": 94, // "ServiceName": "TamaraAncillary", // "Previlege": false, // "Region": null // }, // { // "ID": 95, // "ServiceName": "Verif-Face", // "Previlege": true, // "Region": null // }, // { // "ID": 96, // "ServiceName": "Verif-Finger", // "Previlege": true, // "Region": null // }, // { // "ID": 97, // "ServiceName": "Verif-SMS", // "Previlege": true, // "Region": null // }, // { // "ID": 98, // "ServiceName": "Verif-WhatsApp", // "Previlege": true, // "Region": null // }, // { // "ID": 99, // "ServiceName": "PharmacyLivecare", // "Previlege": true, // "Region": null // }, // { // "ID": 100, // "ServiceName": "ePharmacy", // "Previlege": true, // "Region": null // }, // { // "ID": 102, // "ServiceName": "CheckIn_Geofence", // "Previlege": true, // "Region": null // }, // { // "ID": 103, // "ServiceName": "Payment-ApplePay-Web", // "Previlege": true, // "Region": null // }, // { // "ID": 104, // "ServiceName": "Livecare_Zoom", // "Previlege": false, // "Region": null // }, // { // "ID": 105, // "ServiceName": "Dental Virtual Tour", // "Previlege": true, // "Region": null // }, // { // "ID": 106, // "ServiceName": "Dental Medical Instructions", // "Previlege": true, // "Region": null // }, // { // "ID": 107, // "ServiceName": "Navigation Service", // "Previlege": false, // "Region": null // } // ], // "SharePatientName": null, // "UserAccountIsActivated": false, // "VerificationCode": null, // "email": null, // "errorList": null, // "hasFile": false, // "isActiveCode": false, // "isMerged": false, // "isNeedUserAgreement": false, // "isSMSSent": false, // "memberList": null, // "message": "Patient Registered Successfully", // "statusCode": 1 // }; await new BaseAppClient().post(REGISTER_USER, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); }, body: requestN.toJson()); return Future.value(localRes); } catch (error) { throw error; } } Future registeredAuthenticatedUser(AuthenticatedUser user, deviceToken, lat, long) async { var request = new RegisteredAuthenticatedUserRequest(); request.deviceToken = deviceToken; request.voipToken = ""; //this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false); request.deviceType = Platform.isIOS ? "1" : "2"; request.patientMobileNumber = user.mobileNumber![0] == '0' ? user.mobileNumber : '0' + user.mobileNumber!; request.nationalID = user.patientIdentificationNo; request.gender = user.gender; request.patientID = user.patientID; request.patientOutSA = user.outSA; request.loginType = await sharedPref.getInt(LAST_LOGIN) != null ? await sharedPref.getInt(LAST_LOGIN) : 1; request.mACAddress = '00:00:00:00:00:00'; request.latitude = lat; request.longitude = long; request.languageID = int.parse(user.preferredLanguage!); request.patientTypeID = user.patientType; request.patientType = user.patientType; dynamic localRes; try { await new BaseAppClient().post(LOGGED_IN_USER_URL, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); }, body: request.toJson()); return Future.value(localRes); } catch (error) { throw error; } } Future sendPatientIDSMS(mobileNo, zipCode, context) async { Map request; Request req = appGlobal.getPublicRequest(); request = { "PatientOutSA": zipCode == '+966' ? 0 : 1, "PatientMobileNumber": mobileNo, "SearchType": 2, "ZipCode": zipCode, "DeviceTypeID": req.DeviceTypeID, }; dynamic localRes; await new BaseAppClient().post(FORGOT_PATIENT_ID, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { throw error; }, body: request); return Future.value(localRes); } Future forgotPasswordActivation(request, [value]) async { request['VersionID'] = VERSION_ID; request['Channel'] = CHANNEL; request['IPAdress'] = IP_ADDRESS; request['generalid'] = GENERAL_ID; request['DeviceTypeID'] = Platform.isIOS ? 1 : 2; request['LanguageID'] = (languageID == 'ar' ? 1 : 2); dynamic localRes; try { await new BaseAppClient().post(FORGOT_PASSWORD, onSuccess: (dynamic response, int statusCode) { localRes = response; //CheckActivationCode.fromJson(); }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); // throw error; }, body: request); return Future.value(localRes); } catch (error) { throw error; //return Future.value(error); } } Future getDashboard() async { Map request = {}; dynamic localRes; try { await new BaseAppClient().post(DASHBOARD, onSuccess: (dynamic response, int statusCode) { localRes = response; //CheckActivationCode.fromJson(); }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); // throw error; }, body: request); return Future.value(localRes); } catch (error) { throw error; //return Future.value(error); } } getSettings() async { dynamic localRes; try { await new BaseAppClient().post(PROFILE_SETTING, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); }, body: {}); return Future.value(localRes); } catch (error) { throw error; } } Future saveSettings(request) async { dynamic localRes; try { await new BaseAppClient().post(SAVE_SETTING, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); }, body: request); return Future.value(localRes); } catch (error) { throw error; } } Future deactivateAccount(request, bool isLogin) async { dynamic localRes; try { await new BaseAppClient().post(DEACTIVATE_ACCOUNT, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); }, body: request); if (!isLogin) logout(); return Future.value(localRes); } catch (error) { throw error; } } Future activateAccount(request) async { dynamic localRes; try { await new BaseAppClient().post(DEACTIVATE_ACCOUNT, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { localRes = error; return Future.value(error); }, body: request); logout(); return Future.value(localRes); } catch (error) { throw error; } } logout() async { await sharedPref.remove(LOGIN_TOKEN_ID); await sharedPref.remove(PHARMACY_CUSTOMER_ID); await authenticatedUserObject.getUser(); Provider.of(AppGlobal.context, listen: false).isLogin = false; var model = Provider.of(AppGlobal.context, listen: false); model.setState(0, 0, false, null); Navigator.of(AppGlobal.context).pushReplacementNamed(HOME); } }