bug fixes

dev_v3.13.6_voipcall
Sultan khan 2 years ago
parent 4338da513d
commit c1fbce7eae

@ -64,7 +64,7 @@ class Appointment {
logger('book_appointment_chief_complaints', parameters: { logger('book_appointment_chief_complaints', parameters: {
'appointment_type': appointment_type, 'appointment_type': appointment_type,
'clinic_type': clinic!.clinicDescription, 'clinic_type': clinic!.clinicDescription,
'hospital_name': hospital!.name, 'hospital_name':hospital!=null ? hospital!.name :"",
'treatment_type': treatment.name, 'treatment_type': treatment.name,
}); });
} }

@ -20,8 +20,8 @@ var PACKAGES_ORDERS = '/api/orders';
var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_ORDER_HISTORY = '/api/orders/items';
var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara';
// var BASE_URL = 'http://10.50.100.198:2018/'; // var BASE_URL = 'http://10.50.100.198:2018/';
var BASE_URL = 'https://uat.hmgwebservices.com/'; // var BASE_URL = 'https://uat.hmgwebservices.com/';
// var BASE_URL = 'https://hmgwebservices.com/'; var BASE_URL = 'https://hmgwebservices.com/';
// var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/';
// var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/';
// var BASE_URL = 'https://vidamergeuat.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidamergeuat.cloudsolutions.com.sa/';
@ -339,7 +339,7 @@ var UPDATE_COVID_QUESTIONNAIRE = 'Services/Doctors.svc/REST/COVID19_Questionnari
var CHANNEL = 3; var CHANNEL = 3;
var GENERAL_ID = 'Cs2020@2016\$2958'; var GENERAL_ID = 'Cs2020@2016\$2958';
var IP_ADDRESS = '10.20.10.20'; var IP_ADDRESS = '10.20.10.20';
var VERSION_ID = 11.5; var VERSION_ID = 11.6;
var SETUP_ID = '91877'; var SETUP_ID = '91877';
var LANGUAGE = 2; var LANGUAGE = 2;
// var PATIENT_OUT_SA = 0; // var PATIENT_OUT_SA = 0;

@ -30,16 +30,17 @@ AppSharedPreferences sharedPref = new AppSharedPreferences();
/// onFailure: (String error, int statusCode) {}, /// onFailure: (String error, int statusCode) {},
/// body: Map(); /// body: Map();
/// ///
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>(); AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
VitalSignService _vitalSignService = locator<VitalSignService>(); VitalSignService _vitalSignService = locator<VitalSignService>();
class BaseAppClient { class BaseAppClient {
final _analytics = locator<GAnalytics>(); final _analytics = locator<GAnalytics>();
post(String endPoint, post(String endPoint,
{Map<String, dynamic>? body, {required Map<String, dynamic> body,
Function(dynamic response, int statusCode)? onSuccess, required Function(dynamic response, int statusCode) onSuccess,
Function(String error, int statusCode)? onFailure, required Function(String error, int statusCode) onFailure,
bool isAllowAny = false, bool isAllowAny = false,
bool isExternal = false, bool isExternal = false,
bool isRCService = false, bool isRCService = false,
@ -54,16 +55,21 @@ class BaseAppClient {
url = BASE_URL + endPoint; url = BASE_URL + endPoint;
} }
try { try {
var pharmacyToken = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN); String? pharmacyToken =
await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN);
var user = await sharedPref.getObject(USER_PROFILE); var user = await sharedPref.getObject(USER_PROFILE);
Map<String, String> headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}; Map<String, String> headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
};
if (!isExternal) { if (!isExternal) {
var token = await sharedPref.getString(TOKEN); String? token = await sharedPref.getString(TOKEN);
var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); String? languageID =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
if (endPoint == SEND_ACTIVATION_CODE) { if (endPoint == SEND_ACTIVATION_CODE) {
languageID = 'en'; languageID = 'en';
} }
if (body!.containsKey('SetupID')) { if (body.containsKey('SetupID')) {
body['SetupID'] = body.containsKey('SetupID') body['SetupID'] = body.containsKey('SetupID')
? body['SetupID'] != null ? body['SetupID'] != null
? body['SetupID'] ? body['SetupID']
@ -75,14 +81,22 @@ class BaseAppClient {
body['Channel'] = CHANNEL; body['Channel'] = CHANNEL;
if (body.containsKey('LanguageID')) { if (body.containsKey('LanguageID')) {
if(body['LanguageID'] != null) { if (body['LanguageID'] != null) {
body['LanguageID'] = body['LanguageID']; body['LanguageID'] = body['LanguageID'];
} else { } else {
body['LanguageID'] = Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isArabic ? 1 : 2; body['LanguageID'] =
Provider.of<ProjectViewModel>(AppGlobal.context, listen: false)
.isArabic
? 1
: 2;
} }
} else { } else {
// body['LanguageID'] = (languageID.toString().toLowerCase() == 'ar' ? 1 : 2); // body['LanguageID'] = (languageID.toString().toLowerCase() == 'ar' ? 1 : 2);
body['LanguageID'] = Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isArabic ? 1 : 2; body['LanguageID'] =
Provider.of<ProjectViewModel>(AppGlobal.context, listen: false)
.isArabic
? 1
: 2;
} }
// body['LanguageID'] = Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isArabic ? 1 : 2; // body['LanguageID'] = Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isArabic ? 1 : 2;
@ -91,14 +105,15 @@ class BaseAppClient {
body['generalid'] = GENERAL_ID; body['generalid'] = GENERAL_ID;
// body['isVidaPlus'] = true; // body['isVidaPlus'] = true;
double? lat = await AppSharedPreferences().getDouble(USER_LAT); double lat = await AppSharedPreferences().getDouble(USER_LAT) ?? 0.0;
double? long = await AppSharedPreferences().getDouble(USER_LONG); double long = await AppSharedPreferences().getDouble(USER_LONG) ?? 0.0;
body['Latitude'] = lat == null ? 0.0 : lat; body['Latitude'] = lat;
body['Longitude'] = long == null ? 0.0 : long; body['Longitude'] = long;
if (body.containsKey('isDentalAllowedBackend')) { if (body.containsKey('isDentalAllowedBackend')) {
body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') body['isDentalAllowedBackend'] =
body.containsKey('isDentalAllowedBackend')
? body['isDentalAllowedBackend'] != null ? body['isDentalAllowedBackend'] != null
? body['isDentalAllowedBackend'] ? body['isDentalAllowedBackend']
: IS_DENTAL_ALLOWED_BACKEND : IS_DENTAL_ALLOWED_BACKEND
@ -146,7 +161,9 @@ class BaseAppClient {
if (user != null) { if (user != null) {
body['TokenID'] = body['TokenID'] != null ? body['TokenID'] : token; body['TokenID'] = body['TokenID'] != null ? body['TokenID'] : token;
body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : user['PatientID']; body['PatientID'] = body['PatientID'] != null
? body['PatientID']
: user['PatientID'];
body['PatientOutSA'] = body.containsKey('PatientOutSA') body['PatientOutSA'] = body.containsKey('PatientOutSA')
? body['PatientOutSA'] != null ? body['PatientOutSA'] != null
@ -176,7 +193,7 @@ class BaseAppClient {
// Mobile no.: 0502303285 // Mobile no.: 0502303285
// ID: 119116817 // ID: 119116817
body!.removeWhere((key, value) => key == null || value == null); body.removeWhere((key, value) => key == null || value == null);
// if (AppGlobal.isNetworkDebugEnabled) { // if (AppGlobal.isNetworkDebugEnabled) {
print("URL : $url"); print("URL : $url");
@ -184,12 +201,15 @@ class BaseAppClient {
print(jsonBody); print(jsonBody);
// } // }
if (await Utils.checkConnection(bypassConnectionCheck: bypassConnectionCheck)) { if (await Utils.checkConnection(
final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers); bypassConnectionCheck: bypassConnectionCheck)) {
final response = await http.post(Uri.parse(url.trim()),
body: json.encode(body), headers: headers);
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure!('Error While Fetching data', statusCode); onFailure('Error While Fetching data', statusCode);
logApiEndpointError(endPoint, 'Error While Fetching data', statusCode); logApiEndpointError(
endPoint, 'Error While Fetching data', statusCode);
} else { } else {
// var decoded = utf8.decode(response.bodyBytes); // var decoded = utf8.decode(response.bodyBytes);
var parsed = json.decode(utf8.decode(response.bodyBytes)); var parsed = json.decode(utf8.decode(response.bodyBytes));
@ -197,54 +217,76 @@ class BaseAppClient {
// print("Response: $parsed"); // print("Response: $parsed");
if (isAllowAny) { if (isAllowAny) {
onSuccess!(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else {
if (parsed['Response_Message'] != null) { if (parsed['Response_Message'] != null) {
onSuccess!(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else {
if (parsed['ErrorType'] == 4) { if (parsed['ErrorType'] == 4) {
navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']); navigateToAppUpdate(
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); AppGlobal.context, parsed['ErrorEndUserMessage']);
logApiEndpointError(
endPoint,
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
} }
if (parsed['ErrorType'] == 2) { if (parsed['ErrorType'] == 2) {
await logout(); await logout();
logApiEndpointError(endPoint, "session logged out", statusCode); logApiEndpointError(endPoint, "session logged out", statusCode);
} }
if (isAllowAny) { if (isAllowAny) {
onSuccess!(parsed, statusCode); onSuccess(parsed, statusCode);
} else if (parsed['IsAuthenticated'] == null) { } else if (parsed['IsAuthenticated'] == null) {
if (parsed['isSMSSent'] == true) { if (parsed['isSMSSent'] == true) {
onSuccess!(parsed, statusCode); onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 1) { } else if (parsed['MessageStatus'] == 1) {
onSuccess!(parsed, statusCode); onSuccess(parsed, statusCode);
} else if (parsed['Result'] == 'OK') { } else if (parsed['Result'] == 'OK') {
onSuccess!(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else {
// if (parsed != null) { // if (parsed != null) {
// onSuccess(parsed, statusCode); // onSuccess(parsed, statusCode);
// } else { // } else {
onFailure!(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure(
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
logApiEndpointError(
endPoint,
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
// logout(); // logout();
// } // }
} }
} else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) { } else if (parsed['MessageStatus'] == 1 ||
onSuccess!(parsed, statusCode); parsed['SMSLoginRequired'] == true) {
} else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) { onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 2 &&
parsed['IsAuthenticated']) {
if (parsed['SameClinicApptList'] != null) { if (parsed['SameClinicApptList'] != null) {
onSuccess!(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else {
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { if (parsed['message'] == null &&
parsed['ErrorEndUserMessage'] == null) {
if (parsed['ErrorSearchMsg'] == null) { if (parsed['ErrorSearchMsg'] == null) {
onFailure!("Server Error found with no available message", statusCode); onFailure("Server Error found with no available message",
logApiEndpointError(endPoint, "Server Error found with no available message", statusCode); statusCode);
logApiEndpointError(
endPoint,
"Server Error found with no available message",
statusCode);
} else { } else {
onFailure!(parsed['ErrorSearchMsg'], statusCode); onFailure(parsed['ErrorSearchMsg'], statusCode);
logApiEndpointError(endPoint, parsed['ErrorSearchMsg'], statusCode); logApiEndpointError(
endPoint, parsed['ErrorSearchMsg'], statusCode);
} }
} else { } else {
onFailure!(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure(
logApiEndpointError(endPoint, parsed['message'] ?? parsed['message'], statusCode); parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
logApiEndpointError(endPoint,
parsed['message'] ?? parsed['message'], statusCode);
} }
} }
} }
@ -253,14 +295,21 @@ class BaseAppClient {
// } // }
else { else {
if (parsed['SameClinicApptList'] != null) { if (parsed['SameClinicApptList'] != null) {
onSuccess!(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else {
if (parsed['message'] != null) { if (parsed['message'] != null) {
onFailure!(parsed['message'] ?? parsed['message'], statusCode); onFailure(
logApiEndpointError(endPoint, parsed['message'] ?? parsed['message'], statusCode); parsed['message'] ?? parsed['message'], statusCode);
logApiEndpointError(endPoint,
parsed['message'] ?? parsed['message'], statusCode);
} else { } else {
onFailure!(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure(
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
logApiEndpointError(
endPoint,
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
} }
} }
} }
@ -268,18 +317,23 @@ class BaseAppClient {
} }
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} catch (e) { } catch (e) {
print(e); print(e);
onFailure!(e.toString(), -1); onFailure(e.toString(), -1);
_analytics.errorTracking.log(endPoint, error: "api exception: $e"); _analytics.errorTracking.log(endPoint, error: "api exception: $e");
} }
} }
postPharmacy(String endPoint, postPharmacy(String endPoint,
{Map<String, dynamic>? body, Function(dynamic response, int statusCode)? onSuccess, Function(String error, int statusCode)? onFailure, bool isAllowAny = false, bool isExternal = false}) async { {Map<String, dynamic>? body,
Function(dynamic response, int statusCode)? onSuccess,
Function(String error, int statusCode)? onFailure,
bool isAllowAny = false,
bool isExternal = false}) async {
var token = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN); var token = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN);
var user = await sharedPref.getObject(USER_PROFILE); var user = await sharedPref.getObject(USER_PROFILE);
String url; String url;
@ -296,13 +350,16 @@ class BaseAppClient {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json', 'Accept': 'application/json',
'Authorization': pharmacyToken ?? '', 'Authorization': pharmacyToken ?? '',
'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", 'Mobilenumber': user != null
? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString())
: "",
'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
'Username': user != null ? user['PatientID'].toString() : "", 'Username': user != null ? user['PatientID'].toString() : "",
}; };
if (!isExternal) { if (!isExternal) {
String token = await sharedPref.getString(TOKEN); String token = await sharedPref.getString(TOKEN);
var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); var languageID =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
// if (body.containsKey('SetupID')) { // if (body.containsKey('SetupID')) {
// body['SetupID'] = body.containsKey('SetupID') // body['SetupID'] = body.containsKey('SetupID')
@ -364,12 +421,14 @@ class BaseAppClient {
print("Headers : ${json.encode(headers)}"); print("Headers : ${json.encode(headers)}");
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers); final response = await http.post(Uri.parse(url.trim()),
body: json.encode(body), headers: headers);
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
// print("statusCode :$statusCode"); // print("statusCode :$statusCode");
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure!('Error While Fetching data', statusCode); onFailure!('Error While Fetching data', statusCode);
logApiEndpointError(endPoint, 'Error While Fetching data', statusCode); logApiEndpointError(
endPoint, 'Error While Fetching data', statusCode);
} else { } else {
// var parsed = json.decode(response.body.toString()); // var parsed = json.decode(response.body.toString());
var parsed = json.decode(utf8.decode(response.bodyBytes)); var parsed = json.decode(utf8.decode(response.bodyBytes));
@ -377,8 +436,12 @@ class BaseAppClient {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else { } else {
if (parsed['ErrorType'] == 4) { if (parsed['ErrorType'] == 4) {
navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']); navigateToAppUpdate(
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); AppGlobal.context, parsed['ErrorEndUserMessage']);
logApiEndpointError(
endPoint,
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
} }
if (isAllowAny) { if (isAllowAny) {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
@ -393,29 +456,56 @@ class BaseAppClient {
if (parsed != null) { if (parsed != null) {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else { } else {
onFailure!(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
logApiEndpointError(endPoint, 'session logged out', statusCode); statusCode);
logApiEndpointError(
endPoint,
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
logApiEndpointError(
endPoint, 'session logged out', statusCode);
logout(); logout();
} }
} }
} else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) { } else if (parsed['MessageStatus'] == 1 ||
parsed['SMSLoginRequired'] == true) {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) { } else if (parsed['MessageStatus'] == 2 &&
parsed['IsAuthenticated']) {
if (parsed['SameClinicApptList'] != null) { if (parsed['SameClinicApptList'] != null) {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else { } else {
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { if (parsed['message'] == null &&
parsed['ErrorEndUserMessage'] == null) {
if (parsed['ErrorSearchMsg'] == null) { if (parsed['ErrorSearchMsg'] == null) {
onFailure!("Server Error found with no available message", statusCode); onFailure!("Server Error found with no available message",
logApiEndpointError(endPoint, "Server Error found with no available message", statusCode); statusCode);
logApiEndpointError(
endPoint,
"Server Error found with no available message",
statusCode);
} else { } else {
onFailure!(parsed['ErrorSearchMsg'], statusCode); onFailure!(parsed['ErrorSearchMsg'], statusCode);
logApiEndpointError(endPoint, parsed['ErrorSearchMsg'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); logApiEndpointError(
endPoint,
parsed['ErrorSearchMsg'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
} }
} else { } else {
onFailure!(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
logApiEndpointError(
endPoint,
parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
} }
} }
} else if (!parsed['IsAuthenticated']) { } else if (!parsed['IsAuthenticated']) {
@ -427,11 +517,22 @@ class BaseAppClient {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else { } else {
if (parsed['message'] != null) { if (parsed['message'] != null) {
onFailure!(parsed['message'] ?? parsed['message'], statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['message'] ?? parsed['message'], statusCode);
logApiEndpointError(
endPoint,
parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
} else { } else {
onFailure!(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
logApiEndpointError(
endPoint,
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
} }
} }
} }
@ -439,7 +540,8 @@ class BaseAppClient {
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure!('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} catch (e) { } catch (e) {
print(e); print(e);
@ -451,7 +553,8 @@ class BaseAppClient {
Future navigateToAppUpdate(context, String text) async { Future navigateToAppUpdate(context, String text) async {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
context, context,
MaterialPageRoute(builder: (context) => AppUpdatePage(appUpdateText: text)), MaterialPageRoute(
builder: (context) => AppUpdatePage(appUpdateText: text)),
(Route<dynamic> route) => false, (Route<dynamic> route) => false,
); );
} }
@ -482,7 +585,10 @@ class BaseAppClient {
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
final response = await http.get( final response = await http.get(
Uri.parse(url.trim()), Uri.parse(url.trim()),
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
); );
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
// print("statusCode :$statusCode"); // print("statusCode :$statusCode");
@ -496,7 +602,8 @@ class BaseAppClient {
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure!('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} }
@ -528,7 +635,9 @@ class BaseAppClient {
'Content-Type': 'text/html; charset=utf-8', 'Content-Type': 'text/html; charset=utf-8',
'Accept': 'application/json', 'Accept': 'application/json',
'Authorization': token ?? '', 'Authorization': token ?? '',
'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", 'Mobilenumber': user != null
? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString())
: "",
'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
'Username': user != null ? user['PatientID'].toString() : "", 'Username': user != null ? user['PatientID'].toString() : "",
// 'Host': "mdlaboratories.com", // 'Host': "mdlaboratories.com",
@ -538,14 +647,19 @@ class BaseAppClient {
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
if (statusCode == 401) { if (statusCode == 401) {
onFailure!(TranslationBase.of(AppGlobal.context).pharmacyRelogin, statusCode); onFailure!(TranslationBase.of(AppGlobal.context).pharmacyRelogin,
logApiEndpointError(endPoint, TranslationBase.of(AppGlobal.context).pharmacyRelogin, statusCode); statusCode);
logApiEndpointError(
endPoint,
TranslationBase.of(AppGlobal.context).pharmacyRelogin,
statusCode);
Navigator.of(AppGlobal.context).pushNamed(HOME); Navigator.of(AppGlobal.context).pushNamed(HOME);
} else { } else {
var bodyUtf = json.decode(utf8.decode(response.bodyBytes)); var bodyUtf = json.decode(utf8.decode(response.bodyBytes));
// print(bodyUtf); // print(bodyUtf);
onFailure!(bodyUtf['error']['ErrorEndUserMsg'], statusCode); onFailure!(bodyUtf['error']['ErrorEndUserMsg'], statusCode);
logApiEndpointError(endPoint, bodyUtf['error']['ErrorEndUserMsg'], statusCode); logApiEndpointError(
endPoint, bodyUtf['error']['ErrorEndUserMsg'], statusCode);
} }
} else { } else {
// var parsed = json.decode(response.body.toString()); // var parsed = json.decode(response.body.toString());
@ -554,7 +668,8 @@ class BaseAppClient {
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure!('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} }
@ -570,7 +685,8 @@ class BaseAppClient {
// print("body: $body"); // print("body: $body");
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
headers!.addAll({'Content-Type': 'application/json', 'Accept': 'application/json'}); headers!.addAll(
{'Content-Type': 'application/json', 'Accept': 'application/json'});
final response = await http.post( final response = await http.post(
Uri.parse(url.trim()), Uri.parse(url.trim()),
body: json.encode(body), body: json.encode(body),
@ -578,7 +694,12 @@ class BaseAppClient {
); );
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
// print("statusCode :$statusCode"); // print("statusCode :$statusCode");
if (await handleUnauthorized(statusCode, forUrl: fullUrl)) simplePost(fullUrl, onFailure: onFailure, onSuccess: onSuccess, body: body, headers: headers); if (await handleUnauthorized(statusCode, forUrl: fullUrl))
simplePost(fullUrl,
onFailure: onFailure,
onSuccess: onSuccess,
body: body,
headers: headers);
// print(response.body.toString()); // print(response.body.toString());
@ -590,12 +711,16 @@ class BaseAppClient {
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure!('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} }
simpleGet(String fullUrl, simpleGet(String fullUrl,
{Function(dynamic response, int statusCode)? onSuccess, Function(String error, int statusCode)? onFailure, Map<String, dynamic>? queryParams, Map<String, String>? headers}) async { {Function(dynamic response, int statusCode)? onSuccess,
Function(String error, int statusCode)? onFailure,
Map<String, dynamic>? queryParams,
Map<String, String>? headers}) async {
headers = headers ?? {}; headers = headers ?? {};
String url = fullUrl; String url = fullUrl;
@ -607,7 +732,8 @@ class BaseAppClient {
} }
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
headers.addAll({'Content-Type': 'application/json', 'Accept': 'application/json'}); headers.addAll(
{'Content-Type': 'application/json', 'Accept': 'application/json'});
final response = await http.get( final response = await http.get(
Uri.parse(url.trim()), Uri.parse(url.trim()),
headers: headers, headers: headers,
@ -615,7 +741,12 @@ class BaseAppClient {
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
// print("statusCode :$statusCode"); // print("statusCode :$statusCode");
if (await handleUnauthorized(statusCode, forUrl: fullUrl)) simpleGet(fullUrl, onFailure: onFailure, onSuccess: onSuccess, headers: headers, queryParams: queryParams); if (await handleUnauthorized(statusCode, forUrl: fullUrl))
simpleGet(fullUrl,
onFailure: onFailure,
onSuccess: onSuccess,
headers: headers,
queryParams: queryParams);
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure!('Error While Fetching data', statusCode); onFailure!('Error While Fetching data', statusCode);
@ -625,16 +756,22 @@ class BaseAppClient {
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure!('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} }
simplePut(String fullUrl, {Map<String, dynamic>? body, Map<String, String>? headers, Function(dynamic response, int statusCode)? onSuccess, Function(String error, int statusCode)? onFailure}) async { simplePut(String fullUrl,
{Map<String, dynamic>? body,
Map<String, String>? headers,
Function(dynamic response, int statusCode)? onSuccess,
Function(String error, int statusCode)? onFailure}) async {
String url = fullUrl; String url = fullUrl;
// print("URL Query String: $url"); // print("URL Query String: $url");
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
headers!.addAll({'Content-Type': 'application/json', 'Accept': 'application/json'}); headers!.addAll(
{'Content-Type': 'application/json', 'Accept': 'application/json'});
final response = await http.put( final response = await http.put(
Uri.parse(url.trim()), Uri.parse(url.trim()),
body: json.encode(body), body: json.encode(body),
@ -643,7 +780,12 @@ class BaseAppClient {
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
// print("statusCode :$statusCode"); // print("statusCode :$statusCode");
if (await handleUnauthorized(statusCode, forUrl: fullUrl)) simplePut(fullUrl, onFailure: onFailure, onSuccess: onSuccess, headers: headers, body: body); if (await handleUnauthorized(statusCode, forUrl: fullUrl))
simplePut(fullUrl,
onFailure: onFailure,
onSuccess: onSuccess,
headers: headers,
body: body);
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure!('Error While Fetching data', statusCode); onFailure!('Error While Fetching data', statusCode);
@ -653,12 +795,16 @@ class BaseAppClient {
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure!('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} }
simpleDelete(String fullUrl, simpleDelete(String fullUrl,
{Function(dynamic response, int statusCode)? onSuccess, Function(String error, int statusCode)? onFailure, Map<String, String>? queryParams, Map<String, String>? headers}) async { {Function(dynamic response, int statusCode)? onSuccess,
Function(String error, int statusCode)? onFailure,
Map<String, String>? queryParams,
Map<String, String>? headers}) async {
String url = fullUrl; String url = fullUrl;
// print("URL Query String: $url"); // print("URL Query String: $url");
@ -670,7 +816,8 @@ class BaseAppClient {
} }
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
headers!.addAll({'Content-Type': 'application/json', 'Accept': 'application/json'}); headers!.addAll(
{'Content-Type': 'application/json', 'Accept': 'application/json'});
final response = await http.delete( final response = await http.delete(
Uri.parse(url.trim()), Uri.parse(url.trim()),
headers: headers, headers: headers,
@ -678,7 +825,12 @@ class BaseAppClient {
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
// print("statusCode :$statusCode"); // print("statusCode :$statusCode");
if (await handleUnauthorized(statusCode, forUrl: fullUrl)) simpleDelete(fullUrl, onFailure: onFailure, onSuccess: onSuccess, queryParams: queryParams, headers: headers); if (await handleUnauthorized(statusCode, forUrl: fullUrl))
simpleDelete(fullUrl,
onFailure: onFailure,
onSuccess: onSuccess,
queryParams: queryParams,
headers: headers);
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
onFailure!('Error While Fetching data', statusCode); onFailure!('Error While Fetching data', statusCode);
@ -688,11 +840,13 @@ class BaseAppClient {
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure!('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} }
Future<bool> handleUnauthorized(int statusCode, {required String forUrl}) async { Future<bool> handleUnauthorized(int statusCode,
{required String forUrl}) async {
if (forUrl.startsWith(EXA_CART_API_BASE_URL) && statusCode == 401) { if (forUrl.startsWith(EXA_CART_API_BASE_URL) && statusCode == 401) {
final token = await generatePackagesToken(); final token = await generatePackagesToken();
packagesAuthHeader['Authorization'] = 'Bearer $token'; packagesAuthHeader['Authorization'] = 'Bearer $token';
@ -705,8 +859,10 @@ class BaseAppClient {
await sharedPref.remove(LOGIN_TOKEN_ID); await sharedPref.remove(LOGIN_TOKEN_ID);
await sharedPref.remove(PHARMACY_CUSTOMER_ID); await sharedPref.remove(PHARMACY_CUSTOMER_ID);
await authenticatedUserObject.getUser(); await authenticatedUserObject.getUser();
Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isLogin = false; Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isLogin =
var model = Provider.of<ToDoCountProviderModel>(AppGlobal.context, listen: false); false;
var model =
Provider.of<ToDoCountProviderModel>(AppGlobal.context, listen: false);
_vitalSignService.weightKg = ""; _vitalSignService.weightKg = "";
_vitalSignService.heightCm = ""; _vitalSignService.heightCm = "";
model.setState(0, false, ""); model.setState(0, false, "");
@ -720,7 +876,8 @@ class BaseAppClient {
static defaultHttpParameters() async { static defaultHttpParameters() async {
String token = await sharedPref.getString(TOKEN); String token = await sharedPref.getString(TOKEN);
var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); var languageID =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
var user = await sharedPref.getObject(USER_PROFILE); var user = await sharedPref.getObject(USER_PROFILE);
var params = {}; var params = {};
if (user != null) { if (user != null) {
@ -740,7 +897,11 @@ class BaseAppClient {
} }
pharmacyPost(String endPoint, pharmacyPost(String endPoint,
{Map<String, dynamic>? body, Function(dynamic response, int statusCode)? onSuccess, Function(String error, int statusCode)? onFailure, bool isAllowAny = false, bool isExternal = false}) async { {Map<String, dynamic>? body,
Function(dynamic response, int statusCode)? onSuccess,
Function(String error, int statusCode)? onFailure,
bool isAllowAny = false,
bool isExternal = false}) async {
var token = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN); var token = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN);
var user = await sharedPref.getObject(USER_PROFILE); var user = await sharedPref.getObject(USER_PROFILE);
String url; String url;
@ -752,7 +913,8 @@ class BaseAppClient {
try { try {
if (isExternal) { if (isExternal) {
String token = await sharedPref.getString(TOKEN); String token = await sharedPref.getString(TOKEN);
var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); var languageID =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
var user = await sharedPref.getObject(USER_PROFILE); var user = await sharedPref.getObject(USER_PROFILE);
if (body!.containsKey('SetupID')) { if (body!.containsKey('SetupID')) {
body['SetupID'] = body.containsKey('SetupID') body['SetupID'] = body.containsKey('SetupID')
@ -775,7 +937,8 @@ class BaseAppClient {
: user['OutSA']; : user['OutSA'];
if (body.containsKey('isDentalAllowedBackend')) { if (body.containsKey('isDentalAllowedBackend')) {
body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') body['isDentalAllowedBackend'] =
body.containsKey('isDentalAllowedBackend')
? body['isDentalAllowedBackend'] != null ? body['isDentalAllowedBackend'] != null
? body['isDentalAllowedBackend'] ? body['isDentalAllowedBackend']
: IS_DENTAL_ALLOWED_BACKEND : IS_DENTAL_ALLOWED_BACKEND
@ -802,7 +965,9 @@ class BaseAppClient {
: user['PatientType']; : user['PatientType'];
if (user != null) { if (user != null) {
body['TokenID'] = token; body['TokenID'] = token;
body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : user['PatientID']; body['PatientID'] = body['PatientID'] != null
? body['PatientID']
: user['PatientID'];
body['PatientOutSA'] = user['OutSA']; body['PatientOutSA'] = user['OutSA'];
// body['SessionID'] = SESSION_ID; //getSessionId(token); // body['SessionID'] = SESSION_ID; //getSessionId(token);
} }
@ -814,11 +979,14 @@ class BaseAppClient {
var ss = json.encode(body); var ss = json.encode(body);
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {
final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: { final response = await http
.post(Uri.parse(url.trim()), body: json.encode(body), headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json', 'Accept': 'application/json',
'Authorization': token ?? '', 'Authorization': token ?? '',
'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", 'Mobilenumber': user != null
? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString())
: "",
'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',
'Username': user != null ? user['PatientID'].toString() : "", 'Username': user != null ? user['PatientID'].toString() : "",
}); });
@ -826,8 +994,15 @@ class BaseAppClient {
// print("statusCode :$statusCode"); // print("statusCode :$statusCode");
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
var parsed = json.decode(utf8.decode(response.bodyBytes)); var parsed = json.decode(utf8.decode(response.bodyBytes));
onFailure!(parsed['error']['ErrorEndUserMsgN'] ?? 'Error While Fetching data', statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['error']['ErrorEndUserMsgN'] ?? 'Error While Fetching data', statusCode); parsed['error']['ErrorEndUserMsgN'] ??
'Error While Fetching data',
statusCode);
logApiEndpointError(
endPoint,
parsed['error']['ErrorEndUserMsgN'] ??
'Error While Fetching data',
statusCode);
} else { } else {
// var parsed = json.decode(response.body.toString()); // var parsed = json.decode(response.body.toString());
var parsed = json.decode(utf8.decode(response.bodyBytes)); var parsed = json.decode(utf8.decode(response.bodyBytes));
@ -835,7 +1010,8 @@ class BaseAppClient {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else { } else {
if (parsed['ErrorType'] == 4) { if (parsed['ErrorType'] == 4) {
navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']); navigateToAppUpdate(
AppGlobal.context, parsed['ErrorEndUserMessage']);
} }
if (isAllowAny) { if (isAllowAny) {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
@ -850,25 +1026,47 @@ class BaseAppClient {
if (parsed != null) { if (parsed != null) {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else { } else {
onFailure!(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
logApiEndpointError(
endPoint,
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
logout(); logout();
} }
} }
} else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) { } else if (parsed['MessageStatus'] == 1 ||
parsed['SMSLoginRequired'] == true) {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) { } else if (parsed['MessageStatus'] == 2 &&
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { parsed['IsAuthenticated']) {
if (parsed['message'] == null &&
parsed['ErrorEndUserMessage'] == null) {
if (parsed['ErrorSearchMsg'] == null) { if (parsed['ErrorSearchMsg'] == null) {
onFailure!("Server Error found with no available message", statusCode); onFailure!("Server Error found with no available message",
logApiEndpointError(endPoint, "Server Error found with no available message", statusCode); statusCode);
logApiEndpointError(
endPoint,
"Server Error found with no available message",
statusCode);
} else { } else {
onFailure!(parsed['ErrorSearchMsg'], statusCode); onFailure!(parsed['ErrorSearchMsg'], statusCode);
logApiEndpointError(endPoint, parsed['ErrorSearchMsg'], statusCode); logApiEndpointError(
endPoint, parsed['ErrorSearchMsg'], statusCode);
} }
} else { } else {
onFailure!(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
logApiEndpointError(
endPoint,
parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
} }
} else if (!parsed['IsAuthenticated']) { } else if (!parsed['IsAuthenticated']) {
await logout(); await logout();
@ -879,11 +1077,18 @@ class BaseAppClient {
onSuccess!(parsed, statusCode); onSuccess!(parsed, statusCode);
} else { } else {
if (parsed['message'] != null) { if (parsed['message'] != null) {
onFailure!(parsed['message'] ?? parsed['message'], statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['message'] ?? parsed['message'], statusCode); parsed['message'] ?? parsed['message'], statusCode);
logApiEndpointError(endPoint,
parsed['message'] ?? parsed['message'], statusCode);
} else { } else {
onFailure!(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); onFailure!(
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
logApiEndpointError(
endPoint,
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
} }
} }
} }
@ -891,7 +1096,8 @@ class BaseAppClient {
} }
} else { } else {
onFailure!('Please Check The Internet Connection', -1); onFailure!('Please Check The Internet Connection', -1);
_analytics.errorTracking.log("internet_connectivity", error: "no internet available"); _analytics.errorTracking
.log("internet_connectivity", error: "no internet available");
} }
} catch (e) { } catch (e) {
print(e); print(e);
@ -903,11 +1109,15 @@ class BaseAppClient {
Future<String> generatePackagesToken() async { Future<String> generatePackagesToken() async {
var url = EXA_CART_API_BASE_URL + PACKAGES_TOKEN; var url = EXA_CART_API_BASE_URL + PACKAGES_TOKEN;
var body = { var body = {
"api_client": {"client_id": "a4ab6be4-424f-4836-b032-46caed88e184", "client_secret": "3c1a3e07-4a40-4510-9fb0-ee5f0a72752c"} "api_client": {
"client_id": "a4ab6be4-424f-4836-b032-46caed88e184",
"client_secret": "3c1a3e07-4a40-4510-9fb0-ee5f0a72752c"
}
}; };
String? token; String? token;
final completer = Completer(); final completer = Completer();
simplePost(url, body: body, headers: {}, onSuccess: (dynamic stringResponse, int statusCode) { simplePost(url, body: body, headers: {},
onSuccess: (dynamic stringResponse, int statusCode) {
if (statusCode == 200) { if (statusCode == 200) {
var jsonResponse = json.decode(stringResponse); var jsonResponse = json.decode(stringResponse);
token = jsonResponse['auth_token']; token = jsonResponse['auth_token'];

@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class DentalComplaintCard extends StatefulWidget { class DentalComplaintCard extends StatefulWidget {
final ListDentalChiefComplain listDentalChiefComplain; final ListDentalChiefComplain listDentalChiefComplain;
late VoidCallback logAnalytics; late Function logAnalytics;
var languageID; var languageID;
Function? onSelectedMethod; Function? onSelectedMethod;
bool isDoctorNameSearch; bool isDoctorNameSearch;

@ -51,10 +51,13 @@ class _Login extends State<Login> {
final authService = AuthProvider(); final authService = AuthProvider();
var sharedPref = AppSharedPreferences(); var sharedPref = AppSharedPreferences();
bool isLoading = false; bool isLoading = false;
AppointmentRateViewModel appointmentRateViewModel = locator<AppointmentRateViewModel>(); AppointmentRateViewModel appointmentRateViewModel =
PharmacyModuleViewModel pharmacyModuleViewModel = locator<PharmacyModuleViewModel>(); locator<AppointmentRateViewModel>();
PharmacyModuleViewModel pharmacyModuleViewModel =
locator<PharmacyModuleViewModel>();
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>(); AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
late ProjectViewModel projectViewModel; late ProjectViewModel projectViewModel;
late ToDoCountProviderModel toDoProvider; late ToDoCountProviderModel toDoProvider;
@ -110,7 +113,9 @@ class _Login extends State<Login> {
HabibLogoWidget(), HabibLogoWidget(),
SizedBox(height: 50), SizedBox(height: 50),
Text( Text(
loginType == 1 ? TranslationBase.of(context).enterNationalId : TranslationBase.of(context).enterFile, loginType == 1
? TranslationBase.of(context).enterNationalId
: TranslationBase.of(context).enterFile,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -129,7 +134,9 @@ class _Login extends State<Login> {
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: inputWidget( child: inputWidget(
loginType == 1 ? TranslationBase.of(context).nationalIdNumber : TranslationBase.of(context).medicalFileNumber, loginType == 1
? TranslationBase.of(context).nationalIdNumber
: TranslationBase.of(context).medicalFileNumber,
"Xxxxxxxxx", "Xxxxxxxxx",
nationalIDorFile, nationalIDorFile,
), ),
@ -143,8 +150,7 @@ class _Login extends State<Login> {
DefaultButton( DefaultButton(
TranslationBase.of(context).login, TranslationBase.of(context).login,
() { () {
if (!isButtonDisabled) if (!isButtonDisabled) this.startLogin();
this.startLogin();
}, },
disabledColor: Color(0xff575757), disabledColor: Color(0xff575757),
), ),
@ -153,7 +159,9 @@ class _Login extends State<Login> {
); );
} }
Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String? prefix, bool isEnable = true, bool hasSelection = false}) { Widget inputWidget(
String _labelText, String _hintText, TextEditingController _controller,
{String? prefix, bool isEnable = true, bool hasSelection = false}) {
return Container( return Container(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
alignment: Alignment.center, alignment: Alignment.center,
@ -242,7 +250,8 @@ class _Login extends State<Login> {
} }
void validateForm() { void validateForm() {
if (util.validateIDBox(nationalIDorFile.text, loginType) == true && util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) { if (util.validateIDBox(nationalIDorFile.text, loginType) == true &&
util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) {
setState(() { setState(() {
isButtonDisabled = false; isButtonDisabled = false;
}); });
@ -306,7 +315,8 @@ class _Login extends State<Login> {
}, },
cancelFunction: () => {}); cancelFunction: () => {});
dialog.showAlertDialog(context); dialog.showAlertDialog(context);
projectViewModel.analytics.loginRegistration.login_fail(error: err.toString()); projectViewModel.analytics.loginRegistration
.login_fail(error: err.toString());
}); });
} }
@ -348,7 +358,8 @@ class _Login extends State<Login> {
projectViewModel.setPrivilege(privilegeList: result); projectViewModel.setPrivilege(privilegeList: result);
result = CheckActivationCode.fromJson(result); result = CheckActivationCode.fromJson(result);
result.list.isFamily = false; result.list.isFamily = false;
this.sharedPref.setString(BLOOD_TYPE, result.patientBloodType != null ? result.patientBloodType : ""); this.sharedPref.setString(BLOOD_TYPE,
result.patientBloodType != null ? result.patientBloodType : "");
this.sharedPref.setObject(USER_PROFILE, result.list); this.sharedPref.setObject(USER_PROFILE, result.list);
this.sharedPref.setObject(MAIN_USER, result.list); this.sharedPref.setObject(MAIN_USER, result.list);
this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID); this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID);
@ -359,13 +370,16 @@ class _Login extends State<Login> {
projectViewModel.isLogin = true; projectViewModel.isLogin = true;
authenticatedUserObject.user = result.list; authenticatedUserObject.user = result.list;
projectViewModel.user = authenticatedUserObject.user; projectViewModel.user = authenticatedUserObject.user;
int languageID = Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 1 : 2; int languageID =
Provider.of<ProjectViewModel>(context, listen: false).isArabic
? 1
: 2;
appointmentRateViewModel appointmentRateViewModel
.getIsLastAppointmentRatedList(languageID) .getIsLastAppointmentRatedList(languageID)
.then((value) => { .then((value) => {
checkIfIsInPatient(), checkIfIsInPatient(),
getToDoCount(), getToDoCount(),
GifLoaderDialogUtils.hideDialog(context), // GifLoaderDialogUtils.hideDialog(context),
if (appointmentRateViewModel.isHaveAppointmentNotRate) if (appointmentRateViewModel.isHaveAppointmentNotRate)
{ {
Navigator.pushAndRemoveUntil( Navigator.pushAndRemoveUntil(
@ -396,22 +410,24 @@ class _Login extends State<Login> {
toDoProvider.setState(0, true, toDoProvider.notificationsCount); toDoProvider.setState(0, true, toDoProvider.notificationsCount);
ClinicListService service = new ClinicListService(); ClinicListService service = new ClinicListService();
service.getActiveAppointmentNo(context).then((res) { service.getActiveAppointmentNo(context).then((res) {
print(res['AppointmentActiveNumber']); //print(res['AppointmentActiveNumber']);
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
toDoProvider.setState(res['AppointmentActiveNumber'], true, toDoProvider.notificationsCount); toDoProvider.setState(res['AppointmentActiveNumber'], true,
toDoProvider.notificationsCount);
} else {} } else {}
}).catchError((err) { }).catchError((err) {
print(err); print(err);
}); });
} }
checkIfIsInPatient() { checkIfIsInPatient() async {
bool isAdmitted = false; bool isAdmitted = false;
bool hasAdmissionRequest = false; bool hasAdmissionRequest = false;
GetAdmissionInfoResponseModel getAdmissionInfoResponseModel; GetAdmissionInfoResponseModel getAdmissionInfoResponseModel;
GetAdmissionRequestInfoResponseModel getAdmissionRequestInfoResponseModel; GetAdmissionRequestInfoResponseModel getAdmissionRequestInfoResponseModel;
ClinicListService? service = new ClinicListService(); ClinicListService? service = new ClinicListService();
service.checkIfInPatientAPI(context).then((res) { dynamic res = await service.checkIfInPatientAPI(context);
if (res != null) {
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
isAdmitted = res['isAdmitted']; isAdmitted = res['isAdmitted'];
hasAdmissionRequest = res['hasAdmissionRequests']; hasAdmissionRequest = res['hasAdmissionRequests'];
@ -419,22 +435,30 @@ class _Login extends State<Login> {
print("Has Admission Request: $hasAdmissionRequest"); print("Has Admission Request: $hasAdmissionRequest");
if (isAdmitted) { if (isAdmitted) {
if (res['PatientAdmittedInformation'].length != 0) { if (res['PatientAdmittedInformation'].length != 0) {
getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]); getAdmissionInfoResponseModel =
projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); GetAdmissionInfoResponseModel.fromJson(
projectViewModel.setInPatientAdmissionInfo(getAdmissionInfoResponseModel); res['PatientAdmittedInformation'][0]);
projectViewModel.setInPatientProjectID(
res['PatientAdmittedInformation'][0]['ProjectID']);
projectViewModel
.setInPatientAdmissionInfo(getAdmissionInfoResponseModel);
projectViewModel.setIsPatientAdmitted(true); projectViewModel.setIsPatientAdmitted(true);
} }
} }
if (hasAdmissionRequest) { if (hasAdmissionRequest) {
if (res['MedicalInstruction'].length != 0) { if (res['MedicalInstruction'].length != 0) {
getAdmissionRequestInfoResponseModel = GetAdmissionRequestInfoResponseModel.fromJson(res['MedicalInstruction'][0]); getAdmissionRequestInfoResponseModel =
projectViewModel.setInPatientProjectID(res['MedicalInstruction'][0]['ProjectID']); GetAdmissionRequestInfoResponseModel.fromJson(
projectViewModel.setInPatientAdmissionRequest(getAdmissionRequestInfoResponseModel); res['MedicalInstruction'][0]);
projectViewModel.setInPatientProjectID(
res['MedicalInstruction'][0]['ProjectID']);
projectViewModel.setInPatientAdmissionRequest(
getAdmissionRequestInfoResponseModel);
projectViewModel.setPatientHasAdmissionRequest(true); projectViewModel.setPatientHasAdmissionRequest(true);
} }
} }
} else {} }
}); }
} }
void registerGeoZones() async { void registerGeoZones() async {
@ -448,7 +472,8 @@ class _Login extends State<Login> {
if (registerData != null) { if (registerData != null) {
setState(() { setState(() {
this.nationalIDorFile.text = registerData['PatientIdentificationID'].toString(); this.nationalIDorFile.text =
registerData['PatientIdentificationID'].toString();
this.isButtonDisabled = false; this.isButtonDisabled = false;
this.loginType = 1; this.loginType = 1;
this.mobileNo = registerData['PatientMobileNumber'].toString(); this.mobileNo = registerData['PatientMobileNumber'].toString();

@ -201,11 +201,12 @@ class _RateAppointmentDoctorState extends State<RateAppointmentDoctor> {
), ),
); );
} else { } else {
Navigator.pop( //changed due to blank page coming before
Navigator.pushReplacement(
context, context,
// FadePage( FadePage(
// page: LandingPage(), page: LandingPage(),
// ), ),
); );
} }
} }

@ -33,35 +33,48 @@ enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
AppSharedPreferences sharedPref = AppSharedPreferences(); AppSharedPreferences sharedPref = AppSharedPreferences();
AppGlobal appGlobal = AppGlobal(); AppGlobal appGlobal = AppGlobal();
const String INSERT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI'; const String INSERT_DEVICE_IMEI =
const String SELECT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_SELECTDeviceIMEIbyIMEI'; 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI';
const String CHECK_PATIENT_AUTH = 'Services/Authentication.svc/REST/CheckPatientAuthentication'; 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 GET_MOBILE_INFO = 'Services/Authentication.svc/REST/GetMobileLoginInfo';
const SEND_ACTIVATION_CODE = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType'; const SEND_ACTIVATION_CODE =
'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType';
const SEND_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationTypeForRegistration'; const SEND_ACTIVATION_CODE_REGISTER =
const CHECK_ACTIVATION_CODE = 'Services/Authentication.svc/REST/CheckActivationCode'; 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationTypeForRegistration';
const CHECK_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/CheckActivationCodeForRegistration'; 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 FORGOT_PASSWORD =
const CHECK_PATIENT_FOR_REGISTRATION = "Services/Authentication.svc/REST/CheckPatientForRegisteration"; '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 CHECK_USER_STATUS = "Services/NHIC.svc/REST/GetPatientInfo";
const REGISTER_USER = 'Services/Authentication.svc/REST/PatientRegistration'; const REGISTER_USER = 'Services/Authentication.svc/REST/PatientRegistration';
const LOGGED_IN_USER_URL = 'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo'; const LOGGED_IN_USER_URL =
'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo';
const FORGOT_PATIENT_ID = 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber'; const FORGOT_PATIENT_ID =
'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard'; const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard';
const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate'; const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate';
const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo'; const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo';
const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_InsertUpdate'; const DEACTIVATE_ACCOUNT =
'Services/Patients.svc/REST/PatientAppleActivation_InsertUpdate';
class AuthProvider with ChangeNotifier { class AuthProvider with ChangeNotifier {
bool isLogin = false; bool isLogin = false;
bool isLoading = true; bool isLoading = true;
dynamic authenticatedUser; dynamic authenticatedUser;
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>(); AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
var languageID; var languageID;
AuthProvider() { AuthProvider() {
@ -117,14 +130,17 @@ class AuthProvider with ChangeNotifier {
var lastLogin = lstLogin; //await sharedPref.getInt( var lastLogin = lstLogin; //await sharedPref.getInt(
// LAST_LOGIN); //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); //this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false); // 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 request =
AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
var newRequest = INSERTDeviceIMEIRequest(); var newRequest = INSERTDeviceIMEIRequest();
var imei = await sharedPref.getString(PUSH_TOKEN); var imei = await sharedPref.getString(PUSH_TOKEN);
// if (!request.) { // if (!request.) {
newRequest.iMEI = imei; //imei!=null ? imei : ''; newRequest.iMEI = imei; //imei!=null ? imei : '';
newRequest.firstName = request.firstName ?? "" + " " + request.lastName! ?? ""; newRequest.firstName =
newRequest.firstNameN = request.firstNameN ?? "" + " " + request.lastNameN! ?? ""; request.firstName ?? "" + " " + request.lastName! ?? "";
newRequest.firstNameN =
request.firstNameN ?? "" + " " + request.lastNameN! ?? "";
newRequest.lastNameN = request.lastNameN ?? ""; newRequest.lastNameN = request.lastNameN ?? "";
newRequest.outSA = request.outSA == 1 ? true : false; newRequest.outSA = request.outSA == 1 ? true : false;
newRequest.biometricEnabled = false; newRequest.biometricEnabled = false;
@ -139,7 +155,8 @@ class AuthProvider with ChangeNotifier {
newRequest.tokenID = await sharedPref.getString(TOKEN); newRequest.tokenID = await sharedPref.getString(TOKEN);
// } // }
await new BaseAppClient().post(INSERT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(INSERT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
@ -157,37 +174,45 @@ class AuthProvider with ChangeNotifier {
print(imei); print(imei);
Map<String, dynamic> request = {}; Map<String, dynamic> request = {};
request['IMEI'] = imei; request['IMEI'] = imei;
await BaseAppClient().post(SELECT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) async { await BaseAppClient().post(SELECT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) async {
localRes = Map(); localRes = Map();
if (response['Patient_SELECTDeviceIMEIbyIMEIList'][0] != null) { if (response['Patient_SELECTDeviceIMEIbyIMEIList'][0] != null) {
localRes = SelectDeviceIMEIRES.fromJson( localRes = SelectDeviceIMEIRES.fromJson(
response['Patient_SELECTDeviceIMEIbyIMEIList'][0]); response['Patient_SELECTDeviceIMEIbyIMEIList'][0]);
} }
request['LanguageID'] = Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isArabic ? 1 : 2; request['LanguageID'] =
await new BaseAppClient().post(SELECT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) { Provider.of<ProjectViewModel>(AppGlobal.context, listen: false)
localRes = SelectDeviceIMEIRES.fromJson(response['Patient_SELECTDeviceIMEIbyIMEIList'][0]); .isArabic
? 1
: 2;
await new BaseAppClient().post(SELECT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
localRes = SelectDeviceIMEIRES.fromJson(
response['Patient_SELECTDeviceIMEIbyIMEIList'][0]);
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: request); }, body: request);
return Future.value(localRes); return Future.value(localRes);
}); }, onFailure: (String error, int statusCode) {}, body: {});
} } catch (error) {
catch (error) {
return Future.error(error); return Future.error(error);
} }
} }
Future<dynamic> checkPatientAuthentication(CheckPatientAuthenticationReq request) async { Future<dynamic> checkPatientAuthentication(
CheckPatientAuthenticationReq request) async {
request.versionID = VERSION_ID; request.versionID = VERSION_ID;
request.channel = CHANNEL; request.channel = CHANNEL;
request.iPAdress = IP_ADDRESS; request.iPAdress = IP_ADDRESS;
request.generalid = GENERAL_ID; request.generalid = GENERAL_ID;
request.languageID = (languageID == 'ar' ? 1 : 2); request.languageID = (languageID == 'ar' ? 1 : 2);
request.patientOutSA = (request.zipCode == '966' || request.zipCode == '+966') ? 0 : 1; request.patientOutSA =
(request.zipCode == '966' || request.zipCode == '+966') ? 0 : 1;
try { try {
dynamic localRes; dynamic localRes;
await new BaseAppClient().post(CHECK_PATIENT_AUTH, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(CHECK_PATIENT_AUTH,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
@ -211,7 +236,8 @@ class AuthProvider with ChangeNotifier {
// request.patientTypeID = request.patientType; // request.patientTypeID = request.patientType;
// request.patientType = request.patientType; // request.patientType = request.patientType;
dynamic localRes; dynamic localRes;
await new BaseAppClient().post(GET_MOBILE_INFO, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(GET_MOBILE_INFO,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
@ -231,7 +257,8 @@ class AuthProvider with ChangeNotifier {
request.isDentalAllowedBackend = false; request.isDentalAllowedBackend = false;
dynamic localRes; dynamic localRes;
await new BaseAppClient().post(SEND_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(SEND_ACTIVATION_CODE,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
authenticatedUser = CheckActivationCode.fromJson(localRes); authenticatedUser = CheckActivationCode.fromJson(localRes);
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
@ -251,7 +278,8 @@ class AuthProvider with ChangeNotifier {
request.isDentalAllowedBackend = false; request.isDentalAllowedBackend = false;
dynamic localRes; dynamic localRes;
await new BaseAppClient().post(SEND_ACTIVATION_CODE_REGISTER, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(SEND_ACTIVATION_CODE_REGISTER,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
authenticatedUser = CheckActivationCode.fromJson(localRes); authenticatedUser = CheckActivationCode.fromJson(localRes);
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
@ -274,11 +302,13 @@ class AuthProvider with ChangeNotifier {
neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true; neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true;
neRequest.isDentalAllowedBackend = false; neRequest.isDentalAllowedBackend = false;
// neRequest.deviceToken = null; // neRequest.deviceToken = null;
neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false; neRequest.forRegisteration =
neRequest.isRegister != null ? neRequest.isRegister : false;
neRequest.isRegister = false; neRequest.isRegister = false;
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(CHECK_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(CHECK_ACTIVATION_CODE,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson(); localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -306,11 +336,13 @@ class AuthProvider with ChangeNotifier {
neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true; neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true;
neRequest.isDentalAllowedBackend = false; neRequest.isDentalAllowedBackend = false;
// neRequest.deviceToken = null; // neRequest.deviceToken = null;
neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false; neRequest.forRegisteration =
neRequest.isRegister != null ? neRequest.isRegister : false;
neRequest.isRegister = false; neRequest.isRegister = false;
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(CHECK_ACTIVATION_CODE_REGISTER, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(CHECK_ACTIVATION_CODE_REGISTER,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson(); localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -330,7 +362,8 @@ class AuthProvider with ChangeNotifier {
return authenticatedUser; return authenticatedUser;
} }
Future<dynamic> checkPatientForRegisteration(CheckPatientForRegistration request) async { Future<dynamic> checkPatientForRegisteration(
CheckPatientForRegistration request) async {
request.versionID = VERSION_ID; request.versionID = VERSION_ID;
request.channel = CHANNEL; request.channel = CHANNEL;
request.iPAdress = IP_ADDRESS; request.iPAdress = IP_ADDRESS;
@ -341,7 +374,8 @@ class AuthProvider with ChangeNotifier {
// request.tokenID = ''; // request.tokenID = '';
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(CHECK_PATIENT_FOR_REGISTRATION, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(CHECK_PATIENT_FOR_REGISTRATION,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -364,7 +398,8 @@ class AuthProvider with ChangeNotifier {
// request.tokenID = ''; // request.tokenID = '';
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(CHECK_USER_STATUS, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(CHECK_USER_STATUS,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -390,7 +425,9 @@ class AuthProvider with ChangeNotifier {
final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); final DateFormat dateFormat = DateFormat('MM/dd/yyyy');
final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy');
if (nhic != null) { if (nhic != null) {
requestN.dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); requestN.dob = nhic['IsHijri']
? nhic['DateOfBirth']
: dateFormat2.format(dateFormat.parse(nhic['DateOfBirth']));
requestN.isHijri = nhic['IsHijri'] ? 1 : 0; requestN.isHijri = nhic['IsHijri'] ? 1 : 0;
requestN.healthId = requestN.patientobject!.eHealthIDField!; requestN.healthId = requestN.patientobject!.eHealthIDField!;
} }
@ -401,7 +438,8 @@ class AuthProvider with ChangeNotifier {
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(REGISTER_USER, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(REGISTER_USER,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -413,17 +451,23 @@ class AuthProvider with ChangeNotifier {
} }
} }
Future registeredAuthenticatedUser(AuthenticatedUser user, deviceToken, lat, long) async { Future registeredAuthenticatedUser(
AuthenticatedUser user, deviceToken, lat, long) async {
var request = new RegisteredAuthenticatedUserRequest(); var request = new RegisteredAuthenticatedUserRequest();
request.deviceToken = deviceToken; request.deviceToken = deviceToken;
request.voipToken = ""; //this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false); request.voipToken =
""; //this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false);
request.deviceType = Platform.isIOS ? "1" : "2"; request.deviceType = Platform.isIOS ? "1" : "2";
request.patientMobileNumber = user.mobileNumber![0] == '0' ? user.mobileNumber : '0' + user.mobileNumber!; request.patientMobileNumber = user.mobileNumber![0] == '0'
? user.mobileNumber
: '0' + user.mobileNumber!;
request.nationalID = user.patientIdentificationNo; request.nationalID = user.patientIdentificationNo;
request.gender = user.gender; request.gender = user.gender;
request.patientID = user.patientID; request.patientID = user.patientID;
request.patientOutSA = user.outSA; request.patientOutSA = user.outSA;
request.loginType = await sharedPref.getInt(LAST_LOGIN) != null ? await sharedPref.getInt(LAST_LOGIN) : 1; request.loginType = await sharedPref.getInt(LAST_LOGIN) != null
? await sharedPref.getInt(LAST_LOGIN)
: 1;
request.mACAddress = '00:00:00:00:00:00'; request.mACAddress = '00:00:00:00:00:00';
request.latitude = lat; request.latitude = lat;
request.longitude = long; request.longitude = long;
@ -432,7 +476,8 @@ class AuthProvider with ChangeNotifier {
request.patientType = user.patientType; request.patientType = user.patientType;
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(LOGGED_IN_USER_URL, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(LOGGED_IN_USER_URL,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -458,7 +503,8 @@ class AuthProvider with ChangeNotifier {
dynamic localRes; dynamic localRes;
await new BaseAppClient().post(FORGOT_PATIENT_ID, onSuccess: (response, statusCode) async { await new BaseAppClient().post(FORGOT_PATIENT_ID,
onSuccess: (response, statusCode) async {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
@ -476,7 +522,8 @@ class AuthProvider with ChangeNotifier {
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(FORGOT_PASSWORD, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(FORGOT_PASSWORD,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson(); localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -495,7 +542,8 @@ class AuthProvider with ChangeNotifier {
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(DASHBOARD, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(DASHBOARD,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson(); localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -512,7 +560,8 @@ class AuthProvider with ChangeNotifier {
getSettings() async { getSettings() async {
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(PROFILE_SETTING, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(PROFILE_SETTING,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -527,7 +576,8 @@ class AuthProvider with ChangeNotifier {
Future saveSettings(request) async { Future saveSettings(request) async {
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(SAVE_SETTING, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(SAVE_SETTING,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -542,7 +592,8 @@ class AuthProvider with ChangeNotifier {
Future deactivateAccount(request, bool isLogin) async { Future deactivateAccount(request, bool isLogin) async {
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(DEACTIVATE_ACCOUNT, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(DEACTIVATE_ACCOUNT,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -558,7 +609,8 @@ class AuthProvider with ChangeNotifier {
Future activateAccount(request) async { Future activateAccount(request) async {
dynamic localRes; dynamic localRes;
try { try {
await new BaseAppClient().post(DEACTIVATE_ACCOUNT, onSuccess: (dynamic response, int statusCode) { await new BaseAppClient().post(DEACTIVATE_ACCOUNT,
onSuccess: (dynamic response, int statusCode) {
localRes = response; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
localRes = error; localRes = error;
@ -575,8 +627,10 @@ class AuthProvider with ChangeNotifier {
await sharedPref.remove(LOGIN_TOKEN_ID); await sharedPref.remove(LOGIN_TOKEN_ID);
await sharedPref.remove(PHARMACY_CUSTOMER_ID); await sharedPref.remove(PHARMACY_CUSTOMER_ID);
await authenticatedUserObject.getUser(); await authenticatedUserObject.getUser();
Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isLogin = false; Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isLogin =
var model = Provider.of<ToDoCountProviderModel>(AppGlobal.context, listen: false); false;
var model =
Provider.of<ToDoCountProviderModel>(AppGlobal.context, listen: false);
model.setState(0, false, ""); model.setState(0, false, "");
Navigator.of(AppGlobal.context).pushReplacementNamed(HOME); Navigator.of(AppGlobal.context).pushReplacementNamed(HOME);
} }

@ -52,7 +52,7 @@ class ClinicListService extends BaseService {
} }
Future<Map> checkIfInPatientAPI(context) async { Future<Map> checkIfInPatientAPI(context) async {
Map<String, dynamic> request; Map<String, dynamic>? request;
request = { request = {
"IsActiveAppointment": false, "IsActiveAppointment": false,
}; };

Loading…
Cancel
Save