finish confirmation page

merge-requests/879/head
Elham Rababh 4 years ago
parent 5567b31daf
commit cf498de70f

@ -27,7 +27,7 @@ class BaseAppClient {
Function(String error, int statusCode) onFailure,
bool isAllowAny = false,
bool isLiveCare = false,
bool isFallLanguage=false}) async {
bool isFallLanguage = false}) async {
String url;
if (isLiveCare)
url = BASE_URL_LIVE_CARE + endPoint;
@ -40,14 +40,17 @@ class BaseAppClient {
String token = await sharedPref.getString(TOKEN);
if (profile != null) {
DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile);
if (body['DoctorID'] == null) body['DoctorID'] = doctorProfile?.doctorID;
if (body['DoctorID'] == null)
body['DoctorID'] = doctorProfile?.doctorID;
if (body['DoctorID'] == "") body['DoctorID'] = null;
if (body['EditedBy'] == null) body['EditedBy'] = doctorProfile?.doctorID;
if (body['EditedBy'] == null)
body['EditedBy'] = doctorProfile?.doctorID;
if (body['ProjectID'] == null) {
body['ProjectID'] = doctorProfile?.projectID;
}
if (body['ClinicID'] == null) body['ClinicID'] = doctorProfile?.clinicID;
if (body['ClinicID'] == null)
body['ClinicID'] = doctorProfile?.clinicID;
}
if (body['DoctorID'] == '') {
body['DoctorID'] = null;
@ -59,7 +62,7 @@ class BaseAppClient {
body['TokenID'] = token ?? '';
}
// body['TokenID'] = "@dm!n" ?? '';
if(!isFallLanguage) {
if (!isFallLanguage) {
String lang = await sharedPref.getString(APP_Language);
if (lang != null && lang == 'ar')
body['LanguageID'] = 1;
@ -69,22 +72,29 @@ class BaseAppClient {
body['stamp'] = DateTime.now().toIso8601String();
// if(!body.containsKey("IPAdress"))
body['IPAdress'] = IP_ADDRESS;
body['VersionID'] = VERSION_ID;
body['Channel'] = CHANNEL;
if (body['VersionID'] == null) {
body['VersionID'] = VERSION_ID;
}
if (body['Channel'] == null) {
body['Channel'] = CHANNEL;
}
body['SessionID'] = SESSION_ID;
body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP;
body['PatientOutSA'] = body['PatientOutSA'] ?? 0; // PATIENT_OUT_SA;
if (body['VidaAuthTokenID'] == null) {
body['VidaAuthTokenID'] = await sharedPref.getString(VIDA_AUTH_TOKEN_ID);
body['VidaAuthTokenID'] =
await sharedPref.getString(VIDA_AUTH_TOKEN_ID);
}
if (body['VidaRefreshTokenID'] == null) {
body['VidaRefreshTokenID'] = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID);
body['VidaRefreshTokenID'] =
await sharedPref.getString(VIDA_REFRESH_TOKEN_ID);
}
int projectID = await sharedPref.getInt(PROJECT_ID);
if (projectID == 2 || projectID == 3)
body['PatientOutSA'] = true;
else if ((body.containsKey('facilityId') && body['facilityId'] == 2 || body['facilityId'] == 3) ||
else if ((body.containsKey('facilityId') && body['facilityId'] == 2 ||
body['facilityId'] == 3) ||
body['ProjectID'] == 2 ||
body['ProjectID'] == 3)
body['PatientOutSA'] = true;
@ -98,21 +108,28 @@ class BaseAppClient {
var asd2;
if (await Helpers.checkConnection()) {
final response = await http.post(url,
body: json.encode(body), headers: {'Content-Type': 'application/json', 'Accept': 'application/json'});
body: json.encode(body),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
});
final int statusCode = response.statusCode;
if (statusCode < 200 || statusCode >= 400) {
onFailure(Helpers.generateContactAdminMsg(), statusCode);
} else {
var parsed = json.decode(response.body.toString());
if (parsed['ErrorType'] == 4) {
helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], parsed['AndroidLink'], parsed['IOSLink']);
helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'],
parsed['AndroidLink'], parsed['IOSLink']);
}
if (parsed['IsAuthenticated'] != null && !parsed['IsAuthenticated']) {
if (body['OTP_SendType'] != null) {
onFailure(getError(parsed), statusCode);
} else if (!isAllowAny) {
await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX, listen: false).logout();
await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX,
listen: false)
.logout();
Helpers.showErrorToast('Your session expired Please login again');
locator<NavigationService>().pushNamedAndRemoveUntil(ROOT);
@ -147,10 +164,14 @@ class BaseAppClient {
String url = BASE_URL + endPoint;
try {
Map<String, String> headers = {'Content-Type': 'application/json', 'Accept': 'application/json'};
Map<String, String> headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
};
String token = await sharedPref.getString(TOKEN);
var languageID = await sharedPref.getStringWithDefaultValue(APP_Language, 'en');
var languageID =
await sharedPref.getStringWithDefaultValue(APP_Language, 'en');
body['SetupID'] = body.containsKey('SetupID')
? body['SetupID'] != null
? body['SetupID']
@ -170,11 +191,12 @@ class BaseAppClient {
: PATIENT_OUT_SA_PATIENT_REQ;
if (body.containsKey('isDentalAllowedBackend')) {
body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend')
? body['isDentalAllowedBackend'] != null
? body['isDentalAllowedBackend']
: IS_DENTAL_ALLOWED_BACKEND
: IS_DENTAL_ALLOWED_BACKEND;
body['isDentalAllowedBackend'] =
body.containsKey('isDentalAllowedBackend')
? body['isDentalAllowedBackend'] != null
? body['isDentalAllowedBackend']
: IS_DENTAL_ALLOWED_BACKEND
: IS_DENTAL_ALLOWED_BACKEND;
}
body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2;
@ -196,7 +218,9 @@ class BaseAppClient {
: PATIENT_TYPE_ID;
body['TokenID'] = body.containsKey('TokenID') ? body['TokenID'] : token;
body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : patient.patientId ?? patient.patientMRN;
body['PatientID'] = body['PatientID'] != null
? body['PatientID']
: patient.patientId ?? patient.patientMRN;
body['PatientOutSA'] = 0; //user['OutSA']; //TODO change it
body['SessionID'] = SESSION_ID; //getSe
@ -209,9 +233,11 @@ class BaseAppClient {
print("URL : $url");
print("Body : ${json.encode(body)}");
var asd = json.encode(body);
var asd2;
if (await Helpers.checkConnection()) {
final response = await http.post(url.trim(), body: json.encode(body), headers: headers);
final response = await http.post(url.trim(),
body: json.encode(body), headers: headers);
final int statusCode = response.statusCode;
print("statusCode :$statusCode");
if (statusCode < 200 || statusCode >= 400 || json == null) {
@ -223,7 +249,8 @@ class BaseAppClient {
onSuccess(parsed, statusCode);
} else {
if (parsed['ErrorType'] == 4) {
helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], parsed['AndroidLink'], parsed['IOSLink']);
helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'],
parsed['AndroidLink'], parsed['IOSLink']);
}
if (parsed['IsAuthenticated'] == null) {
if (parsed['isSMSSent'] == true) {
@ -239,20 +266,28 @@ class BaseAppClient {
onFailure(getError(parsed), statusCode);
}
}
} else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) {
} else if (parsed['MessageStatus'] == 1 ||
parsed['SMSLoginRequired'] == true) {
onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) {
} else if (parsed['MessageStatus'] == 2 &&
parsed['IsAuthenticated']) {
if (parsed['SameClinicApptList'] != null) {
onSuccess(parsed, statusCode);
} else {
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) {
if (parsed['message'] == null &&
parsed['ErrorEndUserMessage'] == null) {
if (parsed['ErrorSearchMsg'] == null) {
onFailure("Server Error found with no available message", statusCode);
onFailure("Server Error found with no available message",
statusCode);
} else {
onFailure(parsed['ErrorSearchMsg'], statusCode);
}
} else {
onFailure(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
onFailure(
parsed['message'] ??
parsed['ErrorEndUserMessage'] ??
parsed['ErrorMessage'],
statusCode);
}
}
} else {
@ -262,7 +297,9 @@ class BaseAppClient {
if (parsed['message'] != null) {
onFailure(parsed['message'] ?? parsed['message'], statusCode);
} else {
onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
onFailure(
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode);
}
}
}
@ -285,8 +322,12 @@ class BaseAppClient {
if (parsed["ValidationErrors"]["ValidationErrors"] != null &&
parsed["ValidationErrors"]["ValidationErrors"].length != 0) {
for (var i = 0; i < parsed["ValidationErrors"]["ValidationErrors"].length; i++) {
error = error + parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] + "\n";
for (var i = 0;
i < parsed["ValidationErrors"]["ValidationErrors"].length;
i++) {
error = error +
parsed["ValidationErrors"]["ValidationErrors"][i]["Messages"][0] +
"\n";
}
}
}

@ -373,8 +373,8 @@ const GET_ADMISSION_ORDERS =
///Patient Registration Services
const CHECK_PATIENT_FOR_REGISTRATION =
"Services/Authentication.svc/REST/CheckPatientForRegisteration";
const SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE =
"Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType";
const SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE_FOR_REGISTRATION =
"Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationTypeForRegistration";
const CHECK_ACTIVATION_CODE_FOR_PATIENT =
"Services/Authentication.svc/REST/CheckActivationCode";
const PATIENT_REGISTRATION = "Services/Authentication.svc/REST/PatientRegistration";

@ -16,7 +16,7 @@ class SendActivationCodeByOTPNotificationTypeForRegistrationModel {
int channel;
String iPAdress;
String generalid;
bool patientOutSA;
int patientOutSA;
Null sessionID;
bool isDentalAllowedBackend;
int deviceTypeID;
@ -26,29 +26,29 @@ class SendActivationCodeByOTPNotificationTypeForRegistrationModel {
SendActivationCodeByOTPNotificationTypeForRegistrationModel(
{this.patientMobileNumber,
this.mobileNo,
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.dOB,
this.isHijri,
this.healthId});
this.mobileNo,
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.dOB,
this.isHijri,
this.healthId});
SendActivationCodeByOTPNotificationTypeForRegistrationModel.fromJson(
Map<String, dynamic> json) {

@ -10,13 +10,16 @@ import 'package:doctor_app_flutter/core/viewModel/PatientRegistrationViewModel.d
class PatientRegistrationService extends BaseService {
GetPatientInfoResponseModel getPatientInfoResponseModel;
String logInTokenID;
checkPatientForRegistration(
CheckPatientForRegistrationModel registrationModel) async {
hasError = false;
await baseAppClient.post(CHECK_PATIENT_FOR_REGISTRATION,
onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
onSuccess: (dynamic response, int statusCode) {
//TODO Elham* fix it
logInTokenID = "OjEi/qgRekGICZm5/a4jbQ=="; //response["LogInTokenID"];
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: registrationModel.toJson());
@ -39,24 +42,39 @@ class PatientRegistrationService extends BaseService {
{SendActivationCodeByOTPNotificationTypeForRegistrationModel
registrationModel,
int otpType,
PatientRegistrationViewModel user,
PatientRegistrationViewModel model,
CheckPatientForRegistrationModel
checkPatientForRegistrationModel}) async {
registrationModel =
SendActivationCodeByOTPNotificationTypeForRegistrationModel(
oTPSendType: otpType,
patientIdentificationID:
checkPatientForRegistrationModel.patientIdentificationID,
patientMobileNumber: checkPatientForRegistrationModel.patientMobileNumber,
zipCode: checkPatientForRegistrationModel.zipCode,
patientOutSA: false,
healthId: "30000018540264",
dOB: checkPatientForRegistrationModel.dOB,
isRegister: checkPatientForRegistrationModel.isRegister,
isHijri: checkPatientForRegistrationModel.isHijri,
);
oTPSendType: otpType,
patientIdentificationID: checkPatientForRegistrationModel
.patientIdentificationID,
patientMobileNumber: checkPatientForRegistrationModel
.patientMobileNumber,
zipCode: checkPatientForRegistrationModel.zipCode,
patientOutSA: 0,
healthId: model.getPatientInfoResponseModel.healthId,
dOB: checkPatientForRegistrationModel.dOB,
isRegister: checkPatientForRegistrationModel.isRegister,
isHijri: checkPatientForRegistrationModel.isHijri,
sessionID: null,
generalid: GENERAL_ID,
isDentalAllowedBackend: false,
projectOutSA: 0,
searchType: 1,
versionID: 7.1,
channel: 3,
nationalID:
model.checkPatientForRegistrationModel.patientIdentificationID,
patientID: 0,
mobileNo: model.checkPatientForRegistrationModel.patientMobileNumber
.toString(),
loginType: otpType,
logInTokenID: logInTokenID);
hasError = false;
await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE,
await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE_FOR_REGISTRATION,
onSuccess: (dynamic response, int statusCode) {
registrationModel =
SendActivationCodeByOTPNotificationTypeForRegistrationModel.fromJson(

@ -399,7 +399,8 @@ class _HomeScreenState extends State<HomeScreen> {
patientCards.add(HomePatientCard(
backgroundColor: backgroundColors[colorIndex],
backgroundIconColor: backgroundIconColors[colorIndex],
cardIconImage: 'assets/images/patient_register.png',
//TODO Elham* match the of the icon
cardIcon: DoctorApp.arrival_patients,
textColor: textColors[colorIndex],
text: TranslationBase.of(context).registerNewPatient,
onTap: () {

@ -39,12 +39,12 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
bool isSubmitted = false;
TextEditingController _phoneController = TextEditingController();
TextEditingController _phoneController = TextEditingController(text: "508079569");
TextEditingController _phoneCode = TextEditingController(text: "966");
String phoneError;
TextEditingController _idController = TextEditingController();
TextEditingController _idController = TextEditingController(text: "1062938285");
String idError;
DateTime _birthDate;
@ -292,7 +292,7 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
isFormValid() {
if(_phoneController.text!=null &&_phoneController.text.isNotEmpty&& _idController.text!=null &&_idController.text.isNotEmpty) {
if(_phoneController.text!=null &&_phoneController.text.isNotEmpty&& _idController.text!=null &&_idController.text.isNotEmpty &&_birthDate!=null) {
return true;
}
return false;

@ -1,7 +1,9 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/PatientRegistration/CheckPatientForRegistrationModel.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientRegistrationViewModel.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
@ -13,6 +15,7 @@ import 'package:hexcolor/hexcolor.dart';
class ActivationPage extends StatefulWidget {
final PatientRegistrationViewModel model;
final Function changePageViewIndex;
ActivationPage({this.model, this.changePageViewIndex});
@override
@ -22,6 +25,7 @@ class ActivationPage extends StatefulWidget {
class _ActivationPageState extends State<ActivationPage> {
bool isSendOtp = false;
final verifyAccountForm = GlobalKey<FormState>();
TextStyle buildTextStyle() {
return TextStyle(
fontSize: SizeConfig.textMultiplier * 3,
@ -74,13 +78,14 @@ class _ActivationPageState extends State<ActivationPage> {
Expanded(
child: InkWell(
onTap: () async {
setState(() {
isSendOtp = true;
});
await widget.model
.sendActivationCodeByOTPNotificationType(
otpType: 1);
// setState(() {
// isSendOtp = true;
// });
//
// await widget.model
// .sendActivationCodeByOTPNotificationType(
// otpType: 1);
await sendActivationCode(1);
},
child: Container(
height:
@ -130,10 +135,7 @@ class _ActivationPageState extends State<ActivationPage> {
Expanded(
child: InkWell(
onTap: () async {
isSendOtp = false;
await widget.model
.sendActivationCodeByOTPNotificationType(
otpType: 1, user: widget.model);
await sendActivationCode(2);
},
child: Container(
height:
@ -442,7 +444,17 @@ class _ActivationPageState extends State<ActivationPage> {
fontColor: Colors.white,
fontSize: 2.0,
onPressed: () async {
//widget.model.checkActivationCode(),
GifLoaderDialogUtils.showMyDialog(context);
await widget.model.checkActivationCode("${digit1.text}${digit2.text}${digit3.text}${digit4.text}");
if (widget.model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(widget.model.error);
//TODO Elham* remove this
widget.changePageViewIndex(2);
GifLoaderDialogUtils.hideDialog(context);
} else {
GifLoaderDialogUtils.hideDialog(context);
widget.changePageViewIndex(2);
}
},
),
),
@ -453,6 +465,21 @@ class _ActivationPageState extends State<ActivationPage> {
: null);
}
sendActivationCode(type) async {
GifLoaderDialogUtils.showMyDialog(context);
await widget.model.sendActivationCodeByOTPNotificationType(otpType: type);
if (widget.model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(widget.model.error);
GifLoaderDialogUtils.hideDialog(context);
// TODO Elham* retuen the else
// } else {
setState(() {
isSendOtp = true;
});
}
}
InputDecoration buildInputDecoration(BuildContext context) {
return InputDecoration(
counterText: " ",

Loading…
Cancel
Save