From 92c665197d35f586524be83dbf02410a1c3af94d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 24 May 2023 10:04:40 +0300 Subject: [PATCH] SetupID made dynamic --- lib/client/base_app_client.dart | 103 +++------ lib/config/shared_pref_kay.dart | 1 + ...on_code_for_doctor_app_response_model.dart | 2 +- lib/core/model/doctor/clinic_model.dart | 2 +- .../viewModel/authentication_view_model.dart | 206 +++++++----------- .../patient_sick_leave_screen.dart | 152 ++++--------- .../out_patient/out_patient_screen.dart | 77 +++---- 7 files changed, 175 insertions(+), 368 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 0218507f..d7619066 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -5,10 +5,10 @@ import 'dart:io' show Platform; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/core/service/NavigationService.dart'; -import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/service/NavigationService.dart'; +import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; import 'package:doctor_app_flutter/utils/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:flutter/cupertino.dart'; @@ -47,14 +47,12 @@ class BaseAppClient { body['DoctorID'] = doctorProfile?.doctorID; } if (body['DoctorID'] == "") body['DoctorID'] = null; - if (body['EditedBy'] == null) - body['EditedBy'] = doctorProfile?.doctorID; + if (body['EditedBy'] == null) body['EditedBy'] = doctorProfile?.doctorID; if (body['ProjectID'] == null) { body['ProjectID'] = doctorProfile?.projectID; } - if (body['ClinicID'] == null) - body['ClinicID'] = doctorProfile?.clinicID; + if (body['ClinicID'] == null) body['ClinicID'] = doctorProfile?.clinicID; } else { String doctorID = await sharedPref.getString(DOCTOR_ID); if (body['DoctorID'] == '') { @@ -88,21 +86,16 @@ class BaseAppClient { body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['PatientOutSA'] = body['PatientOutSA'] ?? 0; // PATIENT_OUT_SA; if (body['VidaAuthTokenID'] == null) { - body['VidaAuthTokenID'] = - await sharedPref.getString(VIDA_AUTH_TOKEN_ID); + body['VidaAuthTokenID'] = await sharedPref.getString(VIDA_AUTH_TOKEN_ID); } if (body['VidaRefreshTokenID'] == null) { - body['VidaRefreshTokenID'] = - await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); + body['VidaRefreshTokenID'] = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); } int projectID = await sharedPref.getInt(PROJECT_ID); if (projectID == 2 || projectID == 3) body['PatientOutSA'] = true; - else if ((body.containsKey('facilityId') && body['facilityId'] == 2 || - body['facilityId'] == 3) || - body['ProjectID'] == 2 || - body['ProjectID'] == 3) + else if ((body.containsKey('facilityId') && body['facilityId'] == 2 || body['facilityId'] == 3) || body['ProjectID'] == 2 || body['ProjectID'] == 3) body['PatientOutSA'] = true; else body['PatientOutSA'] = false; @@ -113,29 +106,21 @@ class BaseAppClient { var asd = json.encode(body); var asd2; if (await Utils.checkConnection()) { - final response = await http.post(Uri.parse(url), - body: json.encode(body), - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - }); + final response = await http.post(Uri.parse(url), body: json.encode(body), headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode >= 400) { onFailure(Utils.generateContactAdminMsg(), statusCode); } else { var parsed = json.decode(response.body.toString()); if (parsed['ErrorType'] == 4) { - helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], - parsed['AndroidLink'], parsed['IOSLink']); + helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], parsed['AndroidLink'], parsed['IOSLink']); } if (parsed['IsAuthenticated'] != null && !parsed['IsAuthenticated']) { if (body['OTP_SendType'] != null) { onFailure(getError(parsed), statusCode); } else if (!isAllowAny) { - await Provider.of(AppGlobal.CONTEX, - listen: false) - .logout(); + await Provider.of(AppGlobal.CONTEX, listen: false).logout(); Utils.showErrorToast('Your session expired Please login again'); locator().pushNamedAndRemoveUntil(ROOT); @@ -170,10 +155,7 @@ class BaseAppClient { String url = BASE_URL + endPoint; try { - Map headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - }; + Map headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}; String token = await sharedPref.getString(TOKEN); Map profile = await sharedPref.getObj(DOCTOR_PROFILE); @@ -184,13 +166,12 @@ class BaseAppClient { body['DoctorID'] = doctorProfile?.doctorID; } } - var languageID = - await sharedPref.getStringWithDefaultValue(APP_Language, 'en'); + var languageID = await sharedPref.getStringWithDefaultValue(APP_Language, 'en'); body['SetupID'] = body.containsKey('SetupID') ? body['SetupID'] != null ? body['SetupID'] - : SETUP_ID - : SETUP_ID; + : await sharedPref.getString(DOCTOR_SETUP_ID) + : await sharedPref.getString(DOCTOR_SETUP_ID); body['VersionID'] = VERSION_ID; body['Channel'] = CHANNEL; @@ -205,12 +186,11 @@ class BaseAppClient { : PATIENT_OUT_SA_PATIENT_REQ; if (body.containsKey('isDentalAllowedBackend')) { - body['isDentalAllowedBackend'] = - body.containsKey('isDentalAllowedBackend') - ? body['isDentalAllowedBackend'] != null - ? body['isDentalAllowedBackend'] - : IS_DENTAL_ALLOWED_BACKEND - : IS_DENTAL_ALLOWED_BACKEND; + body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') + ? body['isDentalAllowedBackend'] != null + ? body['isDentalAllowedBackend'] + : IS_DENTAL_ALLOWED_BACKEND + : IS_DENTAL_ALLOWED_BACKEND; } body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; @@ -231,10 +211,8 @@ class BaseAppClient { : PATIENT_TYPE_ID : PATIENT_TYPE_ID; - body['TokenID'] = body.containsKey('TokenID') ? body['TokenID']??token : token; - body['PatientID'] = body['PatientID'] != null - ? body['PatientID'] - : patient.patientId ?? patient.patientMRN; + body['TokenID'] = body.containsKey('TokenID') ? body['TokenID'] ?? token : token; + body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : patient.patientId ?? patient.patientMRN; body['PatientOutSA'] = 0; //user['OutSA']; //TODO change it body['SessionID'] = SESSION_ID; //getSe @@ -250,8 +228,7 @@ class BaseAppClient { var asd = json.encode(body); var asd2; 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; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { @@ -263,8 +240,7 @@ class BaseAppClient { onSuccess(parsed, statusCode); } else { if (parsed['ErrorType'] == 4) { - helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], - parsed['AndroidLink'], parsed['IOSLink']); + helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], parsed['AndroidLink'], parsed['IOSLink']); } if (parsed['IsAuthenticated'] == null) { if (parsed['isSMSSent'] == true) { @@ -280,28 +256,20 @@ class BaseAppClient { onFailure(getError(parsed), statusCode); } } - } else if (parsed['MessageStatus'] == 1 || - parsed['SMSLoginRequired'] == true) { + } else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) { onSuccess(parsed, statusCode); - } else if (parsed['MessageStatus'] == 2 && - parsed['IsAuthenticated']) { + } else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) { if (parsed['SameClinicApptList'] != null) { onSuccess(parsed, statusCode); } else { - if (parsed['message'] == null && - parsed['ErrorEndUserMessage'] == null) { + if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { if (parsed['ErrorSearchMsg'] == null) { - onFailure("Server Error found with no available message", - statusCode); + onFailure("Server Error found with no available message", statusCode); } else { onFailure(parsed['ErrorSearchMsg'], statusCode); } } else { - onFailure( - parsed['message'] ?? - parsed['ErrorEndUserMessage'] ?? - parsed['ErrorMessage'], - statusCode); + onFailure(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); } } } else { @@ -311,9 +279,7 @@ class BaseAppClient { if (parsed['message'] != null) { onFailure(parsed['message'] ?? parsed['message'], statusCode); } else { - onFailure( - parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], - statusCode); + onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); } } } @@ -334,14 +300,9 @@ class BaseAppClient { if (parsed["ValidationErrors"] != null) { error = parsed["ValidationErrors"]["StatusMessage"].toString() + "\n"; - if (parsed["ValidationErrors"]["ValidationErrors"] != null && - parsed["ValidationErrors"]["ValidationErrors"].length != 0) { - for (var i = 0; - i < parsed["ValidationErrors"]["ValidationErrors"].length; - i++) { - error = error + - parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] + - "\n"; + if (parsed["ValidationErrors"]["ValidationErrors"] != null && parsed["ValidationErrors"]["ValidationErrors"].length != 0) { + for (var i = 0; i < parsed["ValidationErrors"]["ValidationErrors"].length; i++) { + error = error + parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] + "\n"; } } } diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index 628f5a0e..a3656328 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -14,3 +14,4 @@ const DASHBOARD_DATA = 'dashboard-data'; const OTP_TYPE = 'otp-type'; const LAST_LOGIN_USER = 'last-login-user'; const CLINIC_NAME = 'clinic-name'; +const DOCTOR_SETUP_ID = 'doctor-setup-id'; diff --git a/lib/core/model/auth/check_activation_code_for_doctor_app_response_model.dart b/lib/core/model/auth/check_activation_code_for_doctor_app_response_model.dart index 6fb7eb70..1bb10d1f 100644 --- a/lib/core/model/auth/check_activation_code_for_doctor_app_response_model.dart +++ b/lib/core/model/auth/check_activation_code_for_doctor_app_response_model.dart @@ -60,7 +60,7 @@ class CheckActivationCodeForDoctorAppResponseModel { } class ListDoctorsClinic { - Null setupID; + String setupID; int projectID; int doctorID; int clinicID; diff --git a/lib/core/model/doctor/clinic_model.dart b/lib/core/model/doctor/clinic_model.dart index e5eb8eee..4ea7636c 100644 --- a/lib/core/model/doctor/clinic_model.dart +++ b/lib/core/model/doctor/clinic_model.dart @@ -6,7 +6,7 @@ *@desc: Clinic Model */ class ClinicModel { - Null setupID; + String setupID; int projectID; int doctorID; int clinicID; diff --git a/lib/core/viewModel/authentication_view_model.dart b/lib/core/viewModel/authentication_view_model.dart index d17cb661..9c900eac 100644 --- a/lib/core/viewModel/authentication_view_model.dart +++ b/lib/core/viewModel/authentication_view_model.dart @@ -11,22 +11,23 @@ import 'package:doctor_app_flutter/core/model/auth/imei_details.dart'; import 'package:doctor_app_flutter/core/model/auth/insert_imei_model.dart'; import 'package:doctor_app_flutter/core/model/auth/new_login_information_response_model.dart'; import 'package:doctor_app_flutter/core/model/auth/send_activation_code_for_doctor_app_response_model.dart'; +import 'package:doctor_app_flutter/core/model/doctor/clinic_model.dart'; +import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/core/model/doctor/profile_req_Model.dart'; +import 'package:doctor_app_flutter/core/model/doctor/user_model.dart'; import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart'; import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_response_model.dart'; import 'package:doctor_app_flutter/core/service/authentication_service.dart'; import 'package:doctor_app_flutter/core/service/hospitals/hospitals_service.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; -import 'package:doctor_app_flutter/core/model/doctor/clinic_model.dart'; -import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/core/model/doctor/profile_req_Model.dart'; -import 'package:doctor_app_flutter/core/model/doctor/user_model.dart'; import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; -import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/services.dart'; import 'package:local_auth/auth_strings.dart'; + // import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; // import 'package:local_auth/auth_strings.dart'; import 'package:local_auth/local_auth.dart'; @@ -43,20 +44,13 @@ class AuthenticationViewModel extends BaseViewModel { NewLoginInformationModel get loginInfo => _authService.loginInfo; - List get doctorProfilesList => - _authService.doctorProfilesList; + List 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; @@ -91,32 +85,20 @@ 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; - insertIMEIDetailsModel.loginDoctorID = loggedUser != null ? loggedUser.listMemberInformation[0].employeeID - : int.parse(user.editedBy.toString()); + insertIMEIDetailsModel.loginDoctorID = loggedUser != null ? loggedUser.listMemberInformation[0].employeeID : int.parse(user.editedBy.toString()); await _authService.insertDeviceImei(insertIMEIDetailsModel); if (_authService.hasError) { @@ -144,25 +126,22 @@ 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); + 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 sharedPref.setString(DOCTOR_ID, user.editedBy.toString()); - await _authService - .sendActivationCodeVerificationScreen(activationCodeModel); + await _authService.sendActivationCodeVerificationScreen(activationCodeModel); if (_authService.hasError) { error = _authService.error; setState(ViewState.ErrorLocal); @@ -171,8 +150,7 @@ class AuthenticationViewModel extends BaseViewModel { } /// send activation code for silent login - Future sendActivationCodeForDoctorApp( - {AuthMethodTypes authMethodType, String password}) async { + Future sendActivationCodeForDoctorApp({AuthMethodTypes authMethodType, String password}) async { setState(ViewState.BusyLocal); int projectID = await sharedPref.getInt(PROJECT_ID); ActivationCodeModel activationCodeModel = ActivationCodeModel( @@ -187,57 +165,45 @@ class AuthenticationViewModel extends BaseViewModel { 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( - {String activationCode, bool isSilentLogin = false}) async { + Future checkActivationCodeForDoctorApp({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 ?? '0000', - 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: loggedUser != null ? loggedUser.listMemberInformation[0].employeeID - : int.parse(user.editedBy.toString()),///loggedUser.listMemberInformation[0].employeeID, - // 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 ?? '0000', + 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: loggedUser != null ? loggedUser.listMemberInformation[0].employeeID : int.parse(user.editedBy.toString()), + + ///loggedUser.listMemberInformation[0].employeeID, + // 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; getHospitalsRequestModel.doctorID = memberID; await _hospitalsService.getHospitals(getHospitalsRequestModel); @@ -269,17 +235,13 @@ class AuthenticationViewModel extends BaseViewModel { } } - /// add  token to shared preferences in case of send activation code is success - setDataAfterSendActivationSuccess( - CheckActivationCodeForDoctorAppResponseModel - sendActivationCodeForDoctorAppResponseModel) async { + /// 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, - sendActivationCodeForDoctorAppResponseModel.authenticationTokenID); + await sharedPref.setString(DOCTOR_SETUP_ID, sendActivationCodeForDoctorAppResponseModel.listDoctorsClinic[0].setupID); + await sharedPref.setString(VIDA_AUTH_TOKEN_ID, sendActivationCodeForDoctorAppResponseModel.vidaAuthTokenID); + await sharedPref.setString(VIDA_REFRESH_TOKEN_ID, sendActivationCodeForDoctorAppResponseModel.vidaRefreshTokenID); + await sharedPref.setString(TOKEN, sendActivationCodeForDoctorAppResponseModel.authenticationTokenID); } saveObjToString(String key, value) async { @@ -288,18 +250,10 @@ class AuthenticationViewModel extends BaseViewModel { /// ask user to add his biometric showIOSAuthMessages() async { - const iosStrings = const IOSAuthMessages( - cancelButton: 'cancel', - goToSettingsButton: 'settings', - goToSettingsDescription: 'Please set up your Touch ID.', - lockOut: 'Please Enable Your Touch ID'); + const iosStrings = const IOSAuthMessages(cancelButton: 'cancel', goToSettingsButton: 'settings', goToSettingsDescription: 'Please set up your Touch ID.', lockOut: 'Please Enable Your Touch ID'); try { - await auth.authenticateWithBiometrics( - localizedReason: 'Scan your fingerprint to authenticate', - useErrorDialogs: true, - stickyAuth: true, - iOSAuthStrings: iosStrings); + await auth.authenticateWithBiometrics(localizedReason: 'Scan your fingerprint to authenticate', useErrorDialogs: true, stickyAuth: true, iOSAuthStrings: iosStrings); } on PlatformException catch (e) { DrAppToastMsg.showErrorToast(e.toString()); } @@ -312,12 +266,7 @@ class AuthenticationViewModel extends BaseViewModel { /// get doctor profile based on clinic model Future getDoctorProfileBasedOnClinic(ClinicModel clinicInfo) async { - ProfileReqModel docInfo = new ProfileReqModel( - doctorID: clinicInfo.doctorID, - clinicID: clinicInfo.clinicID, - license: true, - projectID: clinicInfo.projectID, - languageID: 2); + ProfileReqModel docInfo = new ProfileReqModel(doctorID: clinicInfo.doctorID, clinicID: clinicInfo.clinicID, license: true, projectID: clinicInfo.projectID, languageID: 2); ///TODO change the lan await _authService.getDoctorProfileBasedOnClinic(docInfo); @@ -332,17 +281,12 @@ 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); - if (checkActivationCodeForDoctorAppRes.listDoctorProfile != null && - checkActivationCodeForDoctorAppRes.listDoctorProfile.isNotEmpty) { - localSetDoctorProfile( - checkActivationCodeForDoctorAppRes.listDoctorProfile[0]); + sharedPref.setString(TOKEN, checkActivationCodeForDoctorAppRes.authenticationTokenID); + if (checkActivationCodeForDoctorAppRes.listDoctorProfile != null && checkActivationCodeForDoctorAppRes.listDoctorProfile.isNotEmpty) { + 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); } } @@ -387,7 +331,7 @@ class AuthenticationViewModel extends BaseViewModel { setState(ViewState.Busy); try { token = await _firebaseMessaging.getToken(); - } catch(ex) { + } catch (ex) { print(ex); } @@ -401,10 +345,8 @@ class AuthenticationViewModel extends BaseViewModel { } else { if (_authService.dashboardItemsList.length > 0) { user = _authService.dashboardItemsList[0]; - sharedPref.setObj( - LAST_LOGIN_USER, _authService.dashboardItemsList[0]); - await sharedPref.setString( - VIDA_REFRESH_TOKEN_ID, user.vidaRefreshTokenID); + 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); this.unverified = true; } diff --git a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart index 2c0a406c..0e5873df 100644 --- a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart @@ -1,16 +1,16 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_patient_model.dart'; import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; -import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patient-sick-leave/add_patient_sick_leave_screen.dart'; import 'package:doctor_app_flutter/utils/date-utils.dart'; -import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -64,18 +64,14 @@ class PatientSickLeaveScreen extends StatelessWidget { if (!projectsProvider.isArabic) AppText( TranslationBase.of(context).patient, - fontSize: - SizeConfig.getTextMultiplierBasedOnWidth() * - (SizeConfig.isWidthLarge ? 3 : 4), + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge ? 3 : 4), fontWeight: FontWeight.w700, letterSpacing: -0.72, color: Color(0xFF2E303A), ), AppText( TranslationBase.of(context).sickLeave, - fontSize: - SizeConfig.getTextMultiplierBasedOnWidth() * - (SizeConfig.isWidthLarge ? 6 : 6), + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge ? 6 : 6), fontWeight: FontWeight.bold, letterSpacing: -1.44, color: Color(0xFF2E303A), @@ -105,8 +101,7 @@ class PatientSickLeaveScreen extends StatelessWidget { shrinkWrap: true, itemCount: model.getAllSIckLeavePatient.length, itemBuilder: (BuildContext ctxt, int index) { - SickLeavePatientModel item = - model.getAllSIckLeavePatient[index]; + SickLeavePatientModel item = model.getAllSIckLeavePatient[index]; return Column( children: [ CardWithBgWidget( @@ -122,42 +117,31 @@ class PatientSickLeaveScreen extends StatelessWidget { child: Column( children: [ if (item.doctorName != null) - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - // width: MediaQuery.of(context).size.width*0.51, - child: AppText( - Utils.capitalize( - item.doctorName ?? ""), - fontSize: 18, - color: Color(0xff2e303a), - fontWeight: FontWeight.w700, - fontFamily: 'Poppins', - textOverflow: - TextOverflow.ellipsis, - ), - ), - ]), + Row(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ + Expanded( + // width: MediaQuery.of(context).size.width*0.51, + child: AppText( + Utils.capitalize(item.doctorName ?? ""), + fontSize: 18, + color: Color(0xff2e303a), + fontWeight: FontWeight.w700, + fontFamily: 'Poppins', + textOverflow: TextOverflow.ellipsis, + ), + ), + ]), SizedBox( height: 10, ), Row( children: [ ClipRRect( - borderRadius: - BorderRadius.circular(50.0), + borderRadius: BorderRadius.circular(50.0), child: CachedNetworkImage( - imageUrl: item.doctorImageURL ?? - "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", + imageUrl: item.doctorImageURL ?? "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", height: 30, width: 30, - errorWidget: - (context, url, error) => - AppText( + errorWidget: (context, url, error) => AppText( 'No Image', fontSize: 10, ), @@ -170,90 +154,36 @@ class PatientSickLeaveScreen extends StatelessWidget { child: Column( children: [ CustomRow( - label: TranslationBase.of( - context) - .daysSickleave, - labelSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.3, - valueSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 4, - value: (item.sickLeaveDays - .toString() != - null && - item.sickLeaveDays - .toString() != - "null") - ? item.sickLeaveDays - .toString() - : item.noOfDays - .toString(), + label: TranslationBase.of(context).daysSickleave, + labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, + valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, + value: + (item.sickLeaveDays.toString() != null && item.sickLeaveDays.toString() != "null") ? item.sickLeaveDays.toString() : item.noOfDays.toString(), ), CustomRow( - label: TranslationBase.of( - context) - .startDate + - ' ' ?? - "", - labelSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.3, - valueSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 4, - value: AppDateUtils - .getDayMonthYearDateFormatted( - item.startDate.contains( - "/Date(") - ? AppDateUtils - .convertStringToDate( - item - .startDate) - : DateTime.parse( - item.startDate), + label: TranslationBase.of(context).startDate + ' ' ?? "", + labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, + valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, + value: AppDateUtils.getDayMonthYearDateFormatted( + item.startDate.contains("/Date(") ? AppDateUtils.convertStringToDate(item.startDate) : DateTime.parse(item.startDate), ), ), CustomRow( - label: TranslationBase.of( - context) - .endDate + - ' ' ?? - "", - labelSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.3, - valueSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 4, - value: AppDateUtils - .getDayMonthYearDateFormatted( - item.startDate.contains( - "/Date(") - ? AppDateUtils - .convertStringToDate( - item.endDate ?? - "") - .add( - Duration( - days: item - .noOfDays ?? - item.sickLeaveDays), + label: TranslationBase.of(context).endDate + ' ' ?? "", + labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, + valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, + value: AppDateUtils.getDayMonthYearDateFormatted( + item.startDate.contains("/Date(") + ? AppDateUtils.convertStringToDate(item.endDate ?? "").add( + Duration(days: item.noOfDays ?? item.sickLeaveDays), ) - : DateTime.parse( - item.startDate ?? - "") - .add( - Duration( - days: - item.noOfDays ?? - ""), + : DateTime.parse(item.startDate ?? "").add( + Duration(days: item.noOfDays ?? ""), ), ), ), ], - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, ), ), ], diff --git a/lib/screens/patients/out_patient/out_patient_screen.dart b/lib/screens/patients/out_patient/out_patient_screen.dart index 733ba1a1..59d6298b 100644 --- a/lib/screens/patients/out_patient/out_patient_screen.dart +++ b/lib/screens/patients/out_patient/out_patient_screen.dart @@ -1,12 +1,12 @@ import 'package:doctor_app_flutter/core/enum/filter_type.dart'; import 'package:doctor_app_flutter/core/enum/patient_type.dart'; import 'package:doctor_app_flutter/core/enum/view_state.dart'; +import 'package:doctor_app_flutter/core/model/patient/patient_model.dart'; import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/core/model/patient/patient_model.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; @@ -20,6 +20,7 @@ import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_field_cus import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; + import 'filter_date_page.dart'; // ignore: must_be_immutable @@ -107,8 +108,7 @@ class _OutPatientsScreenState extends State { mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: _times.map((item) { - bool _isActive = - _times[_activeLocation] == item ? true : false; + bool _isActive = _times[_activeLocation] == item ? true : false; return Expanded( child: InkWell( @@ -128,8 +128,7 @@ class _OutPatientsScreenState extends State { await model.getPatientBasedOnDate( item: item, selectedPatientType: widget.selectedPatientType, - patientSearchRequestModel: - widget.patientSearchRequestModel, + patientSearchRequestModel: widget.patientSearchRequestModel, isSearchWithKeyInfo: widget.isSearchWithKeyInfo, outPatientFilterType: outPatientFilterType); GifLoaderDialogUtils.hideDialog(context); @@ -140,24 +139,15 @@ class _OutPatientsScreenState extends State { decoration: TabUtils.getBoxTabsBoxDecoration( isActive: _isActive, isFirst: _times.indexOf(item) == 0, - isLast: - _times.indexOf(item) == _times.length - 1, - isMiddle: _times.indexOf(item) != 0 && - _times.indexOf(item) != _times.length - 1, + isLast: _times.indexOf(item) == _times.length - 1, + isMiddle: _times.indexOf(item) != 0 && _times.indexOf(item) != _times.length - 1, projectViewModel: projectsProvider), child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - TabUtils.getTabText( - title: item, isActive: _isActive), - _isActive && - _activeLocation != 0 && - model.state == ViewState.Idle - ? TabUtils.getTabCounter( - isActive: _isActive, - counter: model.filterData.length) - : Container(), + TabUtils.getTabText(title: item, isActive: _isActive), + _isActive && _activeLocation != 0 && model.state == ViewState.Idle ? TabUtils.getTabCounter(isActive: _isActive, counter: model.filterData.length) : Container(), ], ), ), @@ -177,9 +167,7 @@ class _OutPatientsScreenState extends State { marginTop: 5, suffixIcon: IconButton( icon: Icon( - _activeLocation != 0 - ? DoctorApp.filter_1 - : FontAwesomeIcons.slidersH, + _activeLocation != 0 ? DoctorApp.filter_1 : FontAwesomeIcons.slidersH, color: Colors.black, ), iconSize: 20, @@ -189,21 +177,17 @@ class _OutPatientsScreenState extends State { Navigator.push( context, MaterialPageRoute( - builder: (BuildContext context) => - FilterDatePage( + builder: (BuildContext context) => FilterDatePage( outPatientFilterType: outPatientFilterType, patientSearchViewModel: model, ), - settings: RouteSettings( - name: 'FilterOutPatentDateScreen'), + settings: RouteSettings(name: 'FilterOutPatentDateScreen'), )); }, ), positionedChild: IconButton( icon: Icon( - isSortDes - ? FontAwesomeIcons.sortAmountDown - : FontAwesomeIcons.sortAmountUp, + isSortDes ? FontAwesomeIcons.sortAmountDown : FontAwesomeIcons.sortAmountUp, color: Colors.black, ), iconSize: 20, @@ -218,8 +202,7 @@ class _OutPatientsScreenState extends State { child: model.filterData.isEmpty ? Center( child: ErrorMessage( - error: TranslationBase.of(context) - .youDontHaveAnyPatient, + error: TranslationBase.of(context).youDontHaveAnyPatient, ), ) : ListView.builder( @@ -227,15 +210,9 @@ class _OutPatientsScreenState extends State { shrinkWrap: true, itemCount: model.filterData.length, itemBuilder: (BuildContext ctxt, int index) { - if (_activeLocation != 0 || - (model.filterData[index].patientStatusType != - null && - model.filterData[index] - .patientStatusType == - 43)) + if (_activeLocation != 0 || (model.filterData[index].patientStatusType != null && model.filterData[index].patientStatusType == 43)) return Padding( - padding: EdgeInsets.symmetric( - horizontal: 8, vertical: 0), + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 0), child: PatientCard( patientInfo: model.filterData[index], patientType: patientType, @@ -244,20 +221,16 @@ class _OutPatientsScreenState extends State { isInpatient: widget.isInpatient, onTap: () { // TODO change the parameter to daynamic - Navigator.of(context).pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": model.filterData[index], - "patientType": "1", - "from": widget - .patientSearchRequestModel.from, - "to": widget - .patientSearchRequestModel.from, - "isSearch": false, - "isInpatient": false, - "arrivalType": "7", - "isSearchAndOut": false, - }); + Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { + "patient": model.filterData[index], + "patientType": "1", + "from": widget.patientSearchRequestModel.from, + "to": widget.patientSearchRequestModel.from, + "isSearch": false, + "isInpatient": false, + "arrivalType": "7", + "isSearchAndOut": false, + }); }, // isFromSearch: widget.isSearch, ),