Merge branch 'dev_aamir' of http://34.17.52.180/Haroon6138/HMG_Patient_App_New into dev_sultan

# Conflicts:
#	lib/presentation/medical_file/medical_file_page.dart
pull/76/head
Sultan khan 1 month ago
commit d5bd99f525

@ -808,6 +808,9 @@ class ApiConsts {
static final String registerUser = 'Services/Authentication.svc/REST/PatientRegistration'; static final String registerUser = 'Services/Authentication.svc/REST/PatientRegistration';
static final String addFamilyFile = 'Services/Patients.svc/REST/ShareFamilyFileService'; static final String addFamilyFile = 'Services/Patients.svc/REST/ShareFamilyFileService';
static final String sendFamilyFileActivation = 'Services/Authentication.svc/REST/SendActivationCodeForFamilyFile';
static final String checkActivationCodeForFamily = 'Services/Authentication.svc/REST/CheckActivationCodeForFamilyFile';
// static values for Api // static values for Api
static final double appVersionID = 18.7; static final double appVersionID = 18.7;

@ -9,6 +9,7 @@ import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/models/request_models/registration_payload_model.dart'; import 'package:hmg_patient_app_new/features/authentication/models/request_models/registration_payload_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/request_models/send_activation_request_model.dart'; import 'package:hmg_patient_app_new/features/authentication/models/request_models/send_activation_request_model.dart';
import 'package:hmg_patient_app_new/features/common/models/commong_authanticated_req_model.dart'; import 'package:hmg_patient_app_new/features/common/models/commong_authanticated_req_model.dart';
import 'package:hmg_patient_app_new/features/common/models/family_file_request.dart';
class RequestUtils { class RequestUtils {
static dynamic getPatientAuthenticationRequest({ static dynamic getPatientAuthenticationRequest({
@ -125,6 +126,9 @@ class RequestUtils {
required bool isForRegister, required bool isForRegister,
required bool isFileNo, required bool isFileNo,
dynamic payload, dynamic payload,
required bool isExcludedUser,
required bool isFormFamilyFile,
int? responseID,
}) { }) {
AppState _appState = getIt.get<AppState>(); AppState _appState = getIt.get<AppState>();
var request = SendActivationRequest(); var request = SendActivationRequest();
@ -156,6 +160,15 @@ class RequestUtils {
request.isRegister = false; request.isRegister = false;
} }
request.deviceTypeID = request.searchType; request.deviceTypeID = request.searchType;
if (isFormFamilyFile) {
//INFO: Only for Excluded User Family Member Addition
request.isPatientExcluded = isExcludedUser;
request.responseID = responseID;
request.status = 2;
request.familyRegionID = zipCode == CountryEnum.saudiArabia.countryCode ? 1 : 2;
}
return request; return request;
} }
@ -247,19 +260,29 @@ class RequestUtils {
}; };
} }
static dynamic getAddFamilyRequest({required String nationalIDorFile, required String mobileNo, required String countryCode, required int loginType}) { static Future<FamilyFileRequest> getAddFamilyRequest({required String nationalIDorFile, required String mobileNo, required String countryCode}) async {
var request = <String, dynamic>{}; FamilyFileRequest request = FamilyFileRequest();
int? loginType = 0; // Default to National ID
if (countryCode == CountryEnum.saudiArabia.countryCode || countryCode == '+966') {
loginType = (nationalIDorFile.length == 10) ? 1 : 2;
} else if (countryCode == CountryEnum.unitedArabEmirates.countryCode || countryCode == '+971') {
loginType = (nationalIDorFile.length == 15) ? 1 : 2;
}
if (loginType == 1) { if (loginType == 1) {
request["sharedPatientID"] = 0; request.sharedPatientId = 0;
request["sharedPatientIdentificationID"] = nationalIDorFile; request.sharedPatientIdentificationId = nationalIDorFile;
} else if (loginType == 2) { } else if (loginType == 2) {
request["sharedPatientID"] = int.parse(nationalIDorFile); request.sharedPatientId = int.parse(nationalIDorFile);
request["sharedPatientIdentificationID"] = ''; request.sharedPatientIdentificationId = '';
} }
request["searchType"] = loginType; request.searchType = loginType;
request["sharedPatientMobileNumber"] = mobileNo; request.sharedPatientMobileNumber = mobileNo;
request["zipCode"] = countryCode; request.zipCode = countryCode;
request["isRegister"] = false; request.isRegister = false;
request["patientStatus"] = 2; request.patientStatus = 2;
request.isDentalAllowedBackend = false;
return request;
} }
} }

@ -17,12 +17,9 @@ abstract class AuthenticationRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> checkPatientAuthentication({required dynamic checkPatientAuthenticationReq}); Future<Either<Failure, GenericApiModel<dynamic>>> checkPatientAuthentication({required dynamic checkPatientAuthenticationReq});
Future<Either<Failure, GenericApiModel<dynamic>>> sendActivationCodeRepo({required dynamic sendActivationCodeReq, String? languageID, bool isRegister = 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 isExcludedUser = false});
{required dynamic newRequest, // could be CheckActivationCodeReq or CheckActivationCodeRegisterReq
required String? activationCode,
required bool isRegister});
Future<Either<Failure, GenericApiModel<dynamic>>> checkIfUserAgreed({required dynamic commonAuthanticatedRequest}); Future<Either<Failure, GenericApiModel<dynamic>>> checkIfUserAgreed({required dynamic commonAuthanticatedRequest});
@ -134,6 +131,7 @@ class AuthenticationRepoImp implements AuthenticationRepo {
required dynamic sendActivationCodeReq, required dynamic sendActivationCodeReq,
String? languageID, String? languageID,
bool isRegister = false, bool isRegister = false,
bool isFormFamilyFile = false,
}) async { }) async {
int isOutKsa = (sendActivationCodeReq.zipCode == '966' || sendActivationCodeReq.zipCode == '+966') ? 0 : 1; int isOutKsa = (sendActivationCodeReq.zipCode == '966' || sendActivationCodeReq.zipCode == '+966') ? 0 : 1;
sendActivationCodeReq.patientOutSA = isOutKsa; sendActivationCodeReq.patientOutSA = isOutKsa;
@ -144,7 +142,11 @@ class AuthenticationRepoImp implements AuthenticationRepo {
Failure? failure; Failure? failure;
await apiClient.post( await apiClient.post(
isRegister ? ApiConsts.sendActivationCodeRegister : ApiConsts.sendActivationCode, isFormFamilyFile
? ApiConsts.sendFamilyFileActivation
: isRegister
? ApiConsts.sendActivationCodeRegister
: ApiConsts.sendActivationCode,
body: sendActivationCodeReq.toJson(), body: sendActivationCodeReq.toJson(),
onFailure: (error, statusCode, {messageStatus, failureType}) { onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType; failure = failureType;
@ -176,6 +178,7 @@ class AuthenticationRepoImp implements AuthenticationRepo {
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 isExcludedUser = false,
}) async { }) async {
if (isRegister) { if (isRegister) {
newRequest["activationCode"] = activationCode ?? "0000"; newRequest["activationCode"] = activationCode ?? "0000";
@ -189,7 +192,11 @@ class AuthenticationRepoImp implements AuthenticationRepo {
newRequest.isRegister = false; newRequest.isRegister = false;
} }
final endpoint = isRegister ? ApiConsts.checkActivationCodeRegister : ApiConsts.checkActivationCode; final endpoint = isExcludedUser
? ApiConsts.checkActivationCodeForFamily
: isRegister
? ApiConsts.checkActivationCodeRegister
: ApiConsts.checkActivationCode;
try { try {
GenericApiModel<dynamic>? apiResponse; GenericApiModel<dynamic>? apiResponse;

@ -13,6 +13,7 @@ import 'package:hmg_patient_app_new/core/common_models/privilege/HMCProjectListM
import 'package:hmg_patient_app_new/core/common_models/privilege/PrivilegeModel.dart'; import 'package:hmg_patient_app_new/core/common_models/privilege/PrivilegeModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart'; import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/VidaPlusProjectListModel.dart'; import 'package:hmg_patient_app_new/core/common_models/privilege/VidaPlusProjectListModel.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/loading_utils.dart'; import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
import 'package:hmg_patient_app_new/core/utils/request_utils.dart'; import 'package:hmg_patient_app_new/core/utils/request_utils.dart';
@ -27,6 +28,7 @@ import 'package:hmg_patient_app_new/features/authentication/models/resp_models/a
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/check_activation_code_resp_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_user_staus_nhic_response_model.dart'; import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_user_staus_nhic_response_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/select_device_by_imei.dart'; import 'package:hmg_patient_app_new/features/authentication/models/resp_models/select_device_by_imei.dart';
import 'package:hmg_patient_app_new/features/medical_file/medical_file_repo.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/authentication/login.dart'; import 'package:hmg_patient_app_new/presentation/authentication/login.dart';
import 'package:hmg_patient_app_new/presentation/authentication/saved_login_screen.dart'; import 'package:hmg_patient_app_new/presentation/authentication/saved_login_screen.dart';
@ -345,7 +347,15 @@ class AuthenticationViewModel extends ChangeNotifier {
} }
Future<void> sendActivationCode( Future<void> sendActivationCode(
{required OTPTypeEnum otpTypeEnum, required String nationalIdOrFileNumber, required String phoneNumber, required bool isForRegister, dynamic payload, bool isComingFromResendOTP = false}) async { {required OTPTypeEnum otpTypeEnum,
required String nationalIdOrFileNumber,
required String phoneNumber,
required bool isForRegister,
dynamic payload,
bool isComingFromResendOTP = false,
bool isExcludedUser = false,
bool isFormFamilyFile = false,
int? responseID}) async {
var request = RequestUtils.getCommonRequestSendActivationCode( var request = RequestUtils.getCommonRequestSendActivationCode(
otpTypeEnum: otpTypeEnum, otpTypeEnum: otpTypeEnum,
mobileNumber: phoneNumber, mobileNumber: phoneNumber,
@ -361,7 +371,9 @@ class AuthenticationViewModel extends ChangeNotifier {
? false ? false
: true, : true,
payload: payload, payload: payload,
); isExcludedUser: isExcludedUser,
isFormFamilyFile: isFormFamilyFile,
responseID: responseID);
// TODO: GET APP SMS SIGNATURE HERE // TODO: GET APP SMS SIGNATURE HERE
request.sMSSignature = await getSignature(); request.sMSSignature = await getSignature();
@ -370,7 +382,8 @@ class AuthenticationViewModel extends ChangeNotifier {
_appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(payload); _appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(payload);
} }
final resultEither = await _authenticationRepo.sendActivationCodeRepo(sendActivationCodeReq: request, isRegister: checkIsUserComingForRegister(request: payload), languageID: 'er'); final resultEither =
await _authenticationRepo.sendActivationCodeRepo(sendActivationCodeReq: request, isRegister: checkIsUserComingForRegister(request: payload), languageID: 'er', isFormFamilyFile: isFormFamilyFile);
resultEither.fold( resultEither.fold(
(failure) async => await _errorHandlerService.handleError(failure: failure), (failure) async => await _errorHandlerService.handleError(failure: failure),
@ -385,7 +398,10 @@ class AuthenticationViewModel extends ChangeNotifier {
} else { } else {
if (apiResponse.data != null && apiResponse.data['isSMSSent'] == true) { if (apiResponse.data != null && apiResponse.data['isSMSSent'] == true) {
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
if (!isComingFromResendOTP) navigateToOTPScreen(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber, isComingFromRegister: checkIsUserComingForRegister(request: payload), payload: payload); if (!isComingFromResendOTP) {
navigateToOTPScreen(
otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber, isComingFromRegister: checkIsUserComingForRegister(request: payload), payload: payload, isExcludedUser: isExcludedUser);
}
} else { } else {
// TODO: Handle isSMSSent false // TODO: Handle isSMSSent false
// navigateToOTPScreen(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber); // navigateToOTPScreen(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber);
@ -404,7 +420,13 @@ class AuthenticationViewModel extends ChangeNotifier {
} }
Future<void> checkActivationCode( Future<void> checkActivationCode(
{required String? activationCode, required OTPTypeEnum otpTypeEnum, required Function(String? message) onWrongActivationCode, Function()? onResendActivation}) async { {required String? activationCode,
required OTPTypeEnum otpTypeEnum,
required Function(String? message) onWrongActivationCode,
Function()? onResendActivation,
bool isExcludedUser = false,
dynamic requestID,
dynamic responseID}) 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(
@ -430,6 +452,13 @@ class AuthenticationViewModel extends ChangeNotifier {
//TODO: Error Here IN Zip Code. //TODO: Error Here IN Zip Code.
loginType: loginTypeEnum.toInt) loginType: loginTypeEnum.toInt)
.toJson(); .toJson();
if (isExcludedUser) {
request['PatientShareRequestID'] = requestID;
request['ResponseID'] = responseID;
request['Status'] = 3;
}
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader();
if (isForRegister) { if (isForRegister) {
if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob; if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob;
@ -465,7 +494,8 @@ class AuthenticationViewModel extends ChangeNotifier {
} }
}); });
} else { } else {
final resultEither = await _authenticationRepo.checkActivationCodeRepo(newRequest: CheckActivationCodeRegisterReq.fromJson(request), activationCode: activationCode, isRegister: false); final resultEither = await _authenticationRepo.checkActivationCodeRepo(
newRequest: CheckActivationCodeRegisterReq.fromJson(request), activationCode: activationCode, isRegister: false, isExcludedUser: isExcludedUser);
resultEither.fold( resultEither.fold(
(failure) async => await _errorHandlerService.handleError( (failure) async => await _errorHandlerService.handleError(
@ -575,12 +605,13 @@ class AuthenticationViewModel extends ChangeNotifier {
_navigationService.pushAndReplace(AppRoutes.landingScreen); _navigationService.pushAndReplace(AppRoutes.landingScreen);
} }
Future<void> navigateToOTPScreen({required OTPTypeEnum otpTypeEnum, required String phoneNumber, required bool isComingFromRegister, dynamic payload}) async { Future<void> navigateToOTPScreen({required OTPTypeEnum otpTypeEnum, required String phoneNumber, required bool isComingFromRegister, dynamic payload, bool isExcludedUser = false}) async {
_navigationService.pushToOtpScreen( _navigationService.pushToOtpScreen(
phoneNumber: phoneNumber, phoneNumber: phoneNumber,
checkActivationCode: (int activationCode) async { checkActivationCode: (int activationCode) async {
await checkActivationCode( await checkActivationCode(
activationCode: activationCode.toString(), activationCode: activationCode.toString(),
isExcludedUser: isExcludedUser,
otpTypeEnum: otpTypeEnum, otpTypeEnum: otpTypeEnum,
onWrongActivationCode: (String? value) { onWrongActivationCode: (String? value) {
onWrongActivationCode(message: value); onWrongActivationCode(message: value);

@ -0,0 +1,57 @@
import 'dart:convert';
class FamilyFileRequest {
int? sharedPatientId;
String? sharedPatientIdentificationId;
int? searchType;
String? sharedPatientMobileNumber;
String? zipCode;
bool? isRegister;
int? patientStatus;
bool? isDentalAllowedBackend;
bool? isPatientExcluded;
int? responseID;
FamilyFileRequest({
this.sharedPatientId,
this.sharedPatientIdentificationId,
this.searchType,
this.sharedPatientMobileNumber,
this.zipCode,
this.isRegister,
this.patientStatus,
this.isDentalAllowedBackend,
this.isPatientExcluded,
this.responseID,
});
factory FamilyFileRequest.fromRawJson(String str) => FamilyFileRequest.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory FamilyFileRequest.fromJson(Map<String, dynamic> json) => FamilyFileRequest(
sharedPatientId: json["sharedPatientID"],
sharedPatientIdentificationId: json["sharedPatientIdentificationID"],
searchType: json["searchType"],
sharedPatientMobileNumber: json["sharedPatientMobileNumber"],
zipCode: json["zipCode"],
isRegister: json["isRegister"],
patientStatus: json["patientStatus"],
isDentalAllowedBackend: json["isDentalAllowedBackend"],
isPatientExcluded: json["IsPatientExcluded"],
responseID: json["ReponseID"],
);
Map<String, dynamic> toJson() => {
"SharedPatientID": sharedPatientId,
"SharedPatientIdentificationID": sharedPatientIdentificationId,
"SearchType": searchType,
"SharedPatientMobileNumber": sharedPatientMobileNumber,
"zipCode": zipCode,
"isRegister": isRegister,
"PatientStatus": patientStatus,
"isDentalAllowedBackend": isDentalAllowedBackend,
"IsPatientExcluded": isPatientExcluded,
"ReponseID": responseID,
};
}

@ -26,7 +26,7 @@ abstract class MedicalFileRepo {
Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getPatientFamilyFiles(); Future<Either<Failure, GenericApiModel<List<FamilyFileResponseModelLists>>>> getPatientFamilyFiles();
Future<Either<Failure, GenericApiModel<List<dynamic>>>> addFamilyFile({required dynamic request}); Future<Either<Failure, GenericApiModel<dynamic>>> addFamilyFile({required dynamic request});
} }
class MedicalFileRepoImp implements MedicalFileRepo { class MedicalFileRepoImp implements MedicalFileRepo {
@ -313,9 +313,9 @@ class MedicalFileRepoImp implements MedicalFileRepo {
} }
@override @override
Future<Either<Failure, GenericApiModel<List<dynamic>>>> addFamilyFile({dynamic request}) async { Future<Either<Failure, GenericApiModel<dynamic>>> addFamilyFile({dynamic request}) async {
try { try {
GenericApiModel<List<dynamic>>? apiResponse; GenericApiModel<dynamic>? apiResponse;
Failure? failure; Failure? failure;
await apiClient.post( await apiClient.post(
ApiConsts.addFamilyFile, ApiConsts.addFamilyFile,
@ -325,17 +325,12 @@ class MedicalFileRepoImp implements MedicalFileRepo {
}, },
onSuccess: (response, statusCode, {messageStatus, errorMessage}) { onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try { try {
print(response); apiResponse = GenericApiModel<dynamic>(
// final list = response['GetAllSharedRecordsByStatusList']; messageStatus: messageStatus,
// statusCode: statusCode,
// final familyLists = list.map((item) => FamilyFileResponseModelLists.fromJson(item as Map<String, dynamic>)).toList().cast<FamilyFileResponseModelLists>(); errorMessage: errorMessage,
// data: response["ShareFamilyFileObj"] ?? null,
// apiResponse = GenericApiModel<List<FamilyFileResponseModelLists>>( );
// messageStatus: messageStatus,
// statusCode: statusCode,
// errorMessage: null,
// data: familyLists,
// );
} catch (e) { } catch (e) {
failure = DataParsingFailure(e.toString()); failure = DataParsingFailure(e.toString());
} }

@ -1,8 +1,14 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/core/dependencies.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/core/utils/request_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart'; import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart';
import 'package:hmg_patient_app_new/features/common/models/family_file_request.dart';
import 'package:hmg_patient_app_new/features/medical_file/medical_file_repo.dart'; import 'package:hmg_patient_app_new/features/medical_file/medical_file_repo.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart'; import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/patient_medical_response_model.dart'; import 'package:hmg_patient_app_new/features/medical_file/models/patient_medical_response_model.dart';
@ -10,6 +16,7 @@ import 'package:hmg_patient_app_new/features/medical_file/models/patient_sicklea
import 'package:hmg_patient_app_new/features/medical_file/models/patient_vaccine_response_model.dart'; import 'package:hmg_patient_app_new/features/medical_file/models/patient_vaccine_response_model.dart';
import 'package:hmg_patient_app_new/services/dialog_service.dart'; import 'package:hmg_patient_app_new/services/dialog_service.dart';
import 'package:hmg_patient_app_new/services/error_handler_service.dart'; import 'package:hmg_patient_app_new/services/error_handler_service.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
class MedicalFileViewModel extends ChangeNotifier { class MedicalFileViewModel extends ChangeNotifier {
int selectedTabIndex = 0; int selectedTabIndex = 0;
@ -293,9 +300,36 @@ class MedicalFileViewModel extends ChangeNotifier {
); );
} }
Future<void> addFamilyFile() async { Future<void> addFamilyFile({required OTPTypeEnum otpTypeEnum, required bool isExcludedUser}) async {
final resultEither = await medicalFileRepo.addFamilyFile(request: {}); AuthenticationViewModel authVM = getIt.get<AuthenticationViewModel>();
resultEither.fold((failure) async => await errorHandlerService.handleError(failure: failure), (apiResponse) async {}); NavigationService navigationService = getIt.get<NavigationService>();
} FamilyFileRequest request =
await RequestUtils.getAddFamilyRequest(nationalIDorFile: authVM.nationalIdController.text, mobileNo: authVM.phoneNumberController.text, countryCode: authVM.selectedCountrySignup.countryCode);
final resultEither = await medicalFileRepo.addFamilyFile(request: request.toJson());
resultEither.fold((failure) async => await errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse != null && apiResponse.data != null) {
request.isPatientExcluded = apiResponse.data["IsPatientExcluded"];
request.responseID = apiResponse.data["ReponseID"];
_dialogService.showExceptionBottomSheet(
message: apiResponse.data['Message'],
onOkPressed: () {
print("=================== On Press Ok ==================");
authVM.sendActivationCode(
otpTypeEnum: otpTypeEnum,
nationalIdOrFileNumber: request.sharedPatientIdentificationId!,
phoneNumber: request.sharedPatientMobileNumber!,
isForRegister: false,
isExcludedUser: apiResponse.data['IsPatientExcluded'],
responseID: apiResponse.data["ReponseID"],
isFormFamilyFile: true);
// insertFamilyData(payload: apiResponse.data![0]['ShareFamilyFileObj'], isExcludedPatient: apiResponse.data![0]['ShareFamilyFileObj']['IsPatientExcluded']);
},
onCancelPressed: () {
navigationService.pop();
});
}
});
}
} }

@ -143,6 +143,13 @@ class _MedicalFilePageState extends State<MedicalFilePage> {
AppCustomChipWidget( AppCustomChipWidget(
icon: AppAssets.file_icon, icon: AppAssets.file_icon,
labelText: "${LocaleKeys.fileNo.tr(context: context)}: ${appState.getAuthenticatedUser()!.patientId}", labelText: "${LocaleKeys.fileNo.tr(context: context)}: ${appState.getAuthenticatedUser()!.patientId}",
onChipTap: () {
navigationService.pushPage(
page: FamilyMedicalScreen(
profiles: medicalFileViewModel.patientFamilyFiles,
onSelect: (FamilyFileResponseModelLists p1) {},
));
},
), ),
AppCustomChipWidget( AppCustomChipWidget(
icon: AppAssets.checkmark_icon, icon: AppAssets.checkmark_icon,
@ -769,9 +776,4 @@ class _MedicalFilePageState extends State<MedicalFilePage> {
return Container(); return Container();
} }
} }
getMember() {
// AuthanticationViewModel authanticationViewModel = getIt.get<AuthanticationViewModel>();
// RequestUtils.getAddFamilyRequest(nationalIDorFile: nationalIDorFile, mobileNo: mobileNo, countryCode: countryCode, loginType: loginType);
}
} }

@ -10,6 +10,7 @@ import 'package:hmg_patient_app_new/core/utils/validation_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart'; import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart'; import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/my_family/widget/family_cards.dart'; import 'package:hmg_patient_app_new/presentation/my_family/widget/family_cards.dart';
@ -27,10 +28,10 @@ class FamilyMedicalScreen extends StatefulWidget {
final Function(FamilyFileResponseModelLists) onSelect; final Function(FamilyFileResponseModelLists) onSelect;
const FamilyMedicalScreen({ const FamilyMedicalScreen({
Key? key, super.key,
required this.profiles, required this.profiles,
required this.onSelect, required this.onSelect,
}) : super(key: key); });
@override @override
State<FamilyMedicalScreen> createState() => _FamilyMedicalScreenState(); State<FamilyMedicalScreen> createState() => _FamilyMedicalScreenState();
@ -38,6 +39,13 @@ class FamilyMedicalScreen extends StatefulWidget {
class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> { class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
List<CustomTabBarModel> tabs = [CustomTabBarModel("", LocaleKeys.medicalFile.tr()), CustomTabBarModel("", LocaleKeys.request.tr())]; List<CustomTabBarModel> tabs = [CustomTabBarModel("", LocaleKeys.medicalFile.tr()), CustomTabBarModel("", LocaleKeys.request.tr())];
MedicalFileViewModel? medicalVM;
@override
void initState() {
super.initState();
medicalVM = getIt.get<MedicalFileViewModel>();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -89,9 +97,11 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
AuthenticationViewModel authVm = getIt.get<AuthenticationViewModel>(); AuthenticationViewModel authVm = getIt.get<AuthenticationViewModel>();
return showCommonBottomSheetWithoutHeight(context, return showCommonBottomSheetWithoutHeight(context,
title: "Add Family Member", title: "Add Family Member",
useSafeArea: true,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [ children: [
"Please fill the below field to add a new family member to your profile".toText16(color: AppColors.textColor, weight: FontWeight.w500), "Please fill the below field to add a new family member to your profile".toText16(color: AppColors.textColor, weight: FontWeight.w500),
SizedBox(height: 20.h), SizedBox(height: 20.h),
@ -104,10 +114,7 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
countryList: CountryEnum.values, countryList: CountryEnum.values,
onCountryChange: authVm.onCountryChange, onCountryChange: authVm.onCountryChange,
).paddingOnly(top: 8.h, bottom: 16.h), ).paddingOnly(top: 8.h, bottom: 16.h),
Divider( Divider(height: 1.h, color: AppColors.spacerLineColor),
height: 1.h,
color: AppColors.spacerLineColor,
),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.nationalIdNumber.tr(), labelText: LocaleKeys.nationalIdNumber.tr(),
hintText: "xxxxxxxxx", hintText: "xxxxxxxxx",
@ -123,13 +130,10 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
padding: EdgeInsets.symmetric(vertical: 8.h), padding: EdgeInsets.symmetric(vertical: 8.h),
leadingIcon: AppAssets.student_card, leadingIcon: AppAssets.student_card,
).paddingOnly(top: 8.h, bottom: 8.h), ).paddingOnly(top: 8.h, bottom: 8.h),
Divider( Divider(height: 1.h, color: AppColors.spacerLineColor),
height: 1.h,
color: AppColors.spacerLineColor,
),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.phoneNumber.tr(), labelText: LocaleKeys.phoneNumber.tr(),
hintText: "574345434", hintText: "",
controller: authVm.phoneNumberController, controller: authVm.phoneNumberController,
isEnable: true, isEnable: true,
prefix: authVm.selectedCountrySignup.countryCode, prefix: authVm.selectedCountrySignup.countryCode,
@ -140,35 +144,7 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
padding: EdgeInsets.symmetric(vertical: 8.h), padding: EdgeInsets.symmetric(vertical: 8.h),
leadingIcon: AppAssets.smart_phone, leadingIcon: AppAssets.smart_phone,
).paddingOnly(top: 8.h, bottom: 4), ).paddingOnly(top: 8.h, bottom: 4.h),
//TextInputWidget(
// labelText: widget.isForEmail ? LocaleKeys.email.tr() : LocaleKeys.phoneNumber.tr(),
// hintText: widget.isForEmail ? "demo@gmail.com" : "5xxxxxxxx",
// controller: widget.textController!,
// focusNode: _textFieldFocusNode,
// autoFocus: widget.autoFocus,
// padding: EdgeInsets.all(8.h),
// keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number,
// onChange: (value) {
// if (widget.onChange != null) {
// widget.onChange!(value);
// }
// },
// onCountryChange: (value) {
// if (widget.onCountryChange != null) {
// widget.onCountryChange!(value);
// }
// },
// isEnable: true,
// isReadOnly: widget.isFromSavedLogin,
// prefix: widget.isForEmail ? null : widget.countryCode,
// isBorderAllowed: false,
// isAllowLeadingIcon: true,
// fontSize: 13.h,
// isCountryDropDown: widget.isEnableCountryDropdown,
// leadingIcon: widget.isForEmail ? AppAssets.email : AppAssets.smart_phone,
// )
], ],
), ),
), ),
@ -184,7 +160,10 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
onOkPress: () { onOkPress: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
)) {} )) {
// authVm.addFamilyMember(otpTypeEnum: OTPTypeEnum.sms, isExcludedUser: true);
medicalVM?.addFamilyFile(otpTypeEnum: OTPTypeEnum.sms, isExcludedUser: true);
}
}, },
icon: AppAssets.add_icon, icon: AppAssets.add_icon,
height: 56.h, height: 56.h,

@ -73,9 +73,8 @@ class DialogServiceImp implements DialogService {
Future<void> showCommonBottomSheetWithoutH({String? label, required String message, required Function() onOkPressed, Function()? onCancelPressed}) async { Future<void> showCommonBottomSheetWithoutH({String? label, required String message, required Function() onOkPressed, Function()? onCancelPressed}) async {
final context = navigationService.navigatorKey.currentContext; final context = navigationService.navigatorKey.currentContext;
if (context == null) return; if (context == null) return;
showCommonBottomSheetWithoutHeight(context, title: label ?? "", child: exceptionBottomSheetWidget(context: context, message: message, onOkPressed: onOkPressed, onCancelPressed: onCancelPressed), showCommonBottomSheetWithoutHeight(context,
callBackFunc: () { title: label ?? "", child: exceptionBottomSheetWidget(context: context, message: message, onOkPressed: onOkPressed, onCancelPressed: onCancelPressed), callBackFunc: () {});
});
} }
@override @override

@ -24,6 +24,7 @@ class AppCustomChipWidget extends StatelessWidget {
this.deleteIconColor = AppColors.textColor, this.deleteIconColor = AppColors.textColor,
this.deleteIconHasColor = false, this.deleteIconHasColor = false,
this.padding = EdgeInsets.zero, this.padding = EdgeInsets.zero,
this.onChipTap
}); });
final String? labelText; final String? labelText;
@ -40,10 +41,13 @@ class AppCustomChipWidget extends StatelessWidget {
final bool deleteIconHasColor; final bool deleteIconHasColor;
final OutlinedBorder? shape; final OutlinedBorder? shape;
final EdgeInsets? padding; final EdgeInsets? padding;
final void Function()? onChipTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ChipTheme( return GestureDetector(
onTap: onChipTap,
child: ChipTheme(
data: ChipThemeData( data: ChipThemeData(
padding: EdgeInsets.all(0.0), padding: EdgeInsets.all(0.0),
shape: SmoothRectangleBorder( shape: SmoothRectangleBorder(
@ -108,6 +112,7 @@ class AppCustomChipWidget extends StatelessWidget {
: null, : null,
onDeleted: deleteIcon?.isNotEmpty == true ? () {} : null, onDeleted: deleteIcon?.isNotEmpty == true ? () {} : null,
), ),
),
); );
} }
} }

@ -113,46 +113,128 @@ void showCommonBottomSheetWithoutHeight(
bool isFullScreen = true, bool isFullScreen = true,
bool isDismissible = true, bool isDismissible = true,
Widget? titleWidget, Widget? titleWidget,
bool useSafeArea = false,
}) { }) {
showModalBottomSheet<String>( showModalBottomSheet<String>(
sheetAnimationStyle: AnimationStyle( sheetAnimationStyle: AnimationStyle(
duration: Duration(milliseconds: 500), // Custom animation duration duration: Duration(milliseconds: 500),
reverseDuration: Duration(milliseconds: 300), // Custom reverse animation duration reverseDuration: Duration(milliseconds: 300),
), ),
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
showDragHandle: false, showDragHandle: false,
isDismissible: isDismissible, isDismissible: isDismissible,
backgroundColor: AppColors.bottomSheetBgColor, backgroundColor: AppColors.bottomSheetBgColor,
useSafeArea: useSafeArea,
builder: (BuildContext context) { builder: (BuildContext context) {
return SafeArea( return SafeArea(
top: false, top: false,
left: false, left: false,
right: false, right: false,
child: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: SingleChildScrollView(
physics: ClampingScrollPhysics(),
child: isCloseButtonVisible child: isCloseButtonVisible
? Container( ? Container(
padding: EdgeInsets.only(left: 24, top: 24, right: 24, bottom: 12), padding: EdgeInsets.only(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.bottomSheetBgColor, borderRadius: 24.h), left: 24,
top: 24,
right: 24,
bottom: 12,
),
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.bottomSheetBgColor,
borderRadius: 24.h,
),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
spacing: 16.h,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
titleWidget ?? Expanded(child: title.toText20(weight: FontWeight.w600)), titleWidget ??
Utils.buildSvgWithAssets(icon: AppAssets.close_bottom_sheet_icon, iconColor: Color(0xff2B353E)).onPress(() { Expanded(
child: title.toText20(weight: FontWeight.w600),
),
Utils.buildSvgWithAssets(
icon: AppAssets.close_bottom_sheet_icon,
iconColor: Color(0xff2B353E),
).onPress(() {
Navigator.of(context).pop(); Navigator.of(context).pop();
}), }),
], ],
), ),
SizedBox(height: 16.h),
child, child,
], ],
)) ),
)
: child, : child,
),
),
); );
}).then((value) { },
).then((value) {
callBackFunc(); callBackFunc();
}); });
} }
// void showCommonBottomSheetWithoutHeight(
// BuildContext context, {
// required Widget child,
// required VoidCallback callBackFunc,
// String title = "",
// bool isCloseButtonVisible = true,
// bool isFullScreen = true,
// bool isDismissible = true,
// Widget? titleWidget,
// bool useSafeArea = false,
//
// }) {
// showModalBottomSheet<String>(
// sheetAnimationStyle: AnimationStyle(
// duration: Duration(milliseconds: 500), // Custom animation duration
// reverseDuration: Duration(milliseconds: 300), // Custom reverse animation duration
// ),
// context: context,
// isScrollControlled: true,
// showDragHandle: false,
// isDismissible: isDismissible,
// backgroundColor: AppColors.bottomSheetBgColor,
// useSafeArea: useSafeArea,
// builder: (BuildContext context) {
// return SafeArea(
// top: false,
// left: false,
// right: false,
// child: isCloseButtonVisible
// ? Container(
// padding: EdgeInsets.only(left: 24, top: 24, right: 24, bottom: 12),
// decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.bottomSheetBgColor, borderRadius: 24.h),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// spacing: 16.h,
// children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// titleWidget ?? Expanded(child: title.toText20(weight: FontWeight.w600)),
// Utils.buildSvgWithAssets(icon: AppAssets.close_bottom_sheet_icon, iconColor: Color(0xff2B353E)).onPress(() {
// Navigator.of(context).pop();
// }),
// ],
// ),
// child,
// ],
// ))
// : child,
// );
// }).then((value) {
// callBackFunc();
// });
// }

Loading…
Cancel
Save