|
|
|
|
@ -4,7 +4,10 @@ import 'package:hmg_patient_app/config/size_config.dart';
|
|
|
|
|
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/check_activation_code_response.dart';
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/check_paitent_authentication_req.dart';
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/check_user_status_reponse.dart';
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/check_user_status_req.dart';
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/checkpatient_for_registration.dart';
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/register_info_response.dart';
|
|
|
|
|
import 'package:hmg_patient_app/new_ui/otp/otp_validation_bootmsheet_widget.dart';
|
|
|
|
|
import 'package:hmg_patient_app/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart';
|
|
|
|
|
import 'package:hmg_patient_app/pages/login/login-type.dart';
|
|
|
|
|
@ -57,7 +60,8 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
late bool isLoading;
|
|
|
|
|
int _currentIndex = 0;
|
|
|
|
|
String? LoginTokenID;
|
|
|
|
|
|
|
|
|
|
bool isDubai =false;
|
|
|
|
|
final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy');
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
@ -521,7 +525,6 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startRegistration(type) {
|
|
|
|
|
final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy');
|
|
|
|
|
// if (isButtonDisabled == false) {
|
|
|
|
|
var request = CheckPatientForRegistration();
|
|
|
|
|
|
|
|
|
|
@ -576,8 +579,22 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
cancelFunction: () {})
|
|
|
|
|
.showAlertDialog(context);
|
|
|
|
|
} else {
|
|
|
|
|
sendActivationCode(type, nRequest['LogInTokenID']);
|
|
|
|
|
final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy');
|
|
|
|
|
nRequest['forRegister'] = true;
|
|
|
|
|
nRequest['isRegister'] = true;
|
|
|
|
|
nRequest["PatientIdentificationID"] = nRequest["PatientIdentificationID"].toString();
|
|
|
|
|
request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
|
nRequest['isHijri'] = isHijri;
|
|
|
|
|
sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, nRequest);
|
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, response['LogInTokenID']);
|
|
|
|
|
if (request.patientOutSA == 0) {
|
|
|
|
|
this.chekUserData(response['LogInTokenID'], type); // ظ ;
|
|
|
|
|
} else {
|
|
|
|
|
//Dubai registration page should be navigate from here..
|
|
|
|
|
|
|
|
|
|
// Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true, isDubai: true)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// if (response['ErrorCode'] == '-986') {
|
|
|
|
|
//AppToast.showErrorToast(message: response);
|
|
|
|
|
@ -593,12 +610,49 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendActivationCode(type, loginTokenID) async {
|
|
|
|
|
chekUserData(loginToken, int type) {
|
|
|
|
|
// let m = hijri(this.dateOfBirth).locale('en');
|
|
|
|
|
// // const dateHijri = m.format('iDD/iMM/iYYYY');
|
|
|
|
|
// const request = {
|
|
|
|
|
// PatientIdentificationID: this.id.toString(),
|
|
|
|
|
// // TokenID: token,
|
|
|
|
|
// DOB: this.dateOption === '1' ? this.dateOfBirth : moment(this.dateOfBirth).format('DD/MM/YYYY'),
|
|
|
|
|
// IsHijri: Number(this.dateOption)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
var request = CheckUserStatusRequest();
|
|
|
|
|
request.patientIdentificationID = nationalIDorFile.text;
|
|
|
|
|
request.dOB = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
|
request.isHijri = isHijri;
|
|
|
|
|
request.patientOutSA = countryCode == '966' ? 0 : 1;
|
|
|
|
|
this.authService.checkUserStatus(request).then((result) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (result is Map)
|
|
|
|
|
{
|
|
|
|
|
result = CheckUserStatusResponse.fromJson(result as Map<String, dynamic>);
|
|
|
|
|
sharedPref.setObject(NHIC_DATA, result);
|
|
|
|
|
// widget.changePageViewIndex!(1),
|
|
|
|
|
// Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true))),
|
|
|
|
|
RegisterInfoResponse resultSet = RegisterInfoResponse.fromJson(result);
|
|
|
|
|
sendActivationCode(type,loginToken, result);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AppToast.showErrorToast(message: result != null ? result : TranslationBase.of(context).somethingWentWrong);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sendActivationCode(type, loginTokenID, RegisterInfoResponse nHICData) async {
|
|
|
|
|
|
|
|
|
|
LoginTokenID = loginTokenID;
|
|
|
|
|
var request = authService.getCommonRequest(
|
|
|
|
|
registerd_data: null,
|
|
|
|
|
deviceToken: null,
|
|
|
|
|
mobileNumber: mobileNo,
|
|
|
|
|
mobileNumber: int.parse(mobileNo),
|
|
|
|
|
zipCode: selectedCountry.countryCode,
|
|
|
|
|
patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1,
|
|
|
|
|
loginTokenID: LoginTokenID,
|
|
|
|
|
@ -608,10 +662,11 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
// 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;
|
|
|
|
|
if (!isDubai) {
|
|
|
|
|
// request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob));
|
|
|
|
|
request.dob = nHICData.isHijri ==true ? nHICData.dateOfBirth: dateFormat.format(dateFormat.parse(nHICData.dateOfBirth!));
|
|
|
|
|
}
|
|
|
|
|
request.healthId = nHICData.healthId;
|
|
|
|
|
request.isHijri = isHijri;
|
|
|
|
|
await this.authService.sendActivationCodeRegister(request).then((result) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
@ -651,8 +706,11 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
if (result is Map)
|
|
|
|
|
{
|
|
|
|
|
result = CheckActivationCode.fromJson(result as Map<String, dynamic>),
|
|
|
|
|
// if (this.registerd_data != null && this.registerd_data.isRegister == true)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//next registration page navigate from here.
|
|
|
|
|
Navigator.of(context).push(FadePage(page: RegisterNewStep2()))
|
|
|
|
|
|
|
|
|
|
// // if(widget.isDubai ==false){
|
|
|
|
|
// // widget.changePageViewIndex!(1),
|
|
|
|
|
// // if(widget.isDubai ==false){
|
|
|
|
|
|