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? _authenticatedChildUser;
int? _superUserID;
void setAuthenticatedUser(AuthenticatedUser authenticatedUser, {bool isFamily = false}) {
if (isFamily) {
_authenticatedChildUser = authenticatedUser;
@ -55,6 +57,10 @@ class AppState {
}
}
int? get superUserID => _superUserID;
set setSuperUserID(int? value) => _superUserID = value;
String _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>>> 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});
@ -187,13 +196,17 @@ class AuthenticationRepoImp implements AuthenticationRepo {
}
@override
Future<Either<Failure, GenericApiModel<dynamic>>> checkActivationCodeRepo(
{required dynamic newRequest, // could be CheckActivationCodeReq or CheckActivationCodeRegisterReq
required String? activationCode,
required bool isRegister,
bool isFormFamilyFile = false,
int? patientShareRequestID,
int? responseID}) async {
Future<Either<Failure, GenericApiModel<dynamic>>> checkActivationCodeRepo({
required dynamic newRequest, // could be CheckActivationCodeReq or CheckActivationCodeRegisterReq
required String? activationCode,
required bool isRegister,
bool isFormFamilyFile = false,
int? patientShareRequestID,
int? responseID,
bool isSwitchUser = false,
int? patientID,
int? loginType
}) async {
if (isRegister) {
newRequest["activationCode"] = activationCode ?? "0000";
newRequest["isSilentLogin"] = activationCode != null ? false : true;
@ -215,18 +228,21 @@ class AuthenticationRepoImp implements AuthenticationRepo {
familyRequest["PatientID"] = appState.getAuthenticatedUser()!.patientId ?? 0;
familyRequest["LogInTokenID"] = appState.getFamilyFileTokenID;
// // Remove unnecessary keys from familyRequest
// familyRequest.remove("MobileNo");
// familyRequest.remove("DeviceToken");
// familyRequest.remove("ProjectOutSA");
// familyRequest.remove("LoginType");
// familyRequest.remove("ZipCode");
// familyRequest.remove("isRegister");
// familyRequest.remove("SearchType");
// familyRequest.remove("NationalID");
// familyRequest.remove("IsSilentLogin");
// familyRequest.remove("isDentalAllowedBackend");
// familyRequest.remove("ForRegisteration");
}
Map<String, dynamic> switchRequest = {};
if (isSwitchUser) {
switchRequest = newRequest.toJson();
switchRequest['PatientID'] = responseID;
switchRequest['IsSilentLogin'] = true;
switchRequest['LogInTokenID'] = null;
switchRequest['SearchType'] = 2;
if(loginType != 0) {
switchRequest['SuperUser'] = patientID;
switchRequest['DeviceToken'] = null;
}else{
switchRequest['LoginType'] = 2;
}
}
@ -247,7 +263,9 @@ class AuthenticationRepoImp implements AuthenticationRepo {
? familyRequest
: isRegister
? newRequest
: newRequest.toJson(),
: isSwitchUser
? switchRequest
: newRequest.toJson(),
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},

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

@ -69,7 +69,7 @@ class AuthenticatedUser {
dynamic authenticatedUserPatientPayType;
dynamic authenticatedUserPatientType;
dynamic authenticatedUserStatus;
int? superUser;
AuthenticatedUser({
this.setupId,
this.patientType,
@ -139,6 +139,7 @@ class AuthenticatedUser {
this.authenticatedUserPatientPayType,
this.authenticatedUserPatientType,
this.authenticatedUserStatus,
this.superUser
});
factory AuthenticatedUser.fromRawJson(String str) => AuthenticatedUser.fromJson(json.decode(str));
@ -214,6 +215,7 @@ class AuthenticatedUser {
authenticatedUserPatientPayType: json["patientPayType"],
authenticatedUserPatientType: json["patientType"],
authenticatedUserStatus: json["status"],
superUser: json["superUser"],
);
Map<String, dynamic> toJson() => {
@ -285,6 +287,7 @@ class AuthenticatedUser {
"patientPayType": authenticatedUserPatientPayType,
"patientType": authenticatedUserPatientType,
"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<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});
@ -276,13 +276,13 @@ class MedicalFileRepoImp implements MedicalFileRepo {
}
@override
Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getPatientFamilyFiles() async {
Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getPatientFamilyFiles(int status, int patientID) async {
try {
GenericApiModel<List<FamilyFileResponseModelLists>>? apiResponse;
Failure? failure;
await apiClient.post(
FAMILY_FILES,
body: {"Status": 3},
body: {"Status": status, "PatientID":patientID},
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},

@ -46,7 +46,7 @@ class MedicalFileViewModel extends ChangeNotifier {
int selectedMedicalReportsTabIndex = 0;
static final DialogService _dialogService = getIt.get<DialogService>();
AppState _appState = getIt<AppState>();
AuthenticationViewModel authVM = getIt.get<AuthenticationViewModel>();
MedicalFileViewModel({required this.medicalFileRepo, required this.errorHandlerService});
initMedicalFileProvider() {
@ -285,7 +285,8 @@ class MedicalFileViewModel extends ChangeNotifier {
}
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(
(failure) async => await errorHandlerService.handleError(
@ -306,6 +307,8 @@ class MedicalFileViewModel extends ChangeNotifier {
patientName: '${_appState.getAuthenticatedUser()!.firstName!} ${_appState.getAuthenticatedUser()!.lastName!}',
isActive: true,
gender: _appState.getAuthenticatedUser()!.gender!,
age: _appState.getAuthenticatedUser()!.age,
mobileNumber: _appState.getAuthenticatedUser()!.mobileNumber,
responseId: _appState.getAuthenticatedUser()!.patientId),
);
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 {
LoaderBottomSheet.showLoader();
AuthenticationViewModel authVM = getIt.get<AuthenticationViewModel>();
NavigationService navigationService = getIt.get<NavigationService>();

@ -70,7 +70,10 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
onTabChange: (int index) {},
),
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),
],
),

Loading…
Cancel
Save