diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index c3862e2..92a7e6c 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -170,6 +170,14 @@ class ApiClientImp implements ApiClient { } } + // request.versionID = VERSION_ID; + // request.channel = CHANNEL; + // request.iPAdress = IP_ADDRESS; + // request.generalid = GENERAL_ID; + // request.languageID = (languageID == 'ar' ? 1 : 2); + // request.patientOutSA = (request.zipCode == '966' || request.zipCode == '+966') ? 0 : 1; + + // TODO : we will use all these from appState body['LanguageID'] = body['LanguageID'] ?? "2"; body['VersionID'] = body['VersionID'] ?? "18.7"; body['Channel'] = body['Channel'] ?? "3"; @@ -192,7 +200,7 @@ class ApiClientImp implements ApiClient { final int statusCode = response.statusCode; if (statusCode < 200 || statusCode >= 400) { - onFailure('Error While Fetching data', statusCode, failureType: ServerFailure("Error While Fetching data")); + onFailure('Error While Fetching data', statusCode, failureType: StatusCodeFailure("Error While Fetching data")); logApiEndpointError(endPoint, 'Error While Fetching data', statusCode); } else { var parsed = json.decode(utf8.decode(response.bodyBytes)); diff --git a/lib/core/app_state.dart b/lib/core/app_state.dart index bdf8d25..7c42042 100644 --- a/lib/core/app_state.dart +++ b/lib/core/app_state.dart @@ -1,6 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:hmg_patient_app_new/core/post_params_model.dart'; -import 'package:hmg_patient_app_new/features/authentication/models/authenticated_user_model.dart'; +import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; import 'api_consts.dart' as ApiConsts; diff --git a/lib/core/dependencies.dart b/lib/core/dependencies.dart index 5aba3e2..549eeed 100644 --- a/lib/core/dependencies.dart +++ b/lib/core/dependencies.dart @@ -35,7 +35,11 @@ class AppDependencies { getIt.registerLazySingleton(() => NavigationService()); getIt.registerLazySingleton(() => GAnalytics()); getIt.registerLazySingleton(() => AppState(navigationService: getIt())); - getIt.registerLazySingleton(() => LocationUtils(isShowConfirmDialog: false, navigationService: getIt())); + getIt.registerLazySingleton(() => LocationUtils( + isShowConfirmDialog: false, + navigationService: getIt(), + appState: getIt(), + )); getIt.registerLazySingleton(() => DialogServiceImp(navigationService: getIt())); getIt.registerLazySingleton(() => ErrorHandlerServiceImp( dialogService: getIt(), diff --git a/lib/core/enums.dart b/lib/core/enums.dart index db758f3..2fd5867 100644 --- a/lib/core/enums.dart +++ b/lib/core/enums.dart @@ -5,7 +5,7 @@ // unverified, // } -enum AuthMethodTypes { +enum AuthMethodTypesEnum { sms, whatsApp, fingerPrint, @@ -13,7 +13,7 @@ enum AuthMethodTypes { moreOptions, } -enum ViewState { +enum ViewStateEnum { hide, idle, busy, @@ -22,20 +22,44 @@ enum ViewState { errorLocal, } -enum LoginType { +enum LoginTypeEnum { fromLogin, silentLogin, silentWithOTP, } -enum OTPType { sms, whatsapp } +enum OTPTypeEnum { sms, whatsapp } -enum Country { saudiArabia, unitedArabEmirates } +enum CountryEnum { saudiArabia, unitedArabEmirates } -enum SelectionType { dropdown, calendar } +enum SelectionTypeEnum { dropdown, calendar } -enum GenderType { male, female } +enum GenderTypeEnum { male, female } -enum MaritalStatusType { single, married, divorced, widowed } +enum MaritalStatusTypeEnum { single, married, divorced, widowed } -enum ChipType { success, error, alert, info, warning } +enum ChipTypeEnum { success, error, alert, info, warning } + +extension OTPTypeEnumExtension on OTPTypeEnum { + /// Convert enum to int + int toInt() { + switch (this) { + case OTPTypeEnum.sms: + return 1; + case OTPTypeEnum.whatsapp: + return 2; + } + } + + /// Convert int to enum + static OTPTypeEnum fromInt(int value) { + switch (value) { + case 1: + return OTPTypeEnum.sms; + case 2: + return OTPTypeEnum.whatsapp; + default: + throw Exception("Invalid OTPTypeEnum value: $value"); + } + } +} diff --git a/lib/core/exceptions/api_failure.dart b/lib/core/exceptions/api_failure.dart index d2a510f..4bc5097 100644 --- a/lib/core/exceptions/api_failure.dart +++ b/lib/core/exceptions/api_failure.dart @@ -13,6 +13,13 @@ class ServerFailure extends Failure { List get props => [message]; } +class StatusCodeFailure extends Failure { + const StatusCodeFailure(super.message); + + @override + List get props => [message]; +} + class ConnectivityFailure extends Failure { const ConnectivityFailure(super.message); @@ -55,3 +62,5 @@ class InvalidCredentials extends Failure { @override List get props => [message]; } + + diff --git a/lib/core/location_util.dart b/lib/core/location_util.dart index c8e69af..dc6a0d6 100644 --- a/lib/core/location_util.dart +++ b/lib/core/location_util.dart @@ -4,14 +4,14 @@ import 'package:geolocator/geolocator.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/consts.dart'; -import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; -// import 'package:huawei_location/huawei_location.dart'; import 'package:permission_handler/permission_handler.dart'; class LocationUtils { NavigationService navigationService; + AppState appState; + bool isShowConfirmDialog; bool isShowLocationTimeoutDialog; bool isHuawei; @@ -20,10 +20,10 @@ class LocationUtils { LocationUtils({ required this.isShowConfirmDialog, required this.navigationService, + required this.appState, this.isHuawei = false, this.isShowLocationTimeoutDialog = true, }); - AppState appState = getIt.get(); void getCurrentLocation({Function(LatLng)? callBack}) async { Geolocator.isLocationServiceEnabled().then((value) async { diff --git a/lib/core/utils/CalendarUtils.dart b/lib/core/utils/calendar_utils.dart similarity index 100% rename from lib/core/utils/CalendarUtils.dart rename to lib/core/utils/calendar_utils.dart diff --git a/lib/core/utils/LocalNotification.dart b/lib/core/utils/local_notifications.dart similarity index 100% rename from lib/core/utils/LocalNotification.dart rename to lib/core/utils/local_notifications.dart diff --git a/lib/core/utils/push-notification-handler.dart b/lib/core/utils/push_notification_handler.dart similarity index 97% rename from lib/core/utils/push-notification-handler.dart rename to lib/core/utils/push_notification_handler.dart index d71bdcf..b5a816e 100644 --- a/lib/core/utils/push-notification-handler.dart +++ b/lib/core/utils/push_notification_handler.dart @@ -3,19 +3,17 @@ import 'dart:developer'; import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; -import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:firebase_messaging/firebase_messaging.dart' as fir; import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_messaging/firebase_messaging.dart' as fir; +import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; // import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; -import 'package:hmg_patient_app_new/core/utils/LocalNotification.dart'; +import 'package:hmg_patient_app_new/core/utils/local_notifications.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:uuid/uuid.dart'; import '../consts.dart'; @@ -365,7 +363,9 @@ class PushNotificationHandler { Future requestPermissions() async { try { if (Platform.isIOS) { - await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation()?.requestPermissions(alert: true, badge: true, sound: true); + await flutterLocalNotificationsPlugin + .resolvePlatformSpecificImplementation() + ?.requestPermissions(alert: true, badge: true, sound: true); } else if (Platform.isAndroid) { Map statuses = await [ Permission.notification, diff --git a/lib/core/utils/request_utils.dart b/lib/core/utils/request_utils.dart new file mode 100644 index 0000000..1869923 --- /dev/null +++ b/lib/core/utils/request_utils.dart @@ -0,0 +1,91 @@ +import 'package:hmg_patient_app_new/core/enums.dart'; +import 'package:hmg_patient_app_new/features/authentication/models/request_models/send_activation_request_model.dart'; + +class RequestUtils { + static dynamic getCommonRequestWelcome({ + required String phoneNumber, + required OTPTypeEnum otpTypeEnum, + required String? deviceToken, + required bool patientOutSA, + required String? loginTokenID, + required var registeredData, + required int? patientId, + required String nationIdText, + required String countryCode, + }) { + bool fileNo = false; + if (nationIdText.isNotEmpty) { + fileNo = nationIdText.length < 10; + } + var request = SendActivationRequest(); + request.patientMobileNumber = int.parse(phoneNumber); + request.mobileNo = '0$phoneNumber'; + request.deviceToken = deviceToken; + request.projectOutSA = patientOutSA; + request.loginType = otpTypeEnum.toInt(); + request.oTPSendType = otpTypeEnum.toInt(); // could map OTPTypeEnum if needed + request.zipCode = countryCode; // or countryCode if defined elsewhere + request.logInTokenID = loginTokenID ?? ""; + + if (registeredData != null) { + request.searchType = registeredData.searchType ?? 1; + request.patientID = registeredData.patientID ?? 0; + request.patientIdentificationID = request.nationalID = registeredData.patientIdentificationID ?? '0'; + request.dob = registeredData.dob; + request.isRegister = registeredData.isRegister; + } else { + if (fileNo) { + request.patientID = patientId ?? int.parse(nationIdText); + request.patientIdentificationID = request.nationalID = ""; + request.searchType = 2; + } else { + request.patientID = 0; + request.searchType = 1; + request.patientIdentificationID = request.nationalID = nationIdText.isNotEmpty ? nationIdText : '0'; + } + request.isRegister = false; + } + + request.deviceTypeID = request.searchType; + return request; + } + + static getCommonRequestAuthProvider({ + required OTPTypeEnum otpTypeEnum, + required registeredData, + required deviceToken, + required mobileNumber, + required zipCode, + required patientOutSA, + required loginTokenID, + required selectedOption, + required int? patientId, + }) { + var request = SendActivationRequest(); + request.patientMobileNumber = mobileNumber; + request.mobileNo = '0$mobileNumber'; + request.deviceToken = deviceToken; + request.projectOutSA = patientOutSA == true ? true : false; + request.loginType = selectedOption; + request.oTPSendType = otpTypeEnum.toInt(); //this.selectedOption == 1 ? 1 : 2; + request.zipCode = zipCode; + + request.logInTokenID = loginTokenID ?? ""; + + if (registeredData != null) { + request.searchType = registeredData.searchType ?? 1; + request.patientID = registeredData.patientID ?? 0; + request.patientIdentificationID = request.nationalID = registeredData.patientIdentificationID ?? '0'; + request.dob = registeredData.dob; + request.isRegister = registeredData.isRegister; + } else { + request.searchType = request.searchType ?? 2; + request.patientID = patientId ?? 0; + request.nationalID = request.nationalID ?? '0'; + request.patientIdentificationID = request.patientIdentificationID ?? '0'; + request.isRegister = false; + } + request.deviceTypeID = request.searchType; + return request; + } +} diff --git a/lib/extensions/widget_extensions.dart b/lib/extensions/widget_extensions.dart index 8b8c796..e6913d2 100644 --- a/lib/extensions/widget_extensions.dart +++ b/lib/extensions/widget_extensions.dart @@ -193,33 +193,33 @@ Widget widthSpacer5per() => SizedBox(height: 5.w); -extension ChipTypeExtension on ChipType { +extension ChipTypeEnumExtension on ChipTypeEnum { Color get color { switch (this) { - case ChipType.success: + case ChipTypeEnum.success: return AppColors.successColor; // Replace with your actual color - case ChipType.error: + case ChipTypeEnum.error: return AppColors.errorColor; // Replace with your actual color - case ChipType.alert: + case ChipTypeEnum.alert: return AppColors.alertColor; // Replace with your actual color - case ChipType.info: + case ChipTypeEnum.info: return AppColors.infoColor; // Replace with your actual color - case ChipType.warning: + case ChipTypeEnum.warning: return AppColors.warningColor; // Replace with your actual color } } Color get backgroundColor { switch (this) { - case ChipType.success: + case ChipTypeEnum.success: return AppColors.successLightColor; // Replace with your actual color - case ChipType.error: + case ChipTypeEnum.error: return AppColors.errorLightColor; // Replace with your actual color - case ChipType.alert: + case ChipTypeEnum.alert: return AppColors.alertLightColor; // Replace with your actual color - case ChipType.info: + case ChipTypeEnum.info: return AppColors.infoLightColor; // Replace with your actual color - case ChipType.warning: + case ChipTypeEnum.warning: return AppColors.warningLightColor; // Replace with your actual color } } diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 04e3a9e..7307013 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -1,15 +1,27 @@ import 'dart:async'; +import 'dart:io'; import 'package:dartz/dartz.dart'; import 'package:hmg_patient_app_new/core/api/api_client.dart'; import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart'; import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; -import 'package:hmg_patient_app_new/features/authentication/models/select_device_by_imei.dart'; +import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_patient_authentication_request_model.dart'; +import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_activation_code_resp_model.dart'; +import 'package:hmg_patient_app_new/features/authentication/models/resp_models/select_device_by_imei.dart'; import 'package:hmg_patient_app_new/services/logger_service.dart'; abstract class AuthenticationRepo { - Future>> selectDeviceByImei({required String firebaseToken}); + Future>> selectDeviceByImei({ + required String firebaseToken, + }); + + Future>> checkPatientAuthentication({ + required CheckPatientAuthenticationReq checkPatientAuthenticationReq, + }); + + Future>> sendActivationCodeRegister( + {required CheckPatientAuthenticationReq checkPatientAuthenticationReq, String? languageID}); } class AuthenticationRepoImp implements AuthenticationRepo { @@ -19,9 +31,7 @@ class AuthenticationRepoImp implements AuthenticationRepo { AuthenticationRepoImp({required this.loggerService, required this.apiClient}); @override - Future>> selectDeviceByImei({ - required String firebaseToken, - }) async { + Future>> selectDeviceByImei({required String firebaseToken}) async { final mapDevice = {"IMEI": firebaseToken}; try { GenericApiModel? apiResponse; @@ -34,7 +44,7 @@ class AuthenticationRepoImp implements AuthenticationRepo { }, onSuccess: (response, statusCode, {messageStatus}) { try { - final list = response['Patient_SELECTDeviceIMEIbyIMEIList'] as List?; + final list = response['Patient_SELECTDeviceIMEIbyIMEIList']; if (list == null || list.isEmpty) { throw Exception("Device list is empty"); } @@ -58,4 +68,93 @@ class AuthenticationRepoImp implements AuthenticationRepo { return Left(UnknownFailure(e.toString())); } } + + @override + Future>> checkPatientAuthentication({ + required CheckPatientAuthenticationReq checkPatientAuthenticationReq, + String? languageID, + }) async { + int isOutKsa = (checkPatientAuthenticationReq.zipCode == '966' || checkPatientAuthenticationReq.zipCode == '+966') ? 0 : 1; + //TODO : We will use all these from AppState directly in the ApiClient + + checkPatientAuthenticationReq.versionID = VERSION_ID; + checkPatientAuthenticationReq.channel = CHANNEL; + checkPatientAuthenticationReq.iPAdress = IP_ADDRESS; + checkPatientAuthenticationReq.generalid = GENERAL_ID; + checkPatientAuthenticationReq.languageID = (languageID == 'ar' ? 1 : 2); + checkPatientAuthenticationReq.patientOutSA = isOutKsa; + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post( + ApiConsts.selectDeviceImei, + body: checkPatientAuthenticationReq.toJson(), + onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, + onSuccess: (response, statusCode, {messageStatus}) { + try { + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: response, + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, + ); + if (failure != null) return Left(failure!); + if (apiResponse == null) return Left(ServerFailure("Unknown error")); + return Right(apiResponse!); + } catch (e) { + return Left(UnknownFailure(e.toString())); + } + } + + @override + Future>> sendActivationCodeRegister( + {required CheckPatientAuthenticationReq checkPatientAuthenticationReq, String? languageID}) async { + int isOutKsa = (checkPatientAuthenticationReq.zipCode == '966' || checkPatientAuthenticationReq.zipCode == '+966') ? 0 : 1; + //TODO : We will use all these from AppState directly in the ApiClient + + checkPatientAuthenticationReq.versionID = VERSION_ID; + checkPatientAuthenticationReq.channel = CHANNEL; + checkPatientAuthenticationReq.iPAdress = IP_ADDRESS; + checkPatientAuthenticationReq.generalid = GENERAL_ID; + checkPatientAuthenticationReq.languageID = (languageID == 'ar' ? 1 : 2); + checkPatientAuthenticationReq.deviceTypeID = Platform.isIOS ? 1 : 2; + checkPatientAuthenticationReq.patientOutSA = isOutKsa; + checkPatientAuthenticationReq.isDentalAllowedBackend = false; + + try { + GenericApiModel? apiResponse; + Failure? failure; + await apiClient.post( + SEND_ACTIVATION_CODE_REGISTER, + body: checkPatientAuthenticationReq.toJson(), + onFailure: (error, statusCode, {messageStatus, failureType}) { + failure = failureType; + }, + onSuccess: (response, statusCode, {messageStatus}) { + try { + apiResponse = GenericApiModel( + messageStatus: messageStatus, + statusCode: statusCode, + errorMessage: null, + data: CheckActivationCode.fromJson(response), + ); + } catch (e) { + failure = DataParsingFailure(e.toString()); + } + }, + ); + if (failure != null) return Left(failure!); + if (apiResponse == null) return Left(ServerFailure("Unknown error")); + return Right(apiResponse!); + } catch (e) { + return Left(UnknownFailure(e.toString())); + } + } } diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index eaf3c95..573c528 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -1,6 +1,9 @@ import 'package:flutter/material.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; +import 'package:hmg_patient_app_new/core/enums.dart'; +import 'package:hmg_patient_app_new/core/utils/request_utils.dart'; import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart'; +import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_patient_authentication_request_model.dart'; import 'package:hmg_patient_app_new/services/dialog_service.dart'; import 'package:hmg_patient_app_new/services/error_handler_service.dart'; @@ -24,15 +27,109 @@ class AuthenticationViewModel extends ChangeNotifier { String firebaseToken = "dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc"; final result = await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken); + result.fold( - (failure) async => await errorHandlerService.handleError(failure), + (failure) async => await errorHandlerService.handleError(failure: failure), (apiResponse) { if (apiResponse.messageStatus == 2) { - dialogService.showErrorDialog(apiResponse.errorMessage!); + dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); } else if (apiResponse.messageStatus == 1) { - // move to next api call + //todo: move to next api call + } + }, + ); + } + + Future checkUserAuthentication({Function(dynamic)? onSuccess, Function(String)? onError}) async { + CheckPatientAuthenticationReq checkPatientAuthenticationReq = RequestUtils.getCommonRequestWelcome( + phoneNumber: '0567184134', + otpTypeEnum: OTPTypeEnum.sms, + deviceToken: 'dummyDeviceToken123', + patientOutSA: true, + loginTokenID: 'dummyLoginToken456', + registeredData: null, + patientId: 12345, + nationIdText: '1234567890', + countryCode: 'SA', + ); + + final result = await authenticationRepo.checkPatientAuthentication(checkPatientAuthenticationReq: checkPatientAuthenticationReq); + result.fold( + (failure) async => await errorHandlerService.handleError(failure: failure), + (apiResponse) { + if (apiResponse.data['isSMSSent']) { + // TODO: set this in AppState + // sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']); + // loginTokenID = value['LogInTokenID'], + // sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, request), + sendActivationCode(type); + } else { + if (apiResponse.data['IsAuthenticated']) { + checkActivationCode(onWrongActivationCode: (String? message) {}); + } } }, ); } + + Future sendActivationCode({required OTPTypeEnum otpTypeEnum}) async { + var request = RequestUtils.getCommonRequestAuthProvider( + otpTypeEnum: otpTypeEnum, + registeredData: null, + deviceToken: "dummyLoginToken456", + mobileNumber: "0567184134", + zipCode: "SA", + patientOutSA: true, + loginTokenID: "dummyLoginToken456", + selectedOption: selectedOption, + patientId: 12345, + ); + + request.sMSSignature = await SMSOTP.getSignature(); + selectedOption = type; + // GifLoaderDialogUtils.showMyDialog(context); + if (healthId != null || isDubai) { + if (!isDubai) { + request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); + } + request.healthId = healthId; + request.isHijri = isHijri; + await this.apiClient.sendActivationCodeRegister(request).then((result) { + // GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + this.startSMSService(type); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + context.showBottomSheet( + child: ExceptionBottomSheet( + message: r.toString(), + onOkPressed: () { + Navigator.of(context).pop(); + }, + )); + // AppToast.showErrorToast(message: r); + }); + } else { + request.dob = ""; + request.healthId = ""; + request.isHijri = 0; + await this.authService.sendActivationCode(request).then((result) { + GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + this.startSMSService(type); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + context.showBottomSheet( + child: ExceptionBottomSheet( + message: r.toString(), + onOkPressed: () { + Navigator.of(context).pop(); + }, + )); + // AppToast.showErrorToast(message: r.toString()); + }); + } + } } diff --git a/lib/features/authentication/models/check_activation_code_request_register.dart b/lib/features/authentication/models/check_activation_code_request_register.dart deleted file mode 100644 index 85e1f56..0000000 --- a/lib/features/authentication/models/check_activation_code_request_register.dart +++ /dev/null @@ -1,121 +0,0 @@ -class CheckActivationCodeRegisterReq { - int? patientMobileNumber; - String? mobileNo; - String? deviceToken; - bool? projectOutSA; - int? loginType; - String? zipCode; - bool? isRegister; - String? logInTokenID; - int? searchType; - int? patientID; - String? nationalID; - String? patientIdentificationID; - String? activationCode; - bool? isSilentLogin; - double? versionID; - int? channel; - int? languageID; - String? iPAdress; - String? generalid; - int? patientOutSA; - dynamic sessionID; - bool? isDentalAllowedBackend; - int? deviceTypeID; - bool? forRegisteration; - String? dob; - int? isHijri; - String? healthId; - - CheckActivationCodeRegisterReq({ - this.patientMobileNumber, - this.mobileNo, - this.deviceToken, - this.projectOutSA, - this.loginType, - this.zipCode, - this.isRegister, - this.logInTokenID, - this.searchType, - this.patientID, - this.nationalID, - this.patientIdentificationID, - this.activationCode, - this.isSilentLogin, - this.versionID, - this.channel, - this.languageID, - this.iPAdress, - this.generalid, - this.patientOutSA, - this.sessionID, - this.isDentalAllowedBackend, - this.deviceTypeID, - this.forRegisteration, - this.dob, - this.isHijri, - this.healthId, - }); - - CheckActivationCodeRegisterReq.fromJson(Map json) { - patientMobileNumber = json['PatientMobileNumber']; - mobileNo = json['MobileNo']; - deviceToken = json['DeviceToken']; - projectOutSA = json['ProjectOutSA']; - loginType = json['LoginType']; - zipCode = json['ZipCode']; - isRegister = json['isRegister']; - logInTokenID = json['LogInTokenID']; - searchType = json['SearchType']; - patientID = json['PatientID']; - nationalID = json['NationalID']; - patientIdentificationID = json['PatientIdentificationID']; - activationCode = json['activationCode']; - isSilentLogin = json['IsSilentLogin']; - versionID = json['VersionID']; - channel = json['Channel']; - languageID = json['LanguageID']; - iPAdress = json['IPAdress']; - generalid = json['generalid']; - patientOutSA = json['PatientOutSA']; - sessionID = json['SessionID']; - isDentalAllowedBackend = json['isDentalAllowedBackend']; - deviceTypeID = json['DeviceTypeID']; - forRegisteration = json['ForRegisteration']; - dob = json['DOB']; - isHijri = json['IsHijri']; - healthId = json['HealthId']; - } - - Map toJson() { - final Map data = new Map(); - data['PatientMobileNumber'] = this.patientMobileNumber; - data['MobileNo'] = this.mobileNo; - data['DeviceToken'] = this.deviceToken; - data['ProjectOutSA'] = this.projectOutSA; - data['LoginType'] = this.loginType; - data['ZipCode'] = this.zipCode; - data['isRegister'] = this.isRegister; - data['LogInTokenID'] = this.logInTokenID; - data['SearchType'] = this.searchType; - data['PatientID'] = this.patientID; - data['NationalID'] = this.nationalID; - data['PatientIdentificationID'] = this.patientIdentificationID; - data['activationCode'] = this.activationCode; - data['IsSilentLogin'] = this.isSilentLogin; - data['VersionID'] = this.versionID; - data['Channel'] = this.channel; - data['LanguageID'] = this.languageID; - data['IPAdress'] = this.iPAdress; - data['generalid'] = this.generalid; - data['PatientOutSA'] = this.patientOutSA; - data['SessionID'] = this.sessionID; - data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; - data['DeviceTypeID'] = this.deviceTypeID; - data['ForRegisteration'] = this.forRegisteration; - data['DOB'] = dob; - data['IsHijri'] = isHijri; - data['HealthId'] = healthId; - return data; - } -} diff --git a/lib/features/authentication/models/request_models/check_activation_code_request_register.dart b/lib/features/authentication/models/request_models/check_activation_code_request_register.dart new file mode 100644 index 0000000..167c8ec --- /dev/null +++ b/lib/features/authentication/models/request_models/check_activation_code_request_register.dart @@ -0,0 +1,121 @@ +// class CheckActivationCodeRegisterReq { +// int? patientMobileNumber; +// String? mobileNo; +// String? deviceToken; +// bool? projectOutSA; +// int? loginType; +// String? zipCode; +// bool? isRegister; +// String? logInTokenID; +// int? searchType; +// int? patientID; +// String? nationalID; +// String? patientIdentificationID; +// String? activationCode; +// bool? isSilentLogin; +// double? versionID; +// int? channel; +// int? languageID; +// String? iPAdress; +// String? generalid; +// int? patientOutSA; +// dynamic sessionID; +// bool? isDentalAllowedBackend; +// int? deviceTypeID; +// bool? forRegisteration; +// String? dob; +// int? isHijri; +// String? healthId; +// +// CheckActivationCodeRegisterReq({ +// this.patientMobileNumber, +// this.mobileNo, +// this.deviceToken, +// this.projectOutSA, +// this.loginType, +// this.zipCode, +// this.isRegister, +// this.logInTokenID, +// this.searchType, +// this.patientID, +// this.nationalID, +// this.patientIdentificationID, +// this.activationCode, +// this.isSilentLogin, +// this.versionID, +// this.channel, +// this.languageID, +// this.iPAdress, +// this.generalid, +// this.patientOutSA, +// this.sessionID, +// this.isDentalAllowedBackend, +// this.deviceTypeID, +// this.forRegisteration, +// this.dob, +// this.isHijri, +// this.healthId, +// }); +// +// CheckActivationCodeRegisterReq.fromJson(Map json) { +// patientMobileNumber = json['PatientMobileNumber']; +// mobileNo = json['MobileNo']; +// deviceToken = json['DeviceToken']; +// projectOutSA = json['ProjectOutSA']; +// loginType = json['LoginType']; +// zipCode = json['ZipCode']; +// isRegister = json['isRegister']; +// logInTokenID = json['LogInTokenID']; +// searchType = json['SearchType']; +// patientID = json['PatientID']; +// nationalID = json['NationalID']; +// patientIdentificationID = json['PatientIdentificationID']; +// activationCode = json['activationCode']; +// isSilentLogin = json['IsSilentLogin']; +// versionID = json['VersionID']; +// channel = json['Channel']; +// languageID = json['LanguageID']; +// iPAdress = json['IPAdress']; +// generalid = json['generalid']; +// patientOutSA = json['PatientOutSA']; +// sessionID = json['SessionID']; +// isDentalAllowedBackend = json['isDentalAllowedBackend']; +// deviceTypeID = json['DeviceTypeID']; +// forRegisteration = json['ForRegisteration']; +// dob = json['DOB']; +// isHijri = json['IsHijri']; +// healthId = json['HealthId']; +// } +// +// Map toJson() { +// final Map data = new Map(); +// data['PatientMobileNumber'] = this.patientMobileNumber; +// data['MobileNo'] = this.mobileNo; +// data['DeviceToken'] = this.deviceToken; +// data['ProjectOutSA'] = this.projectOutSA; +// data['LoginType'] = this.loginType; +// data['ZipCode'] = this.zipCode; +// data['isRegister'] = this.isRegister; +// data['LogInTokenID'] = this.logInTokenID; +// data['SearchType'] = this.searchType; +// data['PatientID'] = this.patientID; +// data['NationalID'] = this.nationalID; +// data['PatientIdentificationID'] = this.patientIdentificationID; +// data['activationCode'] = this.activationCode; +// data['IsSilentLogin'] = this.isSilentLogin; +// data['VersionID'] = this.versionID; +// data['Channel'] = this.channel; +// data['LanguageID'] = this.languageID; +// data['IPAdress'] = this.iPAdress; +// data['generalid'] = this.generalid; +// data['PatientOutSA'] = this.patientOutSA; +// data['SessionID'] = this.sessionID; +// data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; +// data['DeviceTypeID'] = this.deviceTypeID; +// data['ForRegisteration'] = this.forRegisteration; +// data['DOB'] = dob; +// data['IsHijri'] = isHijri; +// data['HealthId'] = healthId; +// return data; +// } +// } diff --git a/lib/features/authentication/models/request_models/check_patient_authentication_request_model.dart b/lib/features/authentication/models/request_models/check_patient_authentication_request_model.dart new file mode 100644 index 0000000..483e416 --- /dev/null +++ b/lib/features/authentication/models/request_models/check_patient_authentication_request_model.dart @@ -0,0 +1,88 @@ +class CheckPatientAuthenticationReq { + int? patientMobileNumber; + String? zipCode; + bool? isRegister; + String? tokenID; + int? searchType; + String? patientIdentificationID; + int? patientID; + double? versionID; + int? channel; + int? languageID; + String? iPAdress; + String? generalid; + int? patientOutSA; + dynamic sessionID; + bool? isDentalAllowedBackend; + int? deviceTypeID; + String? dob; + int? isHijri; + String? healthId; + + CheckPatientAuthenticationReq( + {this.patientMobileNumber, + this.zipCode, + this.isRegister, + this.tokenID, + this.searchType, + this.patientIdentificationID, + this.patientID, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.dob, + this.isHijri, + this.healthId}); + + CheckPatientAuthenticationReq.fromJson(Map json) { + patientMobileNumber = json['PatientMobileNumber']; + zipCode = json['ZipCode']; + isRegister = json['isRegister']; + tokenID = json['TokenID']; + searchType = json['SearchType']; + patientIdentificationID = json['PatientIdentificationID']; + patientID = json['PatientID']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + dob = json['dob']; + isHijri = json['isHijri']; + healthId = json['HealthId']; + } + + Map toJson() { + final Map data = {}; + data['PatientMobileNumber'] = patientMobileNumber; + data['ZipCode'] = zipCode; + data['isRegister'] = isRegister; + data['TokenID'] = tokenID; + data['SearchType'] = searchType; + data['PatientIdentificationID'] = patientIdentificationID; + data['PatientID'] = patientID; + data['VersionID'] = versionID; + data['Channel'] = channel; + data['LanguageID'] = languageID; + data['IPAdress'] = iPAdress; + data['generalid'] = generalid; + data['PatientOutSA'] = patientOutSA; + data['SessionID'] = sessionID; + data['isDentalAllowedBackend'] = isDentalAllowedBackend; + data['DeviceTypeID'] = deviceTypeID; + data['dob'] = dob; + data['isHijri'] = isHijri; + data['HealthId'] = healthId; + return data; + } +} diff --git a/lib/features/authentication/models/request_models/send_activation_request_model.dart b/lib/features/authentication/models/request_models/send_activation_request_model.dart new file mode 100644 index 0000000..dc3d55d --- /dev/null +++ b/lib/features/authentication/models/request_models/send_activation_request_model.dart @@ -0,0 +1,132 @@ +class SendActivationRequest { + int? patientMobileNumber; + String? mobileNo; + String? deviceToken; + bool? projectOutSA; + int? loginType; + String? zipCode; + bool? isRegister; + String? logInTokenID; + int? searchType; + int? patientID; + String? nationalID; + String? patientIdentificationID; + int? oTPSendType; + int? languageID; + double? versionID; + int? channel; + String? iPAdress; + String? generalid; + int? patientOutSA; + dynamic sessionID; + bool? isDentalAllowedBackend; + int? deviceTypeID; + String? sMSSignature; + String? dob; + int? isHijri; + String? healthId; + int? responseID; + int? status; + int? familyRegionID; + bool? isPatientExcluded; + SendActivationRequest( + {this.patientMobileNumber, + this.mobileNo, + this.deviceToken, + this.projectOutSA, + this.loginType, + this.zipCode, + this.isRegister, + this.logInTokenID, + this.searchType, + this.patientID, + this.nationalID, + this.patientIdentificationID, + this.oTPSendType, + this.languageID, + this.versionID, + this.channel, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.sMSSignature, + this.dob, + this.isHijri, + this.healthId, + this.responseID, + this.status, + this.familyRegionID, + this.isPatientExcluded + }); + + SendActivationRequest.fromJson(Map json) { + patientMobileNumber = json['PatientMobileNumber']; + mobileNo = json['MobileNo']; + deviceToken = json['DeviceToken']; + projectOutSA = json['ProjectOutSA']; + loginType = json['LoginType']; + zipCode = json['ZipCode']; + isRegister = json['isRegister']; + logInTokenID = json['LogInTokenID']; + searchType = json['SearchType']; + patientID = json['PatientID']; + nationalID = json['NationalID']; + patientIdentificationID = json['PatientIdentificationID']; + oTPSendType = json['OTP_SendType']; + languageID = json['LanguageID']; + versionID = json['VersionID']; + channel = json['Channel']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + sMSSignature = json['SMSSignature']; + dob = json['DOB']; + isHijri = json['IsHijri']; + healthId = json['HealthId']; + responseID = json['ReponseID']; + status = json['Status']; + familyRegionID = json['FamilyRegionID']; + isPatientExcluded = json['IsPatientExcluded']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMobileNumber'] = patientMobileNumber; + data['MobileNo'] = mobileNo; + data['DeviceToken'] = deviceToken; + data['ProjectOutSA'] = projectOutSA; + data['LoginType'] = loginType; + data['ZipCode'] = zipCode; + data['isRegister'] = isRegister; + data['LogInTokenID'] = logInTokenID; + data['SearchType'] = searchType; + data['PatientID'] = patientID; + data['NationalID'] = nationalID; + data['PatientIdentificationID'] = patientIdentificationID; + data['OTP_SendType'] = oTPSendType; + data['LanguageID'] = languageID; + data['VersionID'] = versionID; + data['Channel'] = channel; + data['IPAdress'] = iPAdress; + data['generalid'] = generalid; + data['PatientOutSA'] = patientOutSA; + data['SessionID'] = sessionID; + data['isDentalAllowedBackend'] = isDentalAllowedBackend; + data['DeviceTypeID'] = deviceTypeID; + data['SMSSignature'] = sMSSignature; + data['DOB'] = dob; + data['IsHijri'] = isHijri; + data['HealthId'] = healthId; + data['ResponseID'] = responseID; + data['Status'] = status; + data['FamilyRegionID'] = familyRegionID; + data['IsPatientExcluded'] = isPatientExcluded; + return data; + } +} diff --git a/lib/features/authentication/models/authenticated_user_model.dart b/lib/features/authentication/models/resp_models/authenticated_user_resp_model.dart similarity index 100% rename from lib/features/authentication/models/authenticated_user_model.dart rename to lib/features/authentication/models/resp_models/authenticated_user_resp_model.dart diff --git a/lib/features/authentication/models/resp_models/check_activation_code_resp_model.dart b/lib/features/authentication/models/resp_models/check_activation_code_resp_model.dart new file mode 100644 index 0000000..8610e08 --- /dev/null +++ b/lib/features/authentication/models/resp_models/check_activation_code_resp_model.dart @@ -0,0 +1,546 @@ +import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart'; + +class CheckActivationCode { + dynamic date; + int? languageID; + int? serviceName; + dynamic time; + dynamic androidLink; + String? authenticationTokenID; + dynamic data; + bool? dataw; + int? dietType; + dynamic errorCode; + dynamic errorEndUserMessage; + dynamic errorEndUserMessageN; + dynamic errorMessage; + int? errorType; + int? foodCategory; + dynamic iOSLink; + bool? isAuthenticated; + int? mealOrderStatus; + int? mealType; + int? messageStatus; + int? numberOfResultRecords; + dynamic patientBlodType; + dynamic successMsg; + dynamic successMsgN; + dynamic doctorInformationList; + dynamic getAllPendingRecordsList; + dynamic getAllSharedRecordsByStatusList; + dynamic getResponseFileList; + bool? isHMGPatient; + bool? isLoginSuccessfully; + bool? isNeedUpdateIdintificationNo; + bool? kioskSendSMS; + AuthenticatedUser? list; + dynamic listAskHabibMobileLoginInfo; + dynamic listAskHabibPatientFile; + dynamic listMergeFiles; + dynamic listMobileLoginInfo; + dynamic listPatientCount; + dynamic logInTokenID; + dynamic mohemmPrivilegeList; + int? pateintID; + String? patientBloodType; + bool? patientHasFile; + dynamic patientMergedIDs; + bool? patientOutSA; + int? patientShareRequestID; + int? patientType; + int? projectIDOut; + dynamic returnMessage; + bool? sMSLoginRequired; + dynamic servicePrivilegeList; + dynamic sharePatientName; + dynamic verificationCode; + dynamic email; + dynamic errorList; + bool? hasFile; + bool? isActiveCode; + bool? isMerged; + bool? isNeedUserAgreement; + bool? isSMSSent; + dynamic memberList; + dynamic message; + int? statusCode; + + CheckActivationCode( + {this.date, + this.languageID, + this.serviceName, + this.time, + this.androidLink, + this.authenticationTokenID, + this.data, + this.dataw, + this.dietType, + this.errorCode, + this.errorEndUserMessage, + this.errorEndUserMessageN, + this.errorMessage, + this.errorType, + this.foodCategory, + this.iOSLink, + this.isAuthenticated, + this.mealOrderStatus, + this.mealType, + this.messageStatus, + this.numberOfResultRecords, + this.patientBlodType, + this.successMsg, + this.successMsgN, + this.doctorInformationList, + this.getAllPendingRecordsList, + this.getAllSharedRecordsByStatusList, + this.getResponseFileList, + this.isHMGPatient, + this.isLoginSuccessfully, + this.isNeedUpdateIdintificationNo, + this.kioskSendSMS, + this.list, + this.listAskHabibMobileLoginInfo, + this.listAskHabibPatientFile, + this.listMergeFiles, + this.listMobileLoginInfo, + this.listPatientCount, + this.logInTokenID, + this.mohemmPrivilegeList, + this.pateintID, + this.patientBloodType, + this.patientHasFile, + this.patientMergedIDs, + this.patientOutSA, + this.patientShareRequestID, + this.patientType, + this.projectIDOut, + this.returnMessage, + this.sMSLoginRequired, + this.servicePrivilegeList, + this.sharePatientName, + this.verificationCode, + this.email, + this.errorList, + this.hasFile, + this.isActiveCode, + this.isMerged, + this.isNeedUserAgreement, + this.isSMSSent, + this.memberList, + this.message, + this.statusCode}); + + CheckActivationCode.fromJson(Map json) { + date = json['Date']; + languageID = json['LanguageID']; + serviceName = json['ServiceName']; + time = json['Time']; + androidLink = json['AndroidLink']; + authenticationTokenID = json['AuthenticationTokenID']; + data = json['Data']; + dataw = json['Dataw']; + dietType = json['DietType']; + errorCode = json['ErrorCode']; + errorEndUserMessage = json['ErrorEndUserMessage']; + errorEndUserMessageN = json['ErrorEndUserMessageN']; + errorMessage = json['ErrorMessage']; + errorType = json['ErrorType']; + foodCategory = json['FoodCategory']; + iOSLink = json['IOSLink']; + isAuthenticated = json['IsAuthenticated']; + mealOrderStatus = json['MealOrderStatus']; + mealType = json['MealType']; + messageStatus = json['MessageStatus']; + numberOfResultRecords = json['NumberOfResultRecords']; + patientBlodType = json['PatientBlodType']; + successMsg = json['SuccessMsg']; + successMsgN = json['SuccessMsgN']; + doctorInformationList = json['DoctorInformation_List']; + getAllPendingRecordsList = json['GetAllPendingRecordsList']; + getAllSharedRecordsByStatusList = json['GetAllSharedRecordsByStatusList']; + getResponseFileList = json['GetResponseFileList']; + isHMGPatient = json['IsHMGPatient']; + isLoginSuccessfully = json['IsLoginSuccessfully']; + isNeedUpdateIdintificationNo = json['IsNeedUpdateIdintificationNo']; + kioskSendSMS = json['KioskSendSMS']; + if (json['List'] != null) { + list = AuthenticatedUser.fromJson(json['List'][0]); + } + listAskHabibMobileLoginInfo = json['List_AskHabibMobileLoginInfo']; + listAskHabibPatientFile = json['List_AskHabibPatientFile']; + listMergeFiles = json['List_MergeFiles']; + listMobileLoginInfo = json['List_MobileLoginInfo']; + listPatientCount = json['List_PatientCount']; + logInTokenID = json['LogInTokenID']; + mohemmPrivilegeList = json['MohemmPrivilege_List']; + pateintID = json['PateintID']; + patientBloodType = json['PatientBloodType']; + patientHasFile = json['PatientHasFile']; + patientMergedIDs = json['PatientMergedIDs']; + patientOutSA = json['PatientOutSA']; + patientShareRequestID = json['PatientShareRequestID']; + patientType = json['PatientType']; + projectIDOut = json['ProjectIDOut']; + returnMessage = json['ReturnMessage']; + sMSLoginRequired = json['SMSLoginRequired']; + servicePrivilegeList = json['ServicePrivilege_List']; + sharePatientName = json['SharePatientName']; + verificationCode = json['VerificationCode']; + email = json['email']; + errorList = json['errorList']; + hasFile = json['hasFile']; + isActiveCode = json['isActiveCode']; + isMerged = json['isMerged']; + isNeedUserAgreement = json['isNeedUserAgreement']; + isSMSSent = json['isSMSSent']; + memberList = json['memberList']; + message = json['message']; + statusCode = json['statusCode']; + } + + Map toJson() { + final Map data = {}; + data['Date'] = date; + data['LanguageID'] = languageID; + data['ServiceName'] = serviceName; + data['Time'] = time; + data['AndroidLink'] = androidLink; + data['AuthenticationTokenID'] = authenticationTokenID; + data['Data'] = this.data; + data['Dataw'] = dataw; + data['DietType'] = dietType; + data['ErrorCode'] = errorCode; + data['ErrorEndUserMessage'] = errorEndUserMessage; + data['ErrorEndUserMessageN'] = errorEndUserMessageN; + data['ErrorMessage'] = errorMessage; + data['ErrorType'] = errorType; + data['FoodCategory'] = foodCategory; + data['IOSLink'] = iOSLink; + data['IsAuthenticated'] = isAuthenticated; + data['MealOrderStatus'] = mealOrderStatus; + data['MealType'] = mealType; + data['MessageStatus'] = messageStatus; + data['NumberOfResultRecords'] = numberOfResultRecords; + data['PatientBlodType'] = patientBlodType; + data['SuccessMsg'] = successMsg; + data['SuccessMsgN'] = successMsgN; + data['DoctorInformation_List'] = doctorInformationList; + data['GetAllPendingRecordsList'] = getAllPendingRecordsList; + data['GetAllSharedRecordsByStatusList'] = getAllSharedRecordsByStatusList; + data['GetResponseFileList'] = getResponseFileList; + data['IsHMGPatient'] = isHMGPatient; + data['IsLoginSuccessfully'] = isLoginSuccessfully; + data['IsNeedUpdateIdintificationNo'] = isNeedUpdateIdintificationNo; + data['KioskSendSMS'] = kioskSendSMS; + if (list != null) { + data['List'] = list; + } + data['List_AskHabibMobileLoginInfo'] = listAskHabibMobileLoginInfo; + data['List_AskHabibPatientFile'] = listAskHabibPatientFile; + data['List_MergeFiles'] = listMergeFiles; + data['List_MobileLoginInfo'] = listMobileLoginInfo; + data['List_PatientCount'] = listPatientCount; + data['LogInTokenID'] = logInTokenID; + data['MohemmPrivilege_List'] = mohemmPrivilegeList; + data['PateintID'] = pateintID; + data['PatientBloodType'] = patientBloodType; + data['PatientHasFile'] = patientHasFile; + data['PatientMergedIDs'] = patientMergedIDs; + data['PatientOutSA'] = patientOutSA; + data['PatientShareRequestID'] = patientShareRequestID; + data['PatientType'] = patientType; + data['ProjectIDOut'] = projectIDOut; + data['ReturnMessage'] = returnMessage; + data['SMSLoginRequired'] = sMSLoginRequired; + data['ServicePrivilege_List'] = servicePrivilegeList; + data['SharePatientName'] = sharePatientName; + data['VerificationCode'] = verificationCode; + data['email'] = email; + data['errorList'] = errorList; + data['hasFile'] = hasFile; + data['isActiveCode'] = isActiveCode; + data['isMerged'] = isMerged; + data['isNeedUserAgreement'] = isNeedUserAgreement; + data['isSMSSent'] = isSMSSent; + data['memberList'] = memberList; + data['message'] = message; + data['statusCode'] = statusCode; + return data; + } +} + +class List { + String? setupID; + int? patientType; + int? patientID; + String? firstName; + String? middleName; + String? lastName; + String? firstNameN; + String? middleNameN; + String? lastNameN; + int? relationshipID; + int? gender; + String? dateofBirth; + dynamic dateofBirthN; + String? nationalityID; + dynamic phoneResi; + dynamic phoneOffice; + String? mobileNumber; + dynamic faxNumber; + String? emailAddress; + dynamic bloodGroup; + dynamic rHFactor; + bool? isEmailAlertRequired; + bool? isSMSAlertRequired; + String? preferredLanguage; + bool? isPrivilegedMember; + dynamic memberID; + dynamic expiryDate; + dynamic isHmgEmployee; + dynamic employeeID; + dynamic emergencyContactName; + dynamic emergencyContactNo; + int? patientPayType; + dynamic dHCCPatientRefID; + bool? isPatientDummy; + int? status; + dynamic isStatusCleared; + int? patientIdentificationType; + String? patientIdentificationNo; + int? projectID; + int? infoSourceID; + dynamic address; + int? age; + String? ageDesc; + int? areaID; + int? createdBy; + String? genderDescription; + dynamic iR; + dynamic iSOCityID; + dynamic iSOCountryID; + ListPrivilege? listPrivilege; + dynamic marital; + int? outSA; + dynamic pOBox; + bool? receiveHealthSummaryReport; + int? sourceType; + dynamic strDateofBirth; + dynamic tempAddress; + dynamic zipCode; + + List({ + this.setupID, + this.patientType, + this.patientID, + this.firstName, + this.middleName, + this.lastName, + this.firstNameN, + this.middleNameN, + this.lastNameN, + this.relationshipID, + this.gender, + this.dateofBirth, + this.dateofBirthN, + this.nationalityID, + this.phoneResi, + this.phoneOffice, + this.mobileNumber, + this.faxNumber, + this.emailAddress, + this.bloodGroup, + this.rHFactor, + this.isEmailAlertRequired, + this.isSMSAlertRequired, + this.preferredLanguage, + this.isPrivilegedMember, + this.memberID, + this.expiryDate, + this.isHmgEmployee, + this.employeeID, + this.emergencyContactName, + this.emergencyContactNo, + this.patientPayType, + this.dHCCPatientRefID, + this.isPatientDummy, + this.status, + this.isStatusCleared, + this.patientIdentificationType, + this.patientIdentificationNo, + this.projectID, + this.infoSourceID, + this.address, + this.age, + this.ageDesc, + this.areaID, + this.createdBy, + this.genderDescription, + this.iR, + this.iSOCityID, + this.iSOCountryID, + this.listPrivilege, + this.marital, + this.outSA, + this.pOBox, + this.receiveHealthSummaryReport, + this.sourceType, + this.strDateofBirth, + this.tempAddress, + this.zipCode, + }); + + List.fromJson(Map json) { + setupID = json['SetupID']; + patientType = json['PatientType']; + patientID = json['PatientID']; + firstName = json['FirstName']; + middleName = json['MiddleName']; + lastName = json['LastName']; + firstNameN = json['FirstNameN']; + middleNameN = json['MiddleNameN']; + lastNameN = json['LastNameN']; + relationshipID = json['RelationshipID']; + gender = json['Gender']; + dateofBirth = json['DateofBirth']; + dateofBirthN = json['DateofBirthN']; + nationalityID = json['NationalityID']; + phoneResi = json['PhoneResi']; + phoneOffice = json['PhoneOffice']; + mobileNumber = json['MobileNumber']; + faxNumber = json['FaxNumber']; + emailAddress = json['EmailAddress']; + bloodGroup = json['BloodGroup']; + rHFactor = json['RHFactor']; + isEmailAlertRequired = json['IsEmailAlertRequired']; + isSMSAlertRequired = json['IsSMSAlertRequired']; + preferredLanguage = json['PreferredLanguage']; + isPrivilegedMember = json['IsPrivilegedMember']; + memberID = json['MemberID']; + expiryDate = json['ExpiryDate']; + isHmgEmployee = json['IsHmgEmployee']; + employeeID = json['EmployeeID']; + emergencyContactName = json['EmergencyContactName']; + emergencyContactNo = json['EmergencyContactNo']; + patientPayType = json['PatientPayType']; + dHCCPatientRefID = json['DHCCPatientRefID']; + isPatientDummy = json['IsPatientDummy']; + status = json['Status']; + isStatusCleared = json['IsStatusCleared']; + patientIdentificationType = json['PatientIdentificationType']; + patientIdentificationNo = json['PatientIdentificationNo']; + projectID = json['ProjectID']; + infoSourceID = json['InfoSourceID']; + address = json['Address']; + age = json['Age']; + ageDesc = json['AgeDesc']; + areaID = json['AreaID']; + createdBy = json['CreatedBy']; + genderDescription = json['GenderDescription']; + iR = json['IR']; + iSOCityID = json['ISOCityID']; + iSOCountryID = json['ISOCountryID']; + if (json['ListPrivilege'] != null) { + listPrivilege = ListPrivilege.fromJson(json['ListPrivilege']); + } + marital = json['Marital']; + outSA = json['OutSA']; + pOBox = json['POBox']; + receiveHealthSummaryReport = json['ReceiveHealthSummaryReport']; + sourceType = json['SourceType']; + strDateofBirth = json['StrDateofBirth']; + tempAddress = json['TempAddress']; + zipCode = json['ZipCode']; + } + + Map toJson() { + final Map data = {}; + data['SetupID'] = setupID; + data['PatientType'] = patientType; + data['PatientID'] = patientID; + data['FirstName'] = firstName; + data['MiddleName'] = middleName; + data['LastName'] = lastName; + data['FirstNameN'] = firstNameN; + data['MiddleNameN'] = middleNameN; + data['LastNameN'] = lastNameN; + data['RelationshipID'] = relationshipID; + data['Gender'] = gender; + data['DateofBirth'] = dateofBirth; + data['DateofBirthN'] = dateofBirthN; + data['NationalityID'] = nationalityID; + data['PhoneResi'] = phoneResi; + data['PhoneOffice'] = phoneOffice; + data['MobileNumber'] = mobileNumber; + data['FaxNumber'] = faxNumber; + data['EmailAddress'] = emailAddress; + data['BloodGroup'] = bloodGroup; + data['RHFactor'] = rHFactor; + data['IsEmailAlertRequired'] = isEmailAlertRequired; + data['IsSMSAlertRequired'] = isSMSAlertRequired; + data['PreferredLanguage'] = preferredLanguage; + data['IsPrivilegedMember'] = isPrivilegedMember; + data['MemberID'] = memberID; + data['ExpiryDate'] = expiryDate; + data['IsHmgEmployee'] = isHmgEmployee; + data['EmployeeID'] = employeeID; + data['EmergencyContactName'] = emergencyContactName; + data['EmergencyContactNo'] = emergencyContactNo; + data['PatientPayType'] = patientPayType; + data['DHCCPatientRefID'] = dHCCPatientRefID; + data['IsPatientDummy'] = isPatientDummy; + data['Status'] = status; + data['IsStatusCleared'] = isStatusCleared; + data['PatientIdentificationType'] = patientIdentificationType; + data['PatientIdentificationNo'] = patientIdentificationNo; + data['ProjectID'] = projectID; + data['InfoSourceID'] = infoSourceID; + data['Address'] = address; + data['Age'] = age; + data['AgeDesc'] = ageDesc; + data['AreaID'] = areaID; + data['CreatedBy'] = createdBy; + data['GenderDescription'] = genderDescription; + data['IR'] = iR; + data['ISOCityID'] = iSOCityID; + data['ISOCountryID'] = iSOCountryID; + if (listPrivilege != null) { + data['ListPrivilege'] = listPrivilege; + } + data['Marital'] = marital; + data['OutSA'] = outSA; + data['POBox'] = pOBox; + data['ReceiveHealthSummaryReport'] = receiveHealthSummaryReport; + data['SourceType'] = sourceType; + data['StrDateofBirth'] = strDateofBirth; + data['TempAddress'] = tempAddress; + data['ZipCode'] = zipCode; + + return data; + } +} + +class ListPrivilege { + int? iD; + String? serviceName; + bool? previlege; + dynamic region; + + ListPrivilege({this.iD, this.serviceName, this.previlege, this.region}); + + ListPrivilege.fromJson(Map json) { + iD = json['ID']; + serviceName = json['ServiceName']; + previlege = json['Previlege']; + region = json['Region']; + } + + Map toJson() { + final Map data = {}; + data['ID'] = iD; + data['ServiceName'] = serviceName; + data['Previlege'] = previlege; + data['Region'] = region; + return data; + } +} diff --git a/lib/features/authentication/models/get_patient_last_login_details_response_model.dart b/lib/features/authentication/models/resp_models/get_patient_last_login_details_response_model.dart similarity index 100% rename from lib/features/authentication/models/get_patient_last_login_details_response_model.dart rename to lib/features/authentication/models/resp_models/get_patient_last_login_details_response_model.dart diff --git a/lib/features/authentication/models/select_device_by_imei.dart b/lib/features/authentication/models/resp_models/select_device_by_imei.dart similarity index 100% rename from lib/features/authentication/models/select_device_by_imei.dart rename to lib/features/authentication/models/resp_models/select_device_by_imei.dart diff --git a/lib/services/analytics/analytics_service.dart b/lib/services/analytics/analytics_service.dart index d4f83a4..3411157 100644 --- a/lib/services/analytics/analytics_service.dart +++ b/lib/services/analytics/analytics_service.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:geolocator/geolocator.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; -import 'package:hmg_patient_app_new/features/authentication/models/authenticated_user_model.dart'; +import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart'; import 'package:hmg_patient_app_new/services/analytics/flows/advance_payments.dart'; import 'package:hmg_patient_app_new/services/analytics/flows/app_nav.dart'; import 'package:hmg_patient_app_new/services/analytics/flows/appointments.dart'; diff --git a/lib/services/dialog_service.dart b/lib/services/dialog_service.dart index e931568..af5af9c 100644 --- a/lib/services/dialog_service.dart +++ b/lib/services/dialog_service.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:hmg_patient_app_new/extensions/route_extensions.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; abstract class DialogService { - Future showErrorDialog(String message); + Future showErrorDialog({required String message, Function()? onOkPressed}); } class DialogServiceImp implements DialogService { @@ -11,7 +12,7 @@ class DialogServiceImp implements DialogService { DialogServiceImp({required this.navigationService}); @override - Future showErrorDialog(String message) async { + Future showErrorDialog({required String message, Function()? onOkPressed}) async { final context = navigationService.navigatorKey.currentContext; if (context == null) return; @@ -21,15 +22,16 @@ class DialogServiceImp implements DialogService { shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(16)), ), - builder: (_) => _ErrorBottomSheet(message: message), + builder: (_) => _ErrorBottomSheet(message: message, onOkPressed: onOkPressed), ); } } class _ErrorBottomSheet extends StatelessWidget { final String message; + final Function()? onOkPressed; - const _ErrorBottomSheet({required this.message}); + const _ErrorBottomSheet({required this.message, this.onOkPressed}); @override Widget build(BuildContext context) { @@ -55,7 +57,13 @@ class _ErrorBottomSheet extends StatelessWidget { ), const SizedBox(height: 16), ElevatedButton( - onPressed: () => Navigator.of(context).pop(), + onPressed: () { + if (onOkPressed != null) { + onOkPressed!(); + } else { + context.pop(); + } + }, style: ElevatedButton.styleFrom( backgroundColor: Colors.red, shape: RoundedRectangleBorder( diff --git a/lib/services/error_handler_service.dart b/lib/services/error_handler_service.dart index d8d473a..a26d264 100644 --- a/lib/services/error_handler_service.dart +++ b/lib/services/error_handler_service.dart @@ -7,7 +7,7 @@ import 'package:hmg_patient_app_new/services/logger_service.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; abstract class ErrorHandlerService { - Future handleError(Failure failure); + Future handleError({required Failure failure, Function() onOkPressed}); } class ErrorHandlerServiceImp implements ErrorHandlerService { @@ -22,7 +22,7 @@ class ErrorHandlerServiceImp implements ErrorHandlerService { }); @override - Future handleError(Failure failure) async { + Future handleError({required Failure failure, Function()? onOkPressed}) async { if (failure is APIException) { loggerService.errorLogs("API Exception: ${failure.message}"); } else if (failure is ServerFailure) { @@ -31,6 +31,9 @@ class ErrorHandlerServiceImp implements ErrorHandlerService { } else if (failure is DataParsingFailure) { loggerService.errorLogs("Data Parsing Failure: ${failure.message}"); await _showDialog(failure, title: "Data Error"); + } else if (failure is StatusCodeFailure) { + loggerService.errorLogs("StatusCode Failure: ${failure.message}"); + await _showDialog(failure, title: "Status Code Failure Error"); } else if (failure is HttpException) { loggerService.errorLogs("Http Exception: ${failure.message}"); await _showDialog(failure, title: "Network Error"); @@ -46,7 +49,7 @@ class ErrorHandlerServiceImp implements ErrorHandlerService { } } - Future _showDialog(Failure failure, {String title = "Error"}) async { - await dialogService.showErrorDialog(failure.message); + Future _showDialog(Failure failure, {String title = "Error", Function()? onOkPressed}) async { + await dialogService.showErrorDialog(message: failure.message, onOkPressed: onOkPressed); } } diff --git a/lib/splashPage.dart b/lib/splashPage.dart index 85b2e80..bc3e542 100644 --- a/lib/splashPage.dart +++ b/lib/splashPage.dart @@ -16,8 +16,8 @@ import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart'; import 'package:provider/provider.dart'; import 'core/consts.dart'; -import 'core/utils/LocalNotification.dart'; -import 'core/utils/push-notification-handler.dart'; +import 'core/utils/local_notifications.dart'; +import 'core/utils/push_notification_handler.dart'; class SplashPage extends StatefulWidget { @override diff --git a/lib/widgets/chip/custom_chip_widget.dart b/lib/widgets/chip/custom_chip_widget.dart index 9afb986..6c2f1e3 100644 --- a/lib/widgets/chip/custom_chip_widget.dart +++ b/lib/widgets/chip/custom_chip_widget.dart @@ -5,7 +5,7 @@ import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; class CustomChipWidget extends StatelessWidget { - final ChipType chipType; + final ChipTypeEnum chipType; final String chipText; final String? iconAsset; final VoidCallback? onTap; @@ -14,7 +14,7 @@ class CustomChipWidget extends StatelessWidget { final EdgeInsetsGeometry padding; const CustomChipWidget({ - Key? key, + super.key, required this.chipType, required this.chipText, this.iconAsset, @@ -22,7 +22,7 @@ class CustomChipWidget extends StatelessWidget { this.isSelected = false, this.borderRadius = 12, this.padding = const EdgeInsets.all(8), - }) : super(key: key); + }); @override Widget build(BuildContext context) {