diff --git a/lib/core/model/patient_muse/PatientSearchRequestModel.dart b/lib/core/model/patient_muse/PatientSearchRequestModel.dart index dcb9b31c..8241f00d 100644 --- a/lib/core/model/patient_muse/PatientSearchRequestModel.dart +++ b/lib/core/model/patient_muse/PatientSearchRequestModel.dart @@ -14,6 +14,8 @@ class PatientSearchRequestModel { String identificationNo; int nursingStationID; int clinicID = 0; + int loginDoctorID; + PatientSearchRequestModel( {this.doctorID, @@ -30,7 +32,7 @@ class PatientSearchRequestModel { this.to = "0", this.clinicID, this.nursingStationID = 0, - this.projectID}); + this.projectID, this.loginDoctorID}); PatientSearchRequestModel.fromJson(Map json) { doctorID = json['DoctorID']; @@ -48,6 +50,7 @@ class PatientSearchRequestModel { nursingStationID = json['NursingStationID']; clinicID = json['ClinicID']; projectID = json['ProjectID']; + loginDoctorID = json['LoginDoctorID']; } Map toJson() { @@ -67,6 +70,7 @@ class PatientSearchRequestModel { data['NursingStationID'] = this.nursingStationID; data['ClinicID'] = this.clinicID; data['ProjectID'] = this.projectID; + data['LoginDoctorID'] = this.loginDoctorID; return data; } } diff --git a/lib/core/service/home/scan_qr_service.dart b/lib/core/service/home/scan_qr_service.dart index 64c02869..c00abd97 100644 --- a/lib/core/service/home/scan_qr_service.dart +++ b/lib/core/service/home/scan_qr_service.dart @@ -11,8 +11,8 @@ class ScanQrService extends BaseService { PatientSearchRequestModel requestModel, bool isMyInpatient) async { hasError = false; await getDoctorProfile(); + requestModel.loginDoctorID = doctorProfile.doctorID; requestModel.doctorID = 0; - await baseAppClient.post( GET_PATIENT_IN_PATIENT_LIST, onSuccess: (dynamic response, int statusCode) { diff --git a/lib/core/service/patient/patientInPatientService.dart b/lib/core/service/patient/patientInPatientService.dart index 86e7d236..9aabbdee 100644 --- a/lib/core/service/patient/patientInPatientService.dart +++ b/lib/core/service/patient/patientInPatientService.dart @@ -11,7 +11,7 @@ class PatientInPatientService extends BaseService { PatientSearchRequestModel requestModel, bool isMyInpatient) async { hasError = false; await getDoctorProfile(isGetProfile: true); - + requestModel.loginDoctorID = doctorProfile.doctorID; if (isMyInpatient) { requestModel.doctorID = doctorProfile.doctorID; } else { diff --git a/lib/core/service/patient/patient_service.dart b/lib/core/service/patient/patient_service.dart index 7db9fd1b..a8eab765 100644 --- a/lib/core/service/patient/patient_service.dart +++ b/lib/core/service/patient/patient_service.dart @@ -168,8 +168,9 @@ class PatientService extends BaseService { Future getInPatient( PatientSearchRequestModel requestModel, bool isMyInpatient) async { hasError = false; - await getDoctorProfile(); + await getDoctorProfile(); + requestModel.loginDoctorID = doctorProfile.doctorID; if (isMyInpatient) { requestModel.doctorID = doctorProfile.doctorID; } else { diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 0c63c11c..72eb876a 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -70,6 +70,7 @@ class PatientSearchViewModel extends BaseViewModel { setState(ViewState.Busy); } await getDoctorProfile(isGetProfile: true); + patientSearchRequestModel.loginDoctorID = doctorProfile.doctorID; patientSearchRequestModel.doctorID = doctorProfile.doctorID; await _outPatientService.getOutPatient(patientSearchRequestModel); if (_outPatientService.hasError) { diff --git a/lib/core/viewModel/authentication_view_model.dart b/lib/core/viewModel/authentication_view_model.dart index da166bd6..5d4b4479 100644 --- a/lib/core/viewModel/authentication_view_model.dart +++ b/lib/core/viewModel/authentication_view_model.dart @@ -112,7 +112,8 @@ class AuthenticationViewModel extends BaseViewModel { insertIMEIDetailsModel.vidaRefreshTokenID = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); insertIMEIDetailsModel.password = userInfo.password; - insertIMEIDetailsModel.loginDoctorID = loggedUser.listMemberInformation[0].employeeID; + insertIMEIDetailsModel.loginDoctorID = loggedUser != null ? loggedUser.listMemberInformation[0].employeeID + : int.parse(user.editedBy); await _authService.insertDeviceImei(insertIMEIDetailsModel); if (_authService.hasError) { @@ -148,14 +149,15 @@ class AuthenticationViewModel extends BaseViewModel { iMEI: user.iMEI, facilityId: user.projectID, memberID: user.doctorID, - //TODO Elham* return it dynamic - loginDoctorID: 4709,//int.parse(user.editedBy.toString()), + 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); if (_authService.hasError) { @@ -213,7 +215,7 @@ class AuthenticationViewModel extends BaseViewModel { oTPSendType: await sharedPref.getInt(OTP_TYPE), iMEI: localToken, loginDoctorID: loggedUser != null ? loggedUser.listMemberInformation[0].employeeID - : int.parse(user.editedBy),///loggedUser.listMemberInformation[0].employeeID, + : int.parse(user.editedBy.toString()),///loggedUser.listMemberInformation[0].employeeID, // loggedUser.listMemberInformation[0].employeeID, isForSilentLogin: isSilentLogin, generalid: "Cs2020@2016\$2958"); diff --git a/lib/core/viewModel/dashboard_view_model.dart b/lib/core/viewModel/dashboard_view_model.dart index 82de3ca3..0343eaa4 100644 --- a/lib/core/viewModel/dashboard_view_model.dart +++ b/lib/core/viewModel/dashboard_view_model.dart @@ -59,8 +59,7 @@ class DashboardViewModel extends BaseViewModel { _firebaseMessaging.getToken().then((String token) async { if (token != '') { // DEVICE_TOKEN = token; - ///TODO Elham* return back - // authProvider.insertDeviceImei(token); + authProvider.insertDeviceImei(token); } }); } diff --git a/lib/screens/qr_reader/QR_reader_screen.dart b/lib/screens/qr_reader/QR_reader_screen.dart index e5443b04..d1fc601a 100644 --- a/lib/screens/qr_reader/QR_reader_screen.dart +++ b/lib/screens/qr_reader/QR_reader_screen.dart @@ -1,6 +1,8 @@ import 'package:barcode_scan2/barcode_scan2.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/view_state.dart'; +import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart'; import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; import 'package:doctor_app_flutter/core/viewModel/scan_qr_view_model.dart'; @@ -86,7 +88,8 @@ class _QrReaderScreenState extends State { _scanQrAndGetPatient(BuildContext context, ScanQrViewModel model) async { var result = (await BarcodeScanner.scan()).rawContent; if (result != "") { - List listOfParams = result.split(','); + DoctorProfileModel doctorProfile =await getDoctorProfile(isGetProfile: true); + List listOfParams = result.split(','); int patientID = 0; if (listOfParams[1].length != 0) patientID = int.parse(listOfParams[1]); PatientSearchRequestModel patientSearchRequestModel = @@ -96,6 +99,8 @@ class _QrReaderScreenState extends State { doctorID: 0, projectID: int.parse(listOfParams[0])); + patientSearchRequestModel.loginDoctorID = doctorProfile.doctorID; + await model .getInPatientList(patientSearchRequestModel, isMyInpatient: false) .then((d) { @@ -115,4 +120,31 @@ class _QrReaderScreenState extends State { }); } } + + Future getDoctorProfile( + {bool isGetProfile = false}) async { + + DoctorProfileModel doctorProfile; + if (isGetProfile) { + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + if (profile != null) { + doctorProfile = DoctorProfileModel.fromJson(profile); + if (doctorProfile != null) { + return doctorProfile; + } + } + } + if (doctorProfile == null) { + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + if (profile != null) { + doctorProfile = DoctorProfileModel.fromJson(profile); + if (doctorProfile != null) { + return doctorProfile; + } + } + return null; + } else { + return doctorProfile; + } + } }