You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App/lib/services/authentication/auth_provider.dart

2004 lines
66 KiB
Dart

import 'dart:convert';
import 'dart:io';
import 'package:hmg_patient_app/config/config.dart';
import 'package:hmg_patient_app/config/shared_pref_kay.dart';
import 'package:hmg_patient_app/core/service/AuthenticatedUserObject.dart';
import 'package:hmg_patient_app/core/service/client/base_app_client.dart';
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
import 'package:hmg_patient_app/main.dart';
import 'package:hmg_patient_app/models/Appointments/toDoCountProviderModel.dart';
import 'package:hmg_patient_app/models/Authentication/authenticated_user.dart';
import 'package:hmg_patient_app/models/Authentication/check_activation_code_request.dart';
import 'package:hmg_patient_app/models/Authentication/check_activation_code_request_register.dart';
import 'package:hmg_patient_app/models/Authentication/check_activation_code_response.dart';
import 'package:hmg_patient_app/models/Authentication/check_paitent_authentication_req.dart';
import 'package:hmg_patient_app/models/Authentication/check_user_status_req.dart';
import 'package:hmg_patient_app/models/Authentication/checkpatient_for_registration.dart';
import 'package:hmg_patient_app/models/Authentication/insert_device_imei_request.dart';
import 'package:hmg_patient_app/models/Authentication/register_user_requet.dart';
import 'package:hmg_patient_app/models/Authentication/registered_authenticated_user_req.dart';
import 'package:hmg_patient_app/models/Authentication/select_device_imei_res.dart';
import 'package:hmg_patient_app/models/Authentication/send_activation_request.dart';
import 'package:hmg_patient_app/models/Request.dart';
import 'package:hmg_patient_app/routes.dart';
import 'package:hmg_patient_app/uitl/app_shared_preferences.dart';
import 'package:flutter/cupertino.dart';
import 'package:hmg_patient_app/uitl/date_uitl.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<AuthenticatedUserObject>();
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<dynamic> 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<dynamic> 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<SelectDeviceIMEIRES?> selectDeviceImei(imei, {int languageID = 1}) async {
SelectDeviceIMEIRES? selectDeviceIMEIRES;
try {
// SelectDeviceIMEIRES? localRes;
print(imei);
Map<String, dynamic> 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<dynamic> 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<dynamic> 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<dynamic> 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<dynamic> 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<dynamic> 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<dynamic> 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<dynamic> 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<dynamic> 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<dynamic> 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);
Map<String, dynamic> requestData;
if (request is String) {
requestData = jsonDecode(request) as Map<String, dynamic>;
} else if (request is Map) {
requestData = Map<String, dynamic>.from(request);
} else {
print("Error: Request is not in the expected format.");
throw ArgumentError("Request data is not a valid Map or JSON String.");
}
print(jsonEncode(requestData));
RegisterUserRequest requestN = RegisterUserRequest(patientobject: Patientobject.fromJson(request["Patientobject"]));
// 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.healthId = requestN.patientobject!.eHealthIdField;
}
requestN.dob =requestN.isHijri ==1 ? requestN.patientobject!.dateofBirth :dateFormat2.format(dateFormat.parse(requestN.patientobject!.strDateofBirth!));
requestN.isHijri =requestN.isHijri;
requestN.patientIdentificationID = requestN.patientobject!.patientIdentificationNo;
requestN.patientMobileNumber = requestN.patientobject!.mobileNumber.toString();
requestN.logInTokenID = await sharedPref.getString(LOGIN_TOKEN_ID);
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
// };
// print(requestN.toRawJson());
// return;
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<Map> sendPatientIDSMS(mobileNo, zipCode, context) async {
Map<String, dynamic> 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<dynamic> 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<dynamic> checkIfUserAgreed() async {
Map<String, dynamic> request;
request = {"Region": 1, "SessionID": SESSION_ID};
dynamic localRes;
try {
await new BaseAppClient().post(CHECK_USAGE_AGREEMENT, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: request);
return Future.value(localRes);
} catch (error) {
throw error;
}
}
Future<dynamic> getUserAgreementContent() async {
Map<String, dynamic> request;
request = {"Region": 1};
dynamic localRes;
try {
await new BaseAppClient().post(GET_USAGE_AGREEMENT, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: request);
return Future.value(localRes);
} catch (error) {
throw error;
}
}
Future<dynamic> addUserAgreementContent() async {
Map<String, dynamic> request;
request = {"Region": 1};
dynamic localRes;
try {
await new BaseAppClient().post(ADD_USAGE_AGREEMENT, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: request);
return Future.value(localRes);
} catch (error) {
throw error;
}
}
Future<dynamic> getDashboard() async {
Map<String, dynamic> 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;
}
}
Future getPatientOccupationList() async {
Map<String, dynamic> request = {"ProjectOutSA": false};
dynamic localRes;
try {
await new BaseAppClient().post(GET_PATIENT_OCCUPATION_LIST, 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<ProjectViewModel>(AppGlobal.context, listen: false).isLogin = false;
var model = Provider.of<ToDoCountProviderModel>(AppGlobal.context, listen: false);
model.setState(0, 0, false, null);
Navigator.of(AppGlobal.context).pushReplacementNamed(HOME);
}
SendActivationRequest getCommonRequest(
{type,
required registerd_data,
required deviceToken,
required mobileNumber,
required zipCode,
required patientOutSA,
required loginTokenID,
required selectedOption,
required SelectDeviceIMEIRES user}) {
var request = SendActivationRequest();
request.patientMobileNumber = mobileNumber;
request.mobileNo = '0' + mobileNumber.toString();
request.deviceToken = deviceToken;
request.projectOutSA = patientOutSA == true ? true : false;
request.loginType = selectedOption;
request.oTPSendType = type == 1 ? type : 2; //this.selectedOption == 1 ? 1 : 2;
request.zipCode = zipCode;
request.logInTokenID = loginTokenID ?? "";
if (registerd_data != null) {
request.searchType = registerd_data.searchType != null ? registerd_data.searchType : 1;
request.patientID = registerd_data.patientID != null ? registerd_data.patientID : 0;
request.patientIdentificationID = request.nationalID = registerd_data.patientIdentificationID != null ? registerd_data.patientIdentificationID : '0';
request.dob = registerd_data.dob;
request.isRegister = registerd_data.isRegister;
} else {
request.searchType = request.searchType != null ? request.searchType : 2;
request.patientID = user.patientID != null ? user.patientID : 0;
request.nationalID = request.nationalID != null ? request.nationalID : '0';
request.patientIdentificationID = request.patientIdentificationID != null ? request.patientIdentificationID : '0';
request.isRegister = false;
}
request.deviceTypeID = request.searchType;
return request;
}
}