|
|
|
|
@ -43,16 +43,20 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
|
|
NewLoginInformationModel get loginInfo => _authService.loginInfo;
|
|
|
|
|
|
|
|
|
|
List<DoctorProfileModel> get doctorProfilesList => _authService.doctorProfilesList;
|
|
|
|
|
List<DoctorProfileModel> get doctorProfilesList =>
|
|
|
|
|
_authService.doctorProfilesList;
|
|
|
|
|
|
|
|
|
|
SendActivationCodeForDoctorAppResponseModel get activationCodeVerificationScreenRes =>
|
|
|
|
|
_authService.activationCodeVerificationScreenRes;
|
|
|
|
|
SendActivationCodeForDoctorAppResponseModel
|
|
|
|
|
get activationCodeVerificationScreenRes =>
|
|
|
|
|
_authService.activationCodeVerificationScreenRes;
|
|
|
|
|
|
|
|
|
|
SendActivationCodeForDoctorAppResponseModel get activationCodeForDoctorAppRes =>
|
|
|
|
|
_authService.activationCodeForDoctorAppRes;
|
|
|
|
|
SendActivationCodeForDoctorAppResponseModel
|
|
|
|
|
get activationCodeForDoctorAppRes =>
|
|
|
|
|
_authService.activationCodeForDoctorAppRes;
|
|
|
|
|
|
|
|
|
|
CheckActivationCodeForDoctorAppResponseModel get checkActivationCodeForDoctorAppRes =>
|
|
|
|
|
_authService.checkActivationCodeForDoctorAppRes;
|
|
|
|
|
CheckActivationCodeForDoctorAppResponseModel
|
|
|
|
|
get checkActivationCodeForDoctorAppRes =>
|
|
|
|
|
_authService.checkActivationCodeForDoctorAppRes;
|
|
|
|
|
|
|
|
|
|
NewLoginInformationModel? loggedUser;
|
|
|
|
|
GetIMEIDetailsModel? user;
|
|
|
|
|
@ -66,13 +70,12 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
bool unverified = false;
|
|
|
|
|
bool isFromLogin = false;
|
|
|
|
|
APP_STATUS appStatus = APP_STATUS.LOADING;
|
|
|
|
|
String localToken ="";
|
|
|
|
|
String localToken = "";
|
|
|
|
|
AuthenticationViewModel() {
|
|
|
|
|
getDeviceInfoFromFirebase();
|
|
|
|
|
getDoctorProfile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Insert Device IMEI
|
|
|
|
|
Future insertDeviceImei(token) async {
|
|
|
|
|
var loggedIn = await sharedPref.getObj(LOGGED_IN_USER);
|
|
|
|
|
@ -86,19 +89,29 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
profileInfo['IMEI'] = token;
|
|
|
|
|
profileInfo['LogInTypeID'] = await sharedPref.getInt(OTP_TYPE);
|
|
|
|
|
profileInfo['BioMetricEnabled'] = true;
|
|
|
|
|
profileInfo['MobileNo'] = loggedIn != null ? loggedIn['MobileNumber'] : user!.mobile;
|
|
|
|
|
InsertIMEIDetailsModel insertIMEIDetailsModel = InsertIMEIDetailsModel.fromJson(profileInfo);
|
|
|
|
|
insertIMEIDetailsModel.genderDescription = profileInfo['Gender_Description'];
|
|
|
|
|
insertIMEIDetailsModel.genderDescriptionN = profileInfo['Gender_DescriptionN'];
|
|
|
|
|
insertIMEIDetailsModel.genderDescriptionN = profileInfo['Gender_DescriptionN'];
|
|
|
|
|
profileInfo['MobileNo'] =
|
|
|
|
|
loggedIn != null ? loggedIn['MobileNumber'] : user!.mobile;
|
|
|
|
|
InsertIMEIDetailsModel insertIMEIDetailsModel =
|
|
|
|
|
InsertIMEIDetailsModel.fromJson(profileInfo);
|
|
|
|
|
insertIMEIDetailsModel.genderDescription =
|
|
|
|
|
profileInfo['Gender_Description'];
|
|
|
|
|
insertIMEIDetailsModel.genderDescriptionN =
|
|
|
|
|
profileInfo['Gender_DescriptionN'];
|
|
|
|
|
insertIMEIDetailsModel.genderDescriptionN =
|
|
|
|
|
profileInfo['Gender_DescriptionN'];
|
|
|
|
|
insertIMEIDetailsModel.titleDescription = profileInfo['Title_Description'];
|
|
|
|
|
insertIMEIDetailsModel.titleDescriptionN = profileInfo['Title_DescriptionN'];
|
|
|
|
|
insertIMEIDetailsModel.titleDescriptionN =
|
|
|
|
|
profileInfo['Title_DescriptionN'];
|
|
|
|
|
insertIMEIDetailsModel.projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
insertIMEIDetailsModel.doctorID =
|
|
|
|
|
loggedIn != null ? loggedIn['List_MemberInformation'][0]['MemberID'] : user!.doctorID;
|
|
|
|
|
insertIMEIDetailsModel.outSA = loggedIn != null ? loggedIn['PatientOutSA'] : user!.outSA;
|
|
|
|
|
insertIMEIDetailsModel.vidaAuthTokenID = await sharedPref.getString(VIDA_AUTH_TOKEN_ID);
|
|
|
|
|
insertIMEIDetailsModel.vidaRefreshTokenID = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID);
|
|
|
|
|
insertIMEIDetailsModel.doctorID = loggedIn != null
|
|
|
|
|
? loggedIn['List_MemberInformation'][0]['MemberID']
|
|
|
|
|
: user!.doctorID;
|
|
|
|
|
insertIMEIDetailsModel.outSA =
|
|
|
|
|
loggedIn != null ? loggedIn['PatientOutSA'] : user!.outSA;
|
|
|
|
|
insertIMEIDetailsModel.vidaAuthTokenID =
|
|
|
|
|
await sharedPref.getString(VIDA_AUTH_TOKEN_ID);
|
|
|
|
|
insertIMEIDetailsModel.vidaRefreshTokenID =
|
|
|
|
|
await sharedPref.getString(VIDA_REFRESH_TOKEN_ID);
|
|
|
|
|
insertIMEIDetailsModel.password = userInfo.password;
|
|
|
|
|
|
|
|
|
|
await _authService.insertDeviceImei(insertIMEIDetailsModel);
|
|
|
|
|
@ -127,20 +140,23 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// send activation code for for msg methods
|
|
|
|
|
Future sendActivationCodeVerificationScreen(AuthMethodTypes authMethodType) async {
|
|
|
|
|
Future sendActivationCodeVerificationScreen(
|
|
|
|
|
AuthMethodTypes authMethodType) async {
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
ActivationCodeForVerificationScreenModel activationCodeModel = ActivationCodeForVerificationScreenModel(
|
|
|
|
|
iMEI: user!.iMEI,
|
|
|
|
|
facilityId: user!.projectID,
|
|
|
|
|
memberID: user!.doctorID,
|
|
|
|
|
loginDoctorID: int.parse(user!.editedBy.toString()),
|
|
|
|
|
zipCode: user!.outSA == true ? '971' : '966',
|
|
|
|
|
mobileNumber: user!.mobile,
|
|
|
|
|
oTPSendType: authMethodType.getTypeIdService(),
|
|
|
|
|
isMobileFingerPrint: 1,
|
|
|
|
|
vidaAuthTokenID: user!.vidaAuthTokenID,
|
|
|
|
|
vidaRefreshTokenID: user!.vidaRefreshTokenID);
|
|
|
|
|
await _authService.sendActivationCodeVerificationScreen(activationCodeModel);
|
|
|
|
|
ActivationCodeForVerificationScreenModel activationCodeModel =
|
|
|
|
|
ActivationCodeForVerificationScreenModel(
|
|
|
|
|
iMEI: user!.iMEI,
|
|
|
|
|
facilityId: user!.projectID,
|
|
|
|
|
memberID: user!.doctorID,
|
|
|
|
|
loginDoctorID: int.parse(user!.editedBy.toString()),
|
|
|
|
|
zipCode: user!.outSA == true ? '971' : '966',
|
|
|
|
|
mobileNumber: user!.mobile,
|
|
|
|
|
oTPSendType: authMethodType.getTypeIdService(),
|
|
|
|
|
isMobileFingerPrint: 1,
|
|
|
|
|
vidaAuthTokenID: user!.vidaAuthTokenID,
|
|
|
|
|
vidaRefreshTokenID: user!.vidaRefreshTokenID);
|
|
|
|
|
await _authService
|
|
|
|
|
.sendActivationCodeVerificationScreen(activationCodeModel);
|
|
|
|
|
if (_authService.hasError) {
|
|
|
|
|
error = _authService.error!;
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
@ -149,56 +165,73 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// send activation code for silent login
|
|
|
|
|
Future sendActivationCodeForDoctorApp({required AuthMethodTypes authMethodType, required String password}) async {
|
|
|
|
|
Future sendActivationCodeForDoctorApp(
|
|
|
|
|
{required AuthMethodTypes authMethodType,
|
|
|
|
|
required String password}) async {
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
int projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
ActivationCodeModel activationCodeModel = ActivationCodeModel(
|
|
|
|
|
facilityId: projectID,
|
|
|
|
|
memberID: loggedUser!.listMemberInformation![0].memberID,
|
|
|
|
|
loginDoctorID: loggedUser!.listMemberInformation![0].employeeID,
|
|
|
|
|
otpSendType: authMethodType.getTypeIdService().toString(),
|
|
|
|
|
);
|
|
|
|
|
facilityId: projectID,
|
|
|
|
|
memberID: loggedUser!.listMemberInformation![0].memberID,
|
|
|
|
|
loginDoctorID: loggedUser!.listMemberInformation![0].employeeID,
|
|
|
|
|
otpSendType: authMethodType.getTypeIdService().toString(),
|
|
|
|
|
);
|
|
|
|
|
await _authService.sendActivationCodeForDoctorApp(activationCodeModel);
|
|
|
|
|
if (_authService.hasError) {
|
|
|
|
|
error = _authService.error!;
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
} else {
|
|
|
|
|
await sharedPref.setString(TOKEN,
|
|
|
|
|
_authService.activationCodeForDoctorAppRes.logInTokenID!);
|
|
|
|
|
await sharedPref.setString(
|
|
|
|
|
TOKEN, _authService.activationCodeForDoctorAppRes.logInTokenID!);
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// check activation code for sms and whats app
|
|
|
|
|
Future checkActivationCodeForDoctorApp({required String activationCode,bool isSilentLogin = false}) async {
|
|
|
|
|
Future checkActivationCodeForDoctorApp(
|
|
|
|
|
{required String activationCode, bool isSilentLogin = false}) async {
|
|
|
|
|
setState(ViewState.BusyLocal);
|
|
|
|
|
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = new CheckActivationCodeRequestModel(
|
|
|
|
|
zipCode: loggedUser != null ? loggedUser!.zipCode : user!.zipCode,
|
|
|
|
|
mobileNumber: loggedUser != null ? loggedUser!.mobileNumber : user!.mobile,
|
|
|
|
|
projectID: await sharedPref.getInt(PROJECT_ID) != null ? await sharedPref.getInt(PROJECT_ID) : user!.projectID,
|
|
|
|
|
logInTokenID: await sharedPref.getString(TOKEN),
|
|
|
|
|
activationCode: activationCode,
|
|
|
|
|
memberID:userInfo.userID!=null? int.parse(userInfo!.userID!):user!.doctorID ,
|
|
|
|
|
password: userInfo.password,
|
|
|
|
|
facilityId:userInfo.projectID!=null? userInfo.projectID.toString():user!.projectID.toString(),
|
|
|
|
|
oTPSendType: await sharedPref.getInt(OTP_TYPE),
|
|
|
|
|
iMEI: localToken,
|
|
|
|
|
loginDoctorID:userInfo.userID!=null? int.parse(userInfo!.userID!):user!.editedBy,// loggedUser.listMemberInformation[0].employeeID,
|
|
|
|
|
isForSilentLogin:isSilentLogin,
|
|
|
|
|
generalid: "Cs2020@2016\$2958");
|
|
|
|
|
await _authService.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp);
|
|
|
|
|
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp =
|
|
|
|
|
new CheckActivationCodeRequestModel(
|
|
|
|
|
zipCode: loggedUser != null ? loggedUser!.zipCode : user!.zipCode,
|
|
|
|
|
mobileNumber:
|
|
|
|
|
loggedUser != null ? loggedUser!.mobileNumber : user!.mobile,
|
|
|
|
|
projectID: await sharedPref.getInt(PROJECT_ID) != null
|
|
|
|
|
? await sharedPref.getInt(PROJECT_ID)
|
|
|
|
|
: user!.projectID,
|
|
|
|
|
logInTokenID: await sharedPref.getString(TOKEN),
|
|
|
|
|
activationCode: activationCode,
|
|
|
|
|
memberID: userInfo.userID != null
|
|
|
|
|
? int.parse(userInfo!.userID!)
|
|
|
|
|
: user!.doctorID,
|
|
|
|
|
password: userInfo.password,
|
|
|
|
|
facilityId: userInfo.projectID != null
|
|
|
|
|
? userInfo.projectID.toString()
|
|
|
|
|
: user!.projectID.toString(),
|
|
|
|
|
oTPSendType: await sharedPref.getInt(OTP_TYPE),
|
|
|
|
|
iMEI: localToken,
|
|
|
|
|
loginDoctorID: userInfo.userID != null
|
|
|
|
|
? int.parse(userInfo!.userID!)
|
|
|
|
|
: user!
|
|
|
|
|
.editedBy, // loggedUser.listMemberInformation[0].employeeID,
|
|
|
|
|
isForSilentLogin: isSilentLogin,
|
|
|
|
|
generalid: "Cs2020@2016\$2958");
|
|
|
|
|
await _authService
|
|
|
|
|
.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp);
|
|
|
|
|
if (_authService.hasError) {
|
|
|
|
|
error = _authService.error!;
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
} else {
|
|
|
|
|
await setDataAfterSendActivationSuccess(checkActivationCodeForDoctorAppRes);
|
|
|
|
|
await setDataAfterSendActivationSuccess(
|
|
|
|
|
checkActivationCodeForDoctorAppRes);
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// get list of Hospitals
|
|
|
|
|
Future getHospitalsList(memberID) async {
|
|
|
|
|
GetHospitalsRequestModel getHospitalsRequestModel = GetHospitalsRequestModel();
|
|
|
|
|
GetHospitalsRequestModel getHospitalsRequestModel =
|
|
|
|
|
GetHospitalsRequestModel();
|
|
|
|
|
getHospitalsRequestModel.memberID = memberID;
|
|
|
|
|
await _hospitalsService.getHospitals(getHospitalsRequestModel);
|
|
|
|
|
if (_hospitalsService.hasError) {
|
|
|
|
|
@ -230,13 +263,15 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// add token to shared preferences in case of send activation code is success
|
|
|
|
|
setDataAfterSendActivationSuccess(CheckActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel)async {
|
|
|
|
|
// print("VerificationCode : " + sendActivationCodeForDoctorAppResponseModel.verificationCode);
|
|
|
|
|
await sharedPref.setString(VIDA_AUTH_TOKEN_ID,
|
|
|
|
|
sendActivationCodeForDoctorAppResponseModel.vidaAuthTokenID);
|
|
|
|
|
await sharedPref.setString(VIDA_REFRESH_TOKEN_ID,
|
|
|
|
|
sendActivationCodeForDoctorAppResponseModel.vidaRefreshTokenID);
|
|
|
|
|
await sharedPref.setString(TOKEN,
|
|
|
|
|
setDataAfterSendActivationSuccess(
|
|
|
|
|
CheckActivationCodeForDoctorAppResponseModel
|
|
|
|
|
sendActivationCodeForDoctorAppResponseModel) async {
|
|
|
|
|
// print("VerificationCode : " + sendActivationCodeForDoctorAppResponseModel.verificationCode);
|
|
|
|
|
await sharedPref.setString(VIDA_AUTH_TOKEN_ID,
|
|
|
|
|
sendActivationCodeForDoctorAppResponseModel.vidaAuthTokenID!);
|
|
|
|
|
await sharedPref.setString(VIDA_REFRESH_TOKEN_ID,
|
|
|
|
|
sendActivationCodeForDoctorAppResponseModel.vidaRefreshTokenID!);
|
|
|
|
|
await sharedPref.setString(TOKEN,
|
|
|
|
|
sendActivationCodeForDoctorAppResponseModel.authenticationTokenID!);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -275,7 +310,9 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
clinicID: clinicInfo.clinicID,
|
|
|
|
|
license: true,
|
|
|
|
|
projectID: clinicInfo.projectID,
|
|
|
|
|
languageID: 2);///TODO change the lan
|
|
|
|
|
languageID: 2);
|
|
|
|
|
|
|
|
|
|
///TODO change the lan
|
|
|
|
|
await _authService.getDoctorProfileBasedOnClinic(docInfo);
|
|
|
|
|
if (_authService.hasError) {
|
|
|
|
|
error = _authService.error!;
|
|
|
|
|
@ -288,13 +325,17 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
|
|
|
|
|
/// add some logic in case of check activation code is success
|
|
|
|
|
onCheckActivationCodeSuccess({bool isSilentLogin = false}) async {
|
|
|
|
|
sharedPref.setString(TOKEN, checkActivationCodeForDoctorAppRes.authenticationTokenID!);
|
|
|
|
|
sharedPref.setString(
|
|
|
|
|
TOKEN, checkActivationCodeForDoctorAppRes.authenticationTokenID!);
|
|
|
|
|
if (checkActivationCodeForDoctorAppRes.listDoctorProfile != null &&
|
|
|
|
|
checkActivationCodeForDoctorAppRes.listDoctorProfile!.isNotEmpty) {
|
|
|
|
|
localSetDoctorProfile(checkActivationCodeForDoctorAppRes.listDoctorProfile![0]);
|
|
|
|
|
localSetDoctorProfile(
|
|
|
|
|
checkActivationCodeForDoctorAppRes.listDoctorProfile![0]);
|
|
|
|
|
} else {
|
|
|
|
|
sharedPref.setObj(CLINIC_NAME, checkActivationCodeForDoctorAppRes.listDoctorsClinic);
|
|
|
|
|
ClinicModel clinic = ClinicModel.fromJson(checkActivationCodeForDoctorAppRes.listDoctorsClinic![0].toJson());
|
|
|
|
|
sharedPref.setObj(
|
|
|
|
|
CLINIC_NAME, checkActivationCodeForDoctorAppRes.listDoctorsClinic);
|
|
|
|
|
ClinicModel clinic = ClinicModel.fromJson(
|
|
|
|
|
checkActivationCodeForDoctorAppRes.listDoctorsClinic![0].toJson());
|
|
|
|
|
await getDoctorProfileBasedOnClinic(clinic);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -336,13 +377,13 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
setState(ViewState.ErrorLocal);
|
|
|
|
|
} else {
|
|
|
|
|
if (_authService.dashboardItemsList.length > 0) {
|
|
|
|
|
user =_authService.dashboardItemsList[0];
|
|
|
|
|
user = _authService.dashboardItemsList[0];
|
|
|
|
|
sharedPref.setObj(
|
|
|
|
|
LAST_LOGIN_USER, _authService.dashboardItemsList[0]);
|
|
|
|
|
await sharedPref.setString(VIDA_REFRESH_TOKEN_ID,
|
|
|
|
|
user!.vidaRefreshTokenID!);
|
|
|
|
|
await sharedPref.setString(VIDA_AUTH_TOKEN_ID,
|
|
|
|
|
user!.vidaAuthTokenID!);
|
|
|
|
|
await sharedPref.setString(
|
|
|
|
|
VIDA_REFRESH_TOKEN_ID, user!.vidaRefreshTokenID!);
|
|
|
|
|
await sharedPref.setString(
|
|
|
|
|
VIDA_AUTH_TOKEN_ID, user!.vidaAuthTokenID!);
|
|
|
|
|
this.unverified = true;
|
|
|
|
|
}
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
@ -352,7 +393,6 @@ class AuthenticationViewModel extends BaseViewModel {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// determine the status of the app
|
|
|
|
|
APP_STATUS get status {
|
|
|
|
|
if (state == ViewState.Busy) {
|
|
|
|
|
|