Merge remote-tracking branch 'origin/dev_sultan' into dev_aamir

# Conflicts:
#	lib/features/authentication/authentication_repo.dart
#	lib/features/authentication/authentication_view_model.dart
#	lib/features/medical_file/medical_file_view_model.dart
pull/76/head
aamir-csol 1 month ago
commit 36193d349c

@ -37,6 +37,8 @@ class AppState {
AuthenticatedUser? _authenticatedRootUser; AuthenticatedUser? _authenticatedRootUser;
AuthenticatedUser? _authenticatedChildUser; AuthenticatedUser? _authenticatedChildUser;
int? _superUserID;
void setAuthenticatedUser(AuthenticatedUser authenticatedUser, {bool isFamily = false}) { void setAuthenticatedUser(AuthenticatedUser authenticatedUser, {bool isFamily = false}) {
if (isFamily) { if (isFamily) {
_authenticatedChildUser = authenticatedUser; _authenticatedChildUser = authenticatedUser;
@ -55,6 +57,10 @@ class AppState {
} }
} }
int? get superUserID => _superUserID;
set setSuperUserID(int? value) => _superUserID = value;
String _userBloodGroup = ""; String _userBloodGroup = "";
String get getUserBloodGroup => _userBloodGroup; String get getUserBloodGroup => _userBloodGroup;

@ -22,7 +22,16 @@ abstract class AuthenticationRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> sendActivationCodeRepo({required dynamic sendActivationCodeReq, String? languageID, bool isRegister = false, bool isFormFamilyFile = false}); Future<Either<Failure, GenericApiModel<dynamic>>> sendActivationCodeRepo({required dynamic sendActivationCodeReq, String? languageID, bool isRegister = false, bool isFormFamilyFile = false});
Future<Either<Failure, GenericApiModel<dynamic>>> checkActivationCodeRepo( Future<Either<Failure, GenericApiModel<dynamic>>> checkActivationCodeRepo(
{required dynamic newRequest, required String? activationCode, required bool isRegister, bool isFormFamilyFile = false, int? patientShareRequestID, int? responseID}); {required dynamic newRequest,
required String? activationCode,
required bool isRegister,
bool isFormFamilyFile = false,
int? patientShareRequestID,
int? responseID,
bool isSwitchUser = false,
int? patientID,
int? loginType
});
Future<Either<Failure, GenericApiModel<dynamic>>> checkIfUserAgreed({required dynamic commonAuthanticatedRequest}); Future<Either<Failure, GenericApiModel<dynamic>>> checkIfUserAgreed({required dynamic commonAuthanticatedRequest});
@ -187,13 +196,17 @@ class AuthenticationRepoImp implements AuthenticationRepo {
} }
@override @override
Future<Either<Failure, GenericApiModel<dynamic>>> checkActivationCodeRepo( Future<Either<Failure, GenericApiModel<dynamic>>> checkActivationCodeRepo({
{required dynamic newRequest, // could be CheckActivationCodeReq or CheckActivationCodeRegisterReq required dynamic newRequest, // could be CheckActivationCodeReq or CheckActivationCodeRegisterReq
required String? activationCode, required String? activationCode,
required bool isRegister, required bool isRegister,
bool isFormFamilyFile = false, bool isFormFamilyFile = false,
int? patientShareRequestID, int? patientShareRequestID,
int? responseID}) async { int? responseID,
bool isSwitchUser = false,
int? patientID,
int? loginType
}) async {
if (isRegister) { if (isRegister) {
newRequest["activationCode"] = activationCode ?? "0000"; newRequest["activationCode"] = activationCode ?? "0000";
newRequest["isSilentLogin"] = activationCode != null ? false : true; newRequest["isSilentLogin"] = activationCode != null ? false : true;
@ -215,18 +228,21 @@ class AuthenticationRepoImp implements AuthenticationRepo {
familyRequest["PatientID"] = appState.getAuthenticatedUser()!.patientId ?? 0; familyRequest["PatientID"] = appState.getAuthenticatedUser()!.patientId ?? 0;
familyRequest["LogInTokenID"] = appState.getFamilyFileTokenID; familyRequest["LogInTokenID"] = appState.getFamilyFileTokenID;
// // Remove unnecessary keys from familyRequest }
// familyRequest.remove("MobileNo"); Map<String, dynamic> switchRequest = {};
// familyRequest.remove("DeviceToken"); if (isSwitchUser) {
// familyRequest.remove("ProjectOutSA"); switchRequest = newRequest.toJson();
// familyRequest.remove("LoginType");
// familyRequest.remove("ZipCode"); switchRequest['PatientID'] = responseID;
// familyRequest.remove("isRegister"); switchRequest['IsSilentLogin'] = true;
// familyRequest.remove("SearchType"); switchRequest['LogInTokenID'] = null;
// familyRequest.remove("NationalID"); switchRequest['SearchType'] = 2;
// familyRequest.remove("IsSilentLogin"); if(loginType != 0) {
// familyRequest.remove("isDentalAllowedBackend"); switchRequest['SuperUser'] = patientID;
// familyRequest.remove("ForRegisteration"); switchRequest['DeviceToken'] = null;
}else{
switchRequest['LoginType'] = 2;
}
} }
@ -247,7 +263,9 @@ class AuthenticationRepoImp implements AuthenticationRepo {
? familyRequest ? familyRequest
: isRegister : isRegister
? newRequest ? newRequest
: newRequest.toJson(), : isSwitchUser
? switchRequest
: newRequest.toJson(),
onFailure: (error, statusCode, {messageStatus, failureType}) { onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType; failure = failureType;
}, },

@ -248,7 +248,7 @@ class AuthenticationViewModel extends ChangeNotifier {
await selectDeviceImei(onSuccess: (dynamic respData) async { await selectDeviceImei(onSuccess: (dynamic respData) async {
try { try {
if (respData != null) { if (respData != null) {
dynamic data = SelectDeviceByImeiRespModelElement.fromJson(respData.toJson()); dynamic data = await SelectDeviceByImeiRespModelElement.fromJson(respData.toJson());
_appState.setSelectDeviceByImeiRespModelElement(data); _appState.setSelectDeviceByImeiRespModelElement(data);
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
@ -443,7 +443,11 @@ class AuthenticationViewModel extends ChangeNotifier {
Function()? onResendActivation, Function()? onResendActivation,
bool isFormFamilyFile = false, bool isFormFamilyFile = false,
dynamic patientShareRequestID, dynamic patientShareRequestID,
dynamic responseID}) async { dynamic responseID,
bool isSwitchUser =false,
int? patientID,
}) async {
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1); bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1);
final request = RequestUtils.getCommonRequestWelcome( final request = RequestUtils.getCommonRequestWelcome(
@ -511,7 +515,11 @@ class AuthenticationViewModel extends ChangeNotifier {
isRegister: false, isRegister: false,
isFormFamilyFile: isFormFamilyFile, isFormFamilyFile: isFormFamilyFile,
patientShareRequestID: patientShareRequestID, patientShareRequestID: patientShareRequestID,
responseID: responseID); responseID: responseID,
isSwitchUser: isSwitchUser,
patientID: patientID,
loginType: _appState.superUserID != null ? 0 : 2,
);
resultEither.fold( resultEither.fold(
(failure) async => await _errorHandlerService.handleError( (failure) async => await _errorHandlerService.handleError(
@ -554,6 +562,9 @@ class AuthenticationViewModel extends ChangeNotifier {
// }); // });
} else { } else {
if (activation.list != null && activation.list!.isNotEmpty) { if (activation.list != null && activation.list!.isNotEmpty) {
if(isSwitchUser){
_appState.setSuperUserID = _appState.getAuthenticatedUser()?.patientId;
}
_appState.setAuthenticatedUser(activation.list!.first); _appState.setAuthenticatedUser(activation.list!.first);
_appState.setPrivilegeModelList(activation.list!.first.listPrivilege!); _appState.setPrivilegeModelList(activation.list!.first.listPrivilege!);
} }

@ -69,7 +69,7 @@ class AuthenticatedUser {
dynamic authenticatedUserPatientPayType; dynamic authenticatedUserPatientPayType;
dynamic authenticatedUserPatientType; dynamic authenticatedUserPatientType;
dynamic authenticatedUserStatus; dynamic authenticatedUserStatus;
int? superUser;
AuthenticatedUser({ AuthenticatedUser({
this.setupId, this.setupId,
this.patientType, this.patientType,
@ -139,6 +139,7 @@ class AuthenticatedUser {
this.authenticatedUserPatientPayType, this.authenticatedUserPatientPayType,
this.authenticatedUserPatientType, this.authenticatedUserPatientType,
this.authenticatedUserStatus, this.authenticatedUserStatus,
this.superUser
}); });
factory AuthenticatedUser.fromRawJson(String str) => AuthenticatedUser.fromJson(json.decode(str)); factory AuthenticatedUser.fromRawJson(String str) => AuthenticatedUser.fromJson(json.decode(str));
@ -214,6 +215,7 @@ class AuthenticatedUser {
authenticatedUserPatientPayType: json["patientPayType"], authenticatedUserPatientPayType: json["patientPayType"],
authenticatedUserPatientType: json["patientType"], authenticatedUserPatientType: json["patientType"],
authenticatedUserStatus: json["status"], authenticatedUserStatus: json["status"],
superUser: json["superUser"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
@ -285,6 +287,7 @@ class AuthenticatedUser {
"patientPayType": authenticatedUserPatientPayType, "patientPayType": authenticatedUserPatientPayType,
"patientType": authenticatedUserPatientType, "patientType": authenticatedUserPatientType,
"status": authenticatedUserStatus, "status": authenticatedUserStatus,
"superUser": superUser,
}; };
} }

@ -24,7 +24,7 @@ abstract class MedicalFileRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> getPatientMedicalReportPDF(PatientMedicalReportResponseModel patientMedicalReportResponseModel, AuthenticatedUser authenticatedUser); Future<Either<Failure, GenericApiModel<dynamic>>> getPatientMedicalReportPDF(PatientMedicalReportResponseModel patientMedicalReportResponseModel, AuthenticatedUser authenticatedUser);
Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getPatientFamilyFiles(); Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getPatientFamilyFiles(int status, int patientId);
Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getAllPendingRecordsByResponseId({required Map<String, dynamic> request}); Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getAllPendingRecordsByResponseId({required Map<String, dynamic> request});
@ -276,13 +276,13 @@ class MedicalFileRepoImp implements MedicalFileRepo {
} }
@override @override
Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getPatientFamilyFiles() async { Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getPatientFamilyFiles(int status, int patientID) async {
try { try {
GenericApiModel<List<FamilyFileResponseModelLists>>? apiResponse; GenericApiModel<List<FamilyFileResponseModelLists>>? apiResponse;
Failure? failure; Failure? failure;
await apiClient.post( await apiClient.post(
FAMILY_FILES, FAMILY_FILES,
body: {"Status": 3}, body: {"Status": status, "PatientID":patientID},
onFailure: (error, statusCode, {messageStatus, failureType}) { onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType; failure = failureType;
}, },

@ -46,7 +46,7 @@ class MedicalFileViewModel extends ChangeNotifier {
int selectedMedicalReportsTabIndex = 0; int selectedMedicalReportsTabIndex = 0;
static final DialogService _dialogService = getIt.get<DialogService>(); static final DialogService _dialogService = getIt.get<DialogService>();
AppState _appState = getIt<AppState>(); AppState _appState = getIt<AppState>();
AuthenticationViewModel authVM = getIt.get<AuthenticationViewModel>();
MedicalFileViewModel({required this.medicalFileRepo, required this.errorHandlerService}); MedicalFileViewModel({required this.medicalFileRepo, required this.errorHandlerService});
initMedicalFileProvider() { initMedicalFileProvider() {
@ -285,7 +285,8 @@ class MedicalFileViewModel extends ChangeNotifier {
} }
Future<void> switchFamilyFiles({Function(dynamic)? onSuccess, Function(String)? onError}) async { Future<void> switchFamilyFiles({Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await medicalFileRepo.getPatientFamilyFiles(); // final result = await medicalFileRepo.getPatientFamilyFiles();
final result = await medicalFileRepo.getPatientFamilyFiles(3,_appState.superUserID !=null ? _appState.superUserID! : _appState.getAuthenticatedUser()!.patientId!);
result.fold( result.fold(
(failure) async => await errorHandlerService.handleError( (failure) async => await errorHandlerService.handleError(
@ -306,6 +307,8 @@ class MedicalFileViewModel extends ChangeNotifier {
patientName: '${_appState.getAuthenticatedUser()!.firstName!} ${_appState.getAuthenticatedUser()!.lastName!}', patientName: '${_appState.getAuthenticatedUser()!.firstName!} ${_appState.getAuthenticatedUser()!.lastName!}',
isActive: true, isActive: true,
gender: _appState.getAuthenticatedUser()!.gender!, gender: _appState.getAuthenticatedUser()!.gender!,
age: _appState.getAuthenticatedUser()!.age,
mobileNumber: _appState.getAuthenticatedUser()!.mobileNumber,
responseId: _appState.getAuthenticatedUser()!.patientId), responseId: _appState.getAuthenticatedUser()!.patientId),
); );
notifyListeners(); notifyListeners();
@ -317,7 +320,19 @@ class MedicalFileViewModel extends ChangeNotifier {
); );
} }
Future<void> switchFamilyFiles( {Function(dynamic)? onSuccess,int? responseID,int? patientID, String? phoneNumber, Function(String)? onError}) async {
authVM.phoneNumberController.text =phoneNumber!.startsWith("0")
? phoneNumber.replaceFirst("0", "")
: phoneNumber;
await authVM.checkActivationCode(activationCode: '0000', otpTypeEnum: OTPTypeEnum.sms, onWrongActivationCode: (String? str) {}, responseID: responseID, isFormFamilyFile:false, isSwitchUser: true, patientID: patientID, );
}
Future<void> addFamilyFile({required OTPTypeEnum otpTypeEnum, required bool isExcludedUser}) async { Future<void> addFamilyFile({required OTPTypeEnum otpTypeEnum, required bool isExcludedUser}) async {
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader();
AuthenticationViewModel authVM = getIt.get<AuthenticationViewModel>(); AuthenticationViewModel authVM = getIt.get<AuthenticationViewModel>();
NavigationService navigationService = getIt.get<NavigationService>(); NavigationService navigationService = getIt.get<NavigationService>();

@ -70,7 +70,10 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
onTabChange: (int index) {}, onTabChange: (int index) {},
), ),
SizedBox(height: 25.h), SizedBox(height: 25.h),
FamilyCards(profiles: widget.profiles, onSelect: widget.onSelect, isShowDetails: true), FamilyCards(profiles: widget.profiles, onSelect: (FamilyFileResponseModelLists profile){
medicalVM?.switchFamilyFiles(responseID: profile.responseId, patientID: profile.patientId, phoneNumber: profile.mobileNumber);
}, isShowDetails: true),
SizedBox(height: 20.h), SizedBox(height: 20.h),
], ],
), ),

Loading…
Cancel
Save