From 1a35201f276b4b74ace29856bd089effa0a40e3c Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 2 Nov 2021 16:41:42 +0200 Subject: [PATCH 1/8] regstration activtion code --- ...PNotificationTypeForRegistrationModel.dart | 48 +++--- .../service/PatientRegistrationService.dart | 23 ++- .../PatientRegistrationViewModel.dart | 9 +- .../register_patient/RegisterPatientPage.dart | 3 +- .../VerifyActivationCodePage.dart | 48 ++++++ .../register_patient/VerifyMethodPage.dart | 147 ++++++++++++++++++ 6 files changed, 245 insertions(+), 33 deletions(-) create mode 100644 lib/screens/patients/register_patient/VerifyActivationCodePage.dart create mode 100644 lib/screens/patients/register_patient/VerifyMethodPage.dart diff --git a/lib/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart b/lib/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart index 8244a95f..8aaf2c6c 100644 --- a/lib/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart +++ b/lib/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart @@ -16,7 +16,7 @@ class SendActivationCodeByOTPNotificationTypeForRegistrationModel { int channel; String iPAdress; String generalid; - int patientOutSA; + bool 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 json) { diff --git a/lib/core/service/PatientRegistrationService.dart b/lib/core/service/PatientRegistrationService.dart index fefa9021..4f084142 100644 --- a/lib/core/service/PatientRegistrationService.dart +++ b/lib/core/service/PatientRegistrationService.dart @@ -18,12 +18,27 @@ class PatientRegistrationService extends BaseService { } sendActivationCodeByOTPNotificationType( - SendActivationCodeByOTPNotificationTypeForRegistrationModel - registrationModel) async { + {SendActivationCodeByOTPNotificationTypeForRegistrationModel + registrationModel, + int otpType}) async { + registrationModel = + SendActivationCodeByOTPNotificationTypeForRegistrationModel( + oTPSendType: otpType, + patientIdentificationID: 1062938285, + patientMobileNumber: 785228065, + zipCode: "966", + patientOutSA: false, + mobileNo: "785228065", + healthId: "30000018540264", + dOB: "31/07/1988", + ); hasError = false; await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE, - onSuccess: (dynamic response, int statusCode) {}, - onFailure: (String error, int statusCode) { + onSuccess: (dynamic response, int statusCode) { + registrationModel = + SendActivationCodeByOTPNotificationTypeForRegistrationModel.fromJson( + response); + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: registrationModel.toJson()); diff --git a/lib/core/viewModel/PatientRegistrationViewModel.dart b/lib/core/viewModel/PatientRegistrationViewModel.dart index 6dddffcd..416925bb 100644 --- a/lib/core/viewModel/PatientRegistrationViewModel.dart +++ b/lib/core/viewModel/PatientRegistrationViewModel.dart @@ -25,11 +25,12 @@ class PatientRegistrationViewModel extends BaseViewModel { } Future sendActivationCodeByOTPNotificationType( - SendActivationCodeByOTPNotificationTypeForRegistrationModel - registrationModel) async { + {SendActivationCodeByOTPNotificationTypeForRegistrationModel + registrationModel, + int otpType}) async { setState(ViewState.Busy); - await _patientRegistrationService - .sendActivationCodeByOTPNotificationType(registrationModel); + await _patientRegistrationService.sendActivationCodeByOTPNotificationType( + otpType: otpType); if (_patientRegistrationService.hasError) { error = _patientRegistrationService.error; setState(ViewState.Error); diff --git a/lib/screens/patients/register_patient/RegisterPatientPage.dart b/lib/screens/patients/register_patient/RegisterPatientPage.dart index 85e46185..daef5eda 100644 --- a/lib/screens/patients/register_patient/RegisterPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterPatientPage.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; import 'package:doctor_app_flutter/screens/patients/profile/UCAF/page-stepper-widget.dart'; import 'package:doctor_app_flutter/screens/patients/register_patient/RegisterConfirmationPatientPage.dart'; +import 'package:doctor_app_flutter/screens/patients/register_patient/VerifyMethodPage.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/buttons/app_buttons_widget.dart'; @@ -99,8 +100,8 @@ class _RegisterPatientPageState extends State scrollDirection: Axis.horizontal, children: [ RegisterSearchPatientPage(), + ActivationPage(), RegisterConfirmationPatientPage(), - ]), ), ), diff --git a/lib/screens/patients/register_patient/VerifyActivationCodePage.dart b/lib/screens/patients/register_patient/VerifyActivationCodePage.dart new file mode 100644 index 00000000..d58e5a3b --- /dev/null +++ b/lib/screens/patients/register_patient/VerifyActivationCodePage.dart @@ -0,0 +1,48 @@ +import 'package:doctor_app_flutter/config/size_config.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/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; + +class VerifyActivationCodePage extends StatefulWidget { + const VerifyActivationCodePage({Key key}) : super(key: key); + + @override + _VerifyActivationCodePageState createState() => + _VerifyActivationCodePageState(); +} + +class _VerifyActivationCodePageState extends State { + @override + Widget build(BuildContext context) { + return BaseView( + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: Column( + children: [ + Container( + width: double.infinity, + margin: EdgeInsets.all(16.0), + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "Please enter the verification code sent to 02221552", + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 2.2, + fontWeight: FontWeight.w800, + ), + ], + ), + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/screens/patients/register_patient/VerifyMethodPage.dart b/lib/screens/patients/register_patient/VerifyMethodPage.dart new file mode 100644 index 00000000..885b2701 --- /dev/null +++ b/lib/screens/patients/register_patient/VerifyMethodPage.dart @@ -0,0 +1,147 @@ +import 'package:doctor_app_flutter/config/size_config.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/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class ActivationPage extends StatefulWidget { + const ActivationPage({Key key}) : super(key: key); + + @override + _ActivationPageState createState() => _ActivationPageState(); +} + +class _ActivationPageState extends State { + @override + Widget build(BuildContext context) { + return BaseView( + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: Column( + children: [ + Container( + width: double.infinity, + margin: EdgeInsets.all(16.0), + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "Please select how you want to be verified", + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 2.2, + fontWeight: FontWeight.w800, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: InkWell( + onTap: () { + model.sendActivationCodeByOTPNotificationType( + otpType: 1); + }, + child: Container( + height: + MediaQuery.of(context).size.height * 0.233, + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10), + ), + border: Border.all( + color: HexColor('#707070'), width: 0.1), + ), + child: Column( + children: [ + Row( + children: [ + Image.asset( + "assets/images/verify-sms.png", + height: + MediaQuery.of(context).size.height * + 0.15, + width: + MediaQuery.of(context).size.width * + 0.15, + ), + ], + ), + SizedBox( + height: 20, + ), + AppText( + "Verify through SMS", + fontSize: 14, + color: Color(0xFF2E303A), + fontWeight: FontWeight.bold, + ) + ], + ), + ), + ), + ), + Expanded( + child: InkWell( + onTap: () { + model.sendActivationCodeByOTPNotificationType( + otpType: 1); + }, + child: Container( + height: + MediaQuery.of(context).size.height * 0.233, + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10), + ), + border: Border.all( + color: HexColor('#707070'), width: 0.1), + ), + child: Column( + children: [ + Row( + children: [ + Image.asset( + "assets/images/verify-whtsapp.png", + height: + MediaQuery.of(context).size.height * + 0.15, + width: + MediaQuery.of(context).size.width * + 0.15, + ), + ], + ), + SizedBox( + height: 20, + ), + AppText( + "Verify through WhatsApp", + fontSize: 14, + color: Color(0xFF2E303A), + fontWeight: FontWeight.bold, + ) + ], + ), + ), + ), + ), + ], + ), + ], + ), + ), + ) + ], + ), + ), + ); + } +} From fd9e8ddb2814fb822adb5386f816a608d63a5052 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 3 Nov 2021 09:43:43 +0200 Subject: [PATCH 2/8] actaivation code page --- .../service/PatientRegistrationService.dart | 17 +++++++++++------ .../viewModel/PatientRegistrationViewModel.dart | 17 ++++++++--------- .../register_patient/RegisterPatientPage.dart | 8 ++++++-- .../register_patient/VerifyMethodPage.dart | 4 +++- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/core/service/PatientRegistrationService.dart b/lib/core/service/PatientRegistrationService.dart index 2ca70aea..084bde69 100644 --- a/lib/core/service/PatientRegistrationService.dart +++ b/lib/core/service/PatientRegistrationService.dart @@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/core/model/PatientRegistration/GetPatientInfo import 'package:doctor_app_flutter/core/model/PatientRegistration/PatientRegistrationModel.dart'; import 'package:doctor_app_flutter/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/core/viewModel/PatientRegistrationViewModel.dart'; class PatientRegistrationService extends BaseService { GetPatientInfoResponseModel getPatientInfoResponseModel; @@ -37,17 +38,21 @@ class PatientRegistrationService extends BaseService { sendActivationCodeByOTPNotificationType( {SendActivationCodeByOTPNotificationTypeForRegistrationModel registrationModel, - int otpType}) async { + int otpType, + PatientRegistrationViewModel user}) async { registrationModel = SendActivationCodeByOTPNotificationTypeForRegistrationModel( oTPSendType: otpType, - patientIdentificationID: 1062938285, - patientMobileNumber: 785228065, - zipCode: "966", + patientIdentificationID: + user.checkPatientForRegistrationModel.patientIdentificationID, + patientMobileNumber: + user.checkPatientForRegistrationModel.patientMobileNumber, + zipCode: user.checkPatientForRegistrationModel.zipCode, patientOutSA: false, - mobileNo: "785228065", healthId: "30000018540264", - dOB: "31/07/1988", + dOB: user.checkPatientForRegistrationModel.dOB, + isRegister: user.checkPatientForRegistrationModel.isRegister, + isHijri: user.checkPatientForRegistrationModel.isHijri, ); hasError = false; await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE, diff --git a/lib/core/viewModel/PatientRegistrationViewModel.dart b/lib/core/viewModel/PatientRegistrationViewModel.dart index d8a4ea2c..f7461054 100644 --- a/lib/core/viewModel/PatientRegistrationViewModel.dart +++ b/lib/core/viewModel/PatientRegistrationViewModel.dart @@ -14,15 +14,13 @@ class PatientRegistrationViewModel extends BaseViewModel { PatientRegistrationService _patientRegistrationService = locator(); + GetPatientInfoResponseModel get getPatientInfoResponseModel => + _patientRegistrationService.getPatientInfoResponseModel; - GetPatientInfoResponseModel get getPatientInfoResponseModel =>_patientRegistrationService.getPatientInfoResponseModel; - - - CheckPatientForRegistrationModel checkPatientForRegistrationModel ; + CheckPatientForRegistrationModel checkPatientForRegistrationModel; Future checkPatientForRegistration( CheckPatientForRegistrationModel registrationModel) async { - - checkPatientForRegistrationModel =registrationModel; + checkPatientForRegistrationModel = registrationModel; setState(ViewState.BusyLocal); await _patientRegistrationService .checkPatientForRegistration(registrationModel); @@ -36,8 +34,8 @@ class PatientRegistrationViewModel extends BaseViewModel { Future getPatientInfo( GetPatientInfoRequestModel getPatientInfoRequestModel) async { setState(ViewState.BusyLocal); - await _patientRegistrationService. - getPatientInfo(getPatientInfoRequestModel); + await _patientRegistrationService + .getPatientInfo(getPatientInfoRequestModel); if (_patientRegistrationService.hasError) { error = _patientRegistrationService.error; setState(ViewState.ErrorLocal); @@ -48,7 +46,8 @@ class PatientRegistrationViewModel extends BaseViewModel { Future sendActivationCodeByOTPNotificationType( {SendActivationCodeByOTPNotificationTypeForRegistrationModel registrationModel, - int otpType}) async { + int otpType, + PatientRegistrationViewModel user}) async { setState(ViewState.Busy); await _patientRegistrationService.sendActivationCodeByOTPNotificationType( otpType: otpType); diff --git a/lib/screens/patients/register_patient/RegisterPatientPage.dart b/lib/screens/patients/register_patient/RegisterPatientPage.dart index 382dd501..efe816cf 100644 --- a/lib/screens/patients/register_patient/RegisterPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterPatientPage.dart @@ -99,8 +99,12 @@ class _RegisterPatientPageState extends State }, scrollDirection: Axis.horizontal, children: [ - RegisterSearchPatientPage(changePageViewIndex: changePageViewIndex,), - ActivationPage(model: model,), + RegisterSearchPatientPage( + changePageViewIndex: changePageViewIndex, + ), + ActivationPage( + user: model, + ), RegisterConfirmationPatientPage(), ]), ), diff --git a/lib/screens/patients/register_patient/VerifyMethodPage.dart b/lib/screens/patients/register_patient/VerifyMethodPage.dart index 885b2701..21286014 100644 --- a/lib/screens/patients/register_patient/VerifyMethodPage.dart +++ b/lib/screens/patients/register_patient/VerifyMethodPage.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/config/size_config.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/widgets/shared/app_scaffold_widget.dart'; @@ -7,7 +8,8 @@ import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; class ActivationPage extends StatefulWidget { - const ActivationPage({Key key}) : super(key: key); + PatientRegistrationViewModel user = PatientRegistrationViewModel(); + ActivationPage({this.user}); @override _ActivationPageState createState() => _ActivationPageState(); From 13c42b297a6621586580c1ad3ee77460568d9449 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 3 Nov 2021 17:08:47 +0200 Subject: [PATCH 3/8] check activation code --- .../service/PatientRegistrationService.dart | 22 +- .../PatientRegistrationViewModel.dart | 205 ++++--- .../register_patient/RegisterPatientPage.dart | 12 +- .../register_patient/VerifyMethodPage.dart | 552 ++++++++++++++---- 4 files changed, 559 insertions(+), 232 deletions(-) diff --git a/lib/core/service/PatientRegistrationService.dart b/lib/core/service/PatientRegistrationService.dart index 084bde69..ed3db005 100644 --- a/lib/core/service/PatientRegistrationService.dart +++ b/lib/core/service/PatientRegistrationService.dart @@ -39,20 +39,21 @@ class PatientRegistrationService extends BaseService { {SendActivationCodeByOTPNotificationTypeForRegistrationModel registrationModel, int otpType, - PatientRegistrationViewModel user}) async { + PatientRegistrationViewModel user, + CheckPatientForRegistrationModel + checkPatientForRegistrationModel}) async { registrationModel = SendActivationCodeByOTPNotificationTypeForRegistrationModel( oTPSendType: otpType, patientIdentificationID: - user.checkPatientForRegistrationModel.patientIdentificationID, - patientMobileNumber: - user.checkPatientForRegistrationModel.patientMobileNumber, - zipCode: user.checkPatientForRegistrationModel.zipCode, + checkPatientForRegistrationModel.patientIdentificationID, + patientMobileNumber: checkPatientForRegistrationModel.patientMobileNumber, + zipCode: checkPatientForRegistrationModel.zipCode, patientOutSA: false, healthId: "30000018540264", - dOB: user.checkPatientForRegistrationModel.dOB, - isRegister: user.checkPatientForRegistrationModel.isRegister, - isHijri: user.checkPatientForRegistrationModel.isHijri, + dOB: checkPatientForRegistrationModel.dOB, + isRegister: checkPatientForRegistrationModel.isRegister, + isHijri: checkPatientForRegistrationModel.isHijri, ); hasError = false; await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE, @@ -69,8 +70,9 @@ class PatientRegistrationService extends BaseService { checkActivationCode(CheckActivationCodeModel registrationModel) async { hasError = false; await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_PATIENT, - onSuccess: (dynamic response, int statusCode) {}, - onFailure: (String error, int statusCode) { + onSuccess: (dynamic response, int statusCode) { + registrationModel = CheckActivationCodeModel.fromJson(response); + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: registrationModel.toJson()); diff --git a/lib/core/viewModel/PatientRegistrationViewModel.dart b/lib/core/viewModel/PatientRegistrationViewModel.dart index 12c57ff0..aee62cad 100644 --- a/lib/core/viewModel/PatientRegistrationViewModel.dart +++ b/lib/core/viewModel/PatientRegistrationViewModel.dart @@ -14,19 +14,17 @@ class PatientRegistrationViewModel extends BaseViewModel { PatientRegistrationService _patientRegistrationService = locator(); - - GetPatientInfoResponseModel get getPatientInfoResponseModel =>_patientRegistrationService.getPatientInfoResponseModel; - - CheckPatientForRegistrationModel checkPatientForRegistrationModel ; GetPatientInfoResponseModel get getPatientInfoResponseModel => _patientRegistrationService.getPatientInfoResponseModel; CheckPatientForRegistrationModel checkPatientForRegistrationModel; + Future checkPatientForRegistration( CheckPatientForRegistrationModel registrationModel) async { checkPatientForRegistrationModel = registrationModel; - checkPatientForRegistrationModel =CheckPatientForRegistrationModel.fromJson(registrationModel.toJson()); + checkPatientForRegistrationModel = + CheckPatientForRegistrationModel.fromJson(registrationModel.toJson()); setState(ViewState.BusyLocal); await _patientRegistrationService .checkPatientForRegistration(registrationModel); @@ -40,111 +38,106 @@ class PatientRegistrationViewModel extends BaseViewModel { Future getPatientInfo( GetPatientInfoRequestModel getPatientInfoRequestModel) async { setState(ViewState.BusyLocal); + /// TODO Elham* return call service when it working - _patientRegistrationService.getPatientInfoResponseModel = GetPatientInfoResponseModel.fromJson({ - "Date": null, - "LanguageID": 0, - "ServiceName": 0, - "Time": null, - "AndroidLink": null, - "AuthenticationTokenID": null, - "Data": null, - "Dataw": false, - "DietType": 0, - "ErrorCode": null, - "ErrorEndUserMessage": null, - "ErrorEndUserMessageN": null, - "ErrorMessage": null, - "ErrorType": 0, - "FoodCategory": 0, - "IOSLink": null, - "IsAuthenticated": false, - "MealOrderStatus": 0, - "MealType": 0, - "MessageStatus": 1, - "NumberOfResultRecords": 0, - "PatientBlodType": null, - "SuccessMsg": null, - "SuccessMsgN": null, - "VidaUpdatedResponse": null, - "AccessTokenObject": null, - "Age": 33, - "ClientIdentifierId": null, - "CreatedBy": 0, - "DateOfBirth": "07/31/1988", - "FirstNameAr": "سفيان", - "FirstNameEn": "SUFIAN", - "Gender": "M", - "GenderAr": null, - "GenderEn": null, - "HealthId": "30000018540264", - "IdNumber": "1062938285", - "IdType": "NationalId", - "IsHijri": false, - "IsInstertedOrUpdated": 0, - "IsNull": 0, - "IsPatientExistNHIC": 0, - "IsRecordLockedByCurrentUser": false, - "LastNameAr": "عثمان", - "LastNameEn": "OTHMAN", - "List_ActiveAccessToken": null, - "MaritalStatus": "غير معروف", - "MaritalStatusCode": "U", - "NationalDateOfBirth": "18/12/1408", - "Nationality": "السعودية", - "NationalityCode": "SAU", - "Occupation": "طالب", - "PCDTransactionDataResultList": null, - "PCD_GetVidaPatientForManualVerificationList": null, - "PCD_NHIC_HMG_PatientDetailsMatchCalulationList": null, - "PCD_ReturnValue": 0, - "PatientStatus": "-", - "PlaceofBirth": "فينا", - "PractitionerStatusCode": null, - "PractitionerStatusDescAr": null, - "PractitionerStatusDescEn": null, - "RowCount": 0, - "SecondNameAr": "عبدالهادي", - "SecondNameEn": "ABDULHADI", - "ThirdNameAr": "احمد", - "ThirdNameEn": "A", - "YakeenVidaPatientDataStatisticsByPatientIdList": null, - "YakeenVidaPatientDataStatisticsList": null, - "YakeenVidaPatientDataStatisticsPrefferedList": null, - "accessToken": null, - "categoryCode": 0, - "categoryNameAr": null, - "categoryNameEn": null, - "constraintCode": 0, - "constraintNameAr": null, - "constraintNameEn": null, - "content": null, - "errorList": null, - "licenseExpiryDate": null, - "licenseIssuedDate": null, - "licenseStatusCode": null, - "licenseStatusDescAr": null, - "licenseStatusDescEn": null, - "organizations": null, - "registrationNumber": null, - "specialtyCode": 0, - "specialtyNameAr": null, - "specialtyNameEn": null - }); + _patientRegistrationService.getPatientInfoResponseModel = + GetPatientInfoResponseModel.fromJson({ + "Date": null, + "LanguageID": 0, + "ServiceName": 0, + "Time": null, + "AndroidLink": null, + "AuthenticationTokenID": null, + "Data": null, + "Dataw": false, + "DietType": 0, + "ErrorCode": null, + "ErrorEndUserMessage": null, + "ErrorEndUserMessageN": null, + "ErrorMessage": null, + "ErrorType": 0, + "FoodCategory": 0, + "IOSLink": null, + "IsAuthenticated": false, + "MealOrderStatus": 0, + "MealType": 0, + "MessageStatus": 1, + "NumberOfResultRecords": 0, + "PatientBlodType": null, + "SuccessMsg": null, + "SuccessMsgN": null, + "VidaUpdatedResponse": null, + "AccessTokenObject": null, + "Age": 33, + "ClientIdentifierId": null, + "CreatedBy": 0, + "DateOfBirth": "07/31/1988", + "FirstNameAr": "سفيان", + "FirstNameEn": "SUFIAN", + "Gender": "M", + "GenderAr": null, + "GenderEn": null, + "HealthId": "30000018540264", + "IdNumber": "1062938285", + "IdType": "NationalId", + "IsHijri": false, + "IsInstertedOrUpdated": 0, + "IsNull": 0, + "IsPatientExistNHIC": 0, + "IsRecordLockedByCurrentUser": false, + "LastNameAr": "عثمان", + "LastNameEn": "OTHMAN", + "List_ActiveAccessToken": null, + "MaritalStatus": "غير معروف", + "MaritalStatusCode": "U", + "NationalDateOfBirth": "18/12/1408", + "Nationality": "السعودية", + "NationalityCode": "SAU", + "Occupation": "طالب", + "PCDTransactionDataResultList": null, + "PCD_GetVidaPatientForManualVerificationList": null, + "PCD_NHIC_HMG_PatientDetailsMatchCalulationList": null, + "PCD_ReturnValue": 0, + "PatientStatus": "-", + "PlaceofBirth": "فينا", + "PractitionerStatusCode": null, + "PractitionerStatusDescAr": null, + "PractitionerStatusDescEn": null, + "RowCount": 0, + "SecondNameAr": "عبدالهادي", + "SecondNameEn": "ABDULHADI", + "ThirdNameAr": "احمد", + "ThirdNameEn": "A", + "YakeenVidaPatientDataStatisticsByPatientIdList": null, + "YakeenVidaPatientDataStatisticsList": null, + "YakeenVidaPatientDataStatisticsPrefferedList": null, + "accessToken": null, + "categoryCode": 0, + "categoryNameAr": null, + "categoryNameEn": null, + "constraintCode": 0, + "constraintNameAr": null, + "constraintNameEn": null, + "content": null, + "errorList": null, + "licenseExpiryDate": null, + "licenseIssuedDate": null, + "licenseStatusCode": null, + "licenseStatusDescAr": null, + "licenseStatusDescEn": null, + "organizations": null, + "registrationNumber": null, + "specialtyCode": 0, + "specialtyNameAr": null, + "specialtyNameEn": null + }); // await _patientRegistrationService. // getPatientInfo(getPatientInfoRequestModel); // if (_patientRegistrationService.hasError) { // error = _patientRegistrationService.error; // setState(ViewState.ErrorLocal); // } else - // setState(ViewState.Idle); - await _patientRegistrationService - .getPatientInfo(getPatientInfoRequestModel); - if (_patientRegistrationService.hasError) { - error = _patientRegistrationService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); + setState(ViewState.Idle); } Future sendActivationCodeByOTPNotificationType( @@ -153,8 +146,12 @@ class PatientRegistrationViewModel extends BaseViewModel { int otpType, PatientRegistrationViewModel user}) async { setState(ViewState.Busy); + print(checkPatientForRegistrationModel); + print(checkPatientForRegistrationModel); + await _patientRegistrationService.sendActivationCodeByOTPNotificationType( - otpType: otpType); + otpType: otpType, + checkPatientForRegistrationModel: checkPatientForRegistrationModel); if (_patientRegistrationService.hasError) { error = _patientRegistrationService.error; setState(ViewState.Error); diff --git a/lib/screens/patients/register_patient/RegisterPatientPage.dart b/lib/screens/patients/register_patient/RegisterPatientPage.dart index 52e3b0c9..f9d6d5d3 100644 --- a/lib/screens/patients/register_patient/RegisterPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterPatientPage.dart @@ -99,16 +99,16 @@ class _RegisterPatientPageState extends State }, scrollDirection: Axis.horizontal, children: [ - RegisterSearchPatientPage(changePageViewIndex: changePageViewIndex,model: model), - RegisterConfirmationPatientPage(model: model,), - RegisterSearchPatientPage( + changePageViewIndex: changePageViewIndex, + model: model), + ActivationPage( + model: model, changePageViewIndex: changePageViewIndex, ), - ActivationPage( - user: model, + RegisterConfirmationPatientPage( + model: model, ), - RegisterConfirmationPatientPage(), ]), ), ), diff --git a/lib/screens/patients/register_patient/VerifyMethodPage.dart b/lib/screens/patients/register_patient/VerifyMethodPage.dart index 21286014..b959e0a8 100644 --- a/lib/screens/patients/register_patient/VerifyMethodPage.dart +++ b/lib/screens/patients/register_patient/VerifyMethodPage.dart @@ -2,147 +2,475 @@ import 'package:doctor_app_flutter/config/size_config.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/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'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; class ActivationPage extends StatefulWidget { - PatientRegistrationViewModel user = PatientRegistrationViewModel(); - ActivationPage({this.user}); + final PatientRegistrationViewModel model; + final Function changePageViewIndex; + ActivationPage({this.model, this.changePageViewIndex}); @override _ActivationPageState createState() => _ActivationPageState(); } class _ActivationPageState extends State { + bool isSendOtp = false; + final verifyAccountForm = GlobalKey(); + TextStyle buildTextStyle() { + return TextStyle( + fontSize: SizeConfig.textMultiplier * 3, + ); + } + + Map verifyAccountFormValue = { + 'digit1': '', + 'digit2': '', + 'digit3': '', + 'digit4': '', + }; + final focusD1 = FocusNode(); + final focusD2 = FocusNode(); + final focusD3 = FocusNode(); + final focusD4 = FocusNode(); + + TextEditingController digit1 = TextEditingController(text: ""); + TextEditingController digit2 = TextEditingController(text: ""); + TextEditingController digit3 = TextEditingController(text: ""); + TextEditingController digit4 = TextEditingController(text: ""); + @override Widget build(BuildContext context) { - return BaseView( - builder: (_, model, w) => AppScaffold( - baseViewModel: model, + return AppScaffold( + baseViewModel: widget.model, isShowAppBar: false, body: Column( children: [ - Container( - width: double.infinity, - margin: EdgeInsets.all(16.0), - child: SingleChildScrollView( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - "Please select how you want to be verified", - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 2.2, - fontWeight: FontWeight.w800, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: InkWell( - onTap: () { - model.sendActivationCodeByOTPNotificationType( - otpType: 1); - }, - child: Container( - height: - MediaQuery.of(context).size.height * 0.233, - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(10), - ), - border: Border.all( - color: HexColor('#707070'), width: 0.1), - ), - child: Column( - children: [ - Row( - children: [ - Image.asset( - "assets/images/verify-sms.png", - height: - MediaQuery.of(context).size.height * - 0.15, - width: - MediaQuery.of(context).size.width * - 0.15, + Visibility( + //visible: isSendOtp, + child: !isSendOtp + ? Container( + width: double.infinity, + margin: EdgeInsets.all(16.0), + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "Please select how you want to be verified", + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 2.2, + fontWeight: FontWeight.w800, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: InkWell( + onTap: () async { + setState(() { + isSendOtp = true; + }); + + await widget.model + .sendActivationCodeByOTPNotificationType( + otpType: 1); + }, + child: Container( + height: + MediaQuery.of(context).size.height * + 0.233, + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10), + ), + border: Border.all( + color: HexColor('#707070'), + width: 0.1), + ), + child: Column( + children: [ + Row( + children: [ + Image.asset( + "assets/images/verify-sms.png", + height: MediaQuery.of(context) + .size + .height * + 0.15, + width: MediaQuery.of(context) + .size + .width * + 0.15, + ), + ], + ), + SizedBox( + height: 20, + ), + AppText( + "Verify through SMS", + fontSize: 14, + color: Color(0xFF2E303A), + fontWeight: FontWeight.bold, + ) + ], ), - ], + ), ), - SizedBox( - height: 20, + ), + Expanded( + child: InkWell( + onTap: () async { + isSendOtp = false; + await widget.model + .sendActivationCodeByOTPNotificationType( + otpType: 1, user: widget.model); + }, + child: Container( + height: + MediaQuery.of(context).size.height * + 0.233, + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10), + ), + border: Border.all( + color: HexColor('#707070'), + width: 0.1), + ), + child: Column( + children: [ + Row( + children: [ + Image.asset( + "assets/images/verify-whtsapp.png", + height: MediaQuery.of(context) + .size + .height * + 0.15, + width: MediaQuery.of(context) + .size + .width * + 0.15, + ), + ], + ), + SizedBox( + height: 20, + ), + AppText( + "Verify through WhatsApp", + fontSize: 14, + color: Color(0xFF2E303A), + fontWeight: FontWeight.bold, + ) + ], + ), + ), ), - AppText( - "Verify through SMS", - fontSize: 14, - color: Color(0xFF2E303A), - fontWeight: FontWeight.bold, - ) - ], - ), + ), + ], ), - ), + ], ), - Expanded( - child: InkWell( - onTap: () { - model.sendActivationCodeByOTPNotificationType( - otpType: 1); - }, - child: Container( - height: - MediaQuery.of(context).size.height * 0.233, - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(10), - ), - border: Border.all( - color: HexColor('#707070'), width: 0.1), - ), - child: Column( - children: [ - Row( - children: [ - Image.asset( - "assets/images/verify-whtsapp.png", - height: - MediaQuery.of(context).size.height * - 0.15, - width: - MediaQuery.of(context).size.width * - 0.15, + ), + ) + : Container( + width: double.infinity, + margin: EdgeInsets.all(16.0), + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "Please enter the verification code sent to 02221552", + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 2.2, + fontWeight: FontWeight.w800, + ), + Row( + children: [ + Center( + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Form( + key: verifyAccountForm, + child: Padding( + padding: EdgeInsets.only(top: 20), + child: Directionality( + textDirection: TextDirection.ltr, + child: Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Container( + width: SizeConfig + .realScreenWidth * + 0.16, + margin: EdgeInsets.all(5), + child: TextFormField( + textInputAction: + TextInputAction.next, + style: buildTextStyle(), + autofocus: true, + maxLength: 1, + controller: digit1, + textAlign: TextAlign.center, + keyboardType: + TextInputType.number, + decoration: + buildInputDecoration( + context), + onSaved: (val) {}, + //validator: validateCodeDigit, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus( + focusD2); + }, + onChanged: (val) { + if (val.length == 1) { + FocusScope.of(context) + .requestFocus( + focusD2); + verifyAccountFormValue[ + 'digit1'] = + val.trim(); + //checkValue(); + } + }, + ), + ), + Container( + width: SizeConfig + .realScreenWidth * + 0.16, + margin: EdgeInsets.all(5), + child: TextFormField( + focusNode: focusD2, + textInputAction: + TextInputAction.next, + maxLength: 1, + controller: digit2, + textAlign: TextAlign.center, + style: buildTextStyle(), + keyboardType: + TextInputType.number, + decoration: + buildInputDecoration( + context), + onSaved: (val) {}, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus( + focusD3); + }, + onChanged: (val) { + if (val.length == 1) { + FocusScope.of(context) + .requestFocus( + focusD3); + verifyAccountFormValue[ + 'digit2'] = + val.trim(); + //checkValue(); + } + }, + //validator: validateCodeDigit, + ), + ), + Container( + margin: EdgeInsets.all(5), + width: SizeConfig + .realScreenWidth * + 0.16, + child: TextFormField( + focusNode: focusD3, + textInputAction: + TextInputAction.next, + maxLength: 1, + controller: digit3, + textAlign: + TextAlign.center, + style: buildTextStyle(), + keyboardType: + TextInputType.number, + decoration: + buildInputDecoration( + context), + onSaved: (val) {}, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus( + focusD4); + }, + onChanged: (val) { + if (val.length == 1) { + FocusScope.of(context) + .requestFocus( + focusD4); + verifyAccountFormValue[ + 'digit3'] = + val.trim(); + //checkValue(); + } + }, + // validator: + // validateCodeDigit, + )), + Container( + margin: EdgeInsets.all(5), + width: SizeConfig + .realScreenWidth * + 0.16, + child: TextFormField( + focusNode: focusD4, + maxLength: 1, + textAlign: + TextAlign.center, + style: buildTextStyle(), + controller: digit4, + keyboardType: + TextInputType.number, + decoration: + buildInputDecoration( + context), + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus( + focusD4); + }, + onChanged: (val) { + if (val.length == 1) { + verifyAccountFormValue[ + 'digit4'] = + val.trim(); + //checkValue(); + } + }, + // validator: + // validateCodeDigit, + )), + ], + )), ), - ], - ), - SizedBox( - height: 20, - ), - AppText( - "Verify through WhatsApp", - fontSize: 14, - color: Color(0xFF2E303A), - fontWeight: FontWeight.bold, - ) - ], - ), + ), + Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context) + .validationMessage + + ' ', + fontWeight: FontWeight.w600, + fontSize: 14, + ), + // AppText( + // displayTime, + // color: Colors.red, + // textAlign: TextAlign.start, + // fontWeight: FontWeight.bold, + // fontSize: 14, + // ) + ]), + ) + ], + ))), + ], ), - ), + ], ), - ], + ), ), - ], - ), - ), ) ], ), + bottomSheet: isSendOtp + ? Container( + height: 60, + margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16), + child: Row( + children: [ + Expanded( + child: Container( + child: AppButton( + title: TranslationBase.of(context).cancel, + hasBorder: true, + vPadding: 12, + hPadding: 8, + borderColor: Color(0xFFeaeaea), + color: Color(0xFFeaeaea), + fontColor: Colors.black, + fontSize: 2.2, + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ), + SizedBox( + width: 8, + ), + Expanded( + child: Container( + child: AppButton( + title: TranslationBase.of(context).next, + hasBorder: true, + vPadding: 12, + hPadding: 8, + borderColor: Color(0xFFB8382B), + color: Color(0xFFB8382B), + fontColor: Colors.white, + fontSize: 2.0, + onPressed: () async { + //widget.model.checkActivationCode(), + }, + ), + ), + ), + ], + ), + ) + : null); + } + + InputDecoration buildInputDecoration(BuildContext context) { + return InputDecoration( + counterText: " ", + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + borderSide: BorderSide(color: Colors.grey[300]), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Colors.grey[300]), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Colors.grey[300]), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), ), ); } From 3eddf2eab57eeb01b87ef7baa82f48338067f90e Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 3 Nov 2021 17:13:59 +0200 Subject: [PATCH 4/8] first step from service part --- .../PatientRegistrationViewModel.dart | 4 +- .../RegisterConfirmationPatientPage.dart | 148 +++++++++++++----- lib/util/date-utils.dart | 4 + 3 files changed, 113 insertions(+), 43 deletions(-) diff --git a/lib/core/viewModel/PatientRegistrationViewModel.dart b/lib/core/viewModel/PatientRegistrationViewModel.dart index 03f2413b..8f7ff521 100644 --- a/lib/core/viewModel/PatientRegistrationViewModel.dart +++ b/lib/core/viewModel/PatientRegistrationViewModel.dart @@ -159,11 +159,11 @@ class PatientRegistrationViewModel extends BaseViewModel { } Future registrationPatient(PatientRegistrationModel registrationModel) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _patientRegistrationService.registrationPatient(registrationModel); if (_patientRegistrationService.hasError) { error = _patientRegistrationService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } diff --git a/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart b/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart index afc3e5bd..6f60ad5d 100644 --- a/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart @@ -17,6 +17,7 @@ import 'package:doctor_app_flutter/models/operation_report/create_update_operati import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/progress_note_request.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; @@ -28,6 +29,7 @@ import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; @@ -38,13 +40,10 @@ import 'CustomEditableText.dart'; class RegisterConfirmationPatientPage extends StatefulWidget { final OperationReportViewModel operationReportViewModel; final PatiantInformtion patient; - final PatientRegistrationViewModel model; - + final PatientRegistrationViewModel model; const RegisterConfirmationPatientPage( - {Key key, - this.operationReportViewModel, - this.patient, this.model}) + {Key key, this.operationReportViewModel, this.patient, this.model}) : super(key: key); @override @@ -56,17 +55,28 @@ class _RegisterConfirmationPatientPageState extends State { bool isSubmitted = false; ProjectViewModel projectViewModel; - TextEditingController firstName; - TextEditingController middleName ; - TextEditingController lastName; + TextEditingController firstNameN; + TextEditingController middleNameN; + TextEditingController lastNameN; + TextEditingController firstNameAr; + TextEditingController middleNameAr; + TextEditingController lastNameAr; TextEditingController emailAddressController; - @override void initState() { - firstName = TextEditingController(text: widget.model.getPatientInfoResponseModel.firstNameEn); - middleName = TextEditingController(text: ""); - lastName = TextEditingController(text: widget.model.getPatientInfoResponseModel.lastNameEn); + firstNameN = TextEditingController( + text: widget.model.getPatientInfoResponseModel.firstNameEn); + middleNameN = TextEditingController(text: ""); + lastNameN = TextEditingController( + text: widget.model.getPatientInfoResponseModel.lastNameEn); + + firstNameAr = TextEditingController( + text: widget.model.getPatientInfoResponseModel.firstNameAr); + middleNameAr = TextEditingController(text: ""); + lastNameAr = TextEditingController( + text: widget.model.getPatientInfoResponseModel.lastNameAr); + emailAddressController = TextEditingController(text: ""); super.initState(); } @@ -95,23 +105,41 @@ class _RegisterConfirmationPatientPageState child: Column( children: [ CustomEditableText( - controller: firstName, + controller: firstNameN, hint: TranslationBase.of(context).firstName), SizedBox( height: 4, ), CustomEditableText( - controller: middleName, + controller: middleNameN, hint: TranslationBase.of(context).middleName), SizedBox( height: 4, ), CustomEditableText( - controller: lastName, + controller: lastNameN, hint: TranslationBase.of(context).lastName), SizedBox( height: 20, ), + CustomEditableText( + controller: firstNameAr, + hint: "First Name Arabic"), + SizedBox( + height: 4, + ), + CustomEditableText( + controller: middleNameAr, + hint: "Middle Name Arabic"), + SizedBox( + height: 4, + ), + CustomEditableText( + controller: lastNameAr, + hint: "Last Name Arabic"), + SizedBox( + height: 20, + ), FractionallySizedBox( widthFactor: .9, child: Center( @@ -148,7 +176,6 @@ class _RegisterConfirmationPatientPageState color: Colors.black), AppText( "${widget.model.getPatientInfoResponseModel.idNumber}", - fontSize: 12, color: Colors.grey[600], ), @@ -193,7 +220,6 @@ class _RegisterConfirmationPatientPageState color: Colors.black), AppText( "${widget.model.getPatientInfoResponseModel.occupation}", - fontSize: 12, color: Colors.grey[600], ), @@ -222,7 +248,6 @@ class _RegisterConfirmationPatientPageState color: Colors.black), AppText( "${widget.model.checkPatientForRegistrationModel.patientMobileNumber}", - fontSize: 12, color: Colors.grey[600], ), @@ -341,32 +366,77 @@ class _RegisterConfirmationPatientPageState fontColor: Colors.white, fontSize: 2.0, onPressed: () async { + print(widget.model + .getPatientInfoResponseModel.dateOfBirth); + + + + var dateFormat = DateFormat('MM/dd/yyyy').parse(widget.model + .getPatientInfoResponseModel.dateOfBirth); + String wellFormat = "${dateFormat.day}\/${dateFormat.month}\/${dateFormat.year}"; + print (dateFormat.toUtc().toString()); + // return ; + GifLoaderDialogUtils.showMyDialog(context); - PatientRegistrationModel - patientRegistrationModel = - PatientRegistrationModel( - // patientIdentificationID: - // int.parse(_idController.text), - // patientMobileNumber: - // int.parse(_phoneController.text), - // zipCode: _phoneCode.text, - isHijri: 0, - isDentalAllowedBackend: false, - patientOutSA: 0, - generalid: GENERAL_ID, - // dOB: - // "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}" - ); - await widget.model.registrationPatient( - patientRegistrationModel); - if(widget.model.state == ViewState.ErrorLocal){ + PatientRegistrationModel patientRegistrationModel = + PatientRegistrationModel( + patientobject: Patientobject( + tempValue: true, + patientIdentificationNo: widget + .model + .checkPatientForRegistrationModel + .patientIdentificationID + .toString(), + patientIdentificationType: 1, + firstName: firstNameAr.text, + firstNameN: firstNameN.text, + lastName: lastNameAr.text, + lastNameN: lastNameN.text, + middleName: middleNameAr.text, + middleNameN: middleNameN.text, + strDateofBirth: dateFormat.toUtc().toString(), + dateofBirth: AppDateUtils.convertToServerFormat(widget.model.getPatientInfoResponseModel.dateOfBirth, 'MM/dd/yyyy'), + dateofBirthN: wellFormat, + gender: (widget.model.getPatientInfoResponseModel.gender == "M") + ? 1 + : 2, + sourceType: "1", + patientOutSA: 0, + nationalityID: widget + .model + .getPatientInfoResponseModel + .nationalityCode, + //todo Elham* change static value to dynamic + preferredLanguage: "1", + marital: "0", + eHealthIDField: widget + .model.getPatientInfoResponseModel.healthId, + emailAddress: emailAddressController.text, + mobileNumber: widget + .model + .checkPatientForRegistrationModel + .patientMobileNumber), + isHijri: 0, + logInTokenID: "zjgvKtLC/EK+saznJ/OkiA==", + isDentalAllowedBackend: false, + patientOutSA: 0, + sessionID: null, + patientMobileNumber: + widget.model.checkPatientForRegistrationModel.patientMobileNumber.toString(), + healthId: widget.model.getPatientInfoResponseModel.healthId, + generalid: GENERAL_ID, + patientIdentificationID: widget.model.checkPatientForRegistrationModel.patientIdentificationID.toString(), + dOB:wellFormat, + zipCode: widget.model.checkPatientForRegistrationModel.zipCode); + await widget.model + .registrationPatient(patientRegistrationModel); + if (widget.model.state == ViewState.ErrorLocal) { Helpers.showErrorToast(widget.model.error); } else { Navigator.of(context).pop(); } GifLoaderDialogUtils.hideDialog(context); - }, ), ), @@ -413,7 +483,6 @@ class _RegisterConfirmationPatientPageState ), ], ), - SizedBox( height: 10, ), @@ -522,7 +591,6 @@ class _RegisterConfirmationPatientPageState ), ], ), - SizedBox( height: 10, ), @@ -568,11 +636,9 @@ class _RegisterConfirmationPatientPageState ], ), ), - ], ), ); }); } - } diff --git a/lib/util/date-utils.dart b/lib/util/date-utils.dart index 89564833..a10a18e3 100644 --- a/lib/util/date-utils.dart +++ b/lib/util/date-utils.dart @@ -24,6 +24,10 @@ class AppDateUtils { return convertDateToFormat(dateTime, dateFormat); } + static String convertToServerFormat(String date, String dateFormat){ + return '/Date(${DateFormat(dateFormat).parse(date).millisecondsSinceEpoch})/'; + } + static convertDateFromServerFormat(String str, dateFormat) { var date = getDateTimeFromServerFormat(str); From 4fe53ef71e29a9ef42fd9a8f0152339d1d1f0930 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 3 Nov 2021 17:28:18 +0200 Subject: [PATCH 5/8] add hijri converter --- .../register_patient/RegisterConfirmationPatientPage.dart | 5 ++++- pubspec.lock | 7 +++++++ pubspec.yaml | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart b/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart index 6f60ad5d..024d65d0 100644 --- a/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart @@ -29,6 +29,7 @@ import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; import 'package:flutter/material.dart'; +import 'package:hijri/hijri_calendar.dart'; import 'package:intl/intl.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; @@ -375,6 +376,7 @@ class _RegisterConfirmationPatientPageState .getPatientInfoResponseModel.dateOfBirth); String wellFormat = "${dateFormat.day}\/${dateFormat.month}\/${dateFormat.year}"; print (dateFormat.toUtc().toString()); + HijriCalendar hijriDate = HijriCalendar.fromDate(new DateTime(dateFormat.year, dateFormat.month, dateFormat.day)); // return ; GifLoaderDialogUtils.showMyDialog(context); @@ -396,7 +398,7 @@ class _RegisterConfirmationPatientPageState middleNameN: middleNameN.text, strDateofBirth: dateFormat.toUtc().toString(), dateofBirth: AppDateUtils.convertToServerFormat(widget.model.getPatientInfoResponseModel.dateOfBirth, 'MM/dd/yyyy'), - dateofBirthN: wellFormat, + dateofBirthN: '$hijriDate', gender: (widget.model.getPatientInfoResponseModel.gender == "M") ? 1 : 2, @@ -433,6 +435,7 @@ class _RegisterConfirmationPatientPageState if (widget.model.state == ViewState.ErrorLocal) { Helpers.showErrorToast(widget.model.error); } else { + DrAppToastMsg.showSuccesToast("Patient added Successfully"); Navigator.of(context).pop(); } diff --git a/pubspec.lock b/pubspec.lock index 43aefcb2..19f658ed 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -574,6 +574,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.6" + hijri: + dependency: "direct main" + description: + name: hijri + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" html: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 66f0df91..485e8ae6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -103,6 +103,11 @@ dependencies: # Badges badges: ^1.1.4 + # Hijri + hijri: ^2.0.0 + + + dev_dependencies: flutter_test: sdk: flutter From ad845b882c8765d6c1b75245152f45b5b0145761 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 4 Nov 2021 10:44:49 +0200 Subject: [PATCH 6/8] finish confirmation page --- .../register_patient/CustomEditableText.dart | 10 +- .../RegisterConfirmationPatientPage.dart | 209 +++++++++++------- .../register_patient/RegisterPatientPage.dart | 3 +- .../RegisterSearchPatientPage.dart | 157 +++++++------ 4 files changed, 232 insertions(+), 147 deletions(-) diff --git a/lib/screens/patients/register_patient/CustomEditableText.dart b/lib/screens/patients/register_patient/CustomEditableText.dart index e4de6aae..17405829 100644 --- a/lib/screens/patients/register_patient/CustomEditableText.dart +++ b/lib/screens/patients/register_patient/CustomEditableText.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; @@ -8,13 +9,14 @@ class CustomEditableText extends StatefulWidget { Key key, @required this.controller, this.hint, - this.isEditable = false, + this.isEditable = false, this.isSubmitted, }) : super(key: key); final TextEditingController controller; final String hint; bool isEditable; + final bool isSubmitted; @override _CustomEditableTextState createState() => _CustomEditableTextState(); @@ -77,6 +79,12 @@ class _CustomEditableTextState extends State { hintText: widget.hint, //TranslationBase.of(context).addoperationReports, controller: widget.controller, + validationError: widget.controller + .text.isEmpty && + widget.isSubmitted + ? TranslationBase.of(context) + .emptyMessage + : null, maxLines: 1, minLines: 1, hasBorder: true, diff --git a/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart b/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart index 024d65d0..af861294 100644 --- a/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterConfirmationPatientPage.dart @@ -63,6 +63,9 @@ class _RegisterConfirmationPatientPageState TextEditingController middleNameAr; TextEditingController lastNameAr; TextEditingController emailAddressController; + TextEditingController langController = TextEditingController( + text: "English"); + int selectedLang = 1; @override void initState() { @@ -84,6 +87,8 @@ class _RegisterConfirmationPatientPageState @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); + + ///TODO Elham* add translation return AppScaffold( isShowAppBar: false, backgroundColor: Color(0xFFF8F8F8), @@ -107,36 +112,44 @@ class _RegisterConfirmationPatientPageState children: [ CustomEditableText( controller: firstNameN, + isSubmitted: isSubmitted, hint: TranslationBase.of(context).firstName), SizedBox( height: 4, ), CustomEditableText( controller: middleNameN, + isEditable: middleNameN.text.isEmpty, + isSubmitted: isSubmitted, hint: TranslationBase.of(context).middleName), SizedBox( height: 4, ), CustomEditableText( controller: lastNameN, + isSubmitted: isSubmitted, hint: TranslationBase.of(context).lastName), SizedBox( height: 20, ), CustomEditableText( controller: firstNameAr, + isSubmitted: isSubmitted, hint: "First Name Arabic"), SizedBox( height: 4, ), CustomEditableText( controller: middleNameAr, + isEditable: middleNameN.text.isEmpty, + isSubmitted: isSubmitted, hint: "Middle Name Arabic"), SizedBox( height: 4, ), CustomEditableText( controller: lastNameAr, + isSubmitted: isSubmitted, hint: "Last Name Arabic"), SizedBox( height: 20, @@ -294,6 +307,7 @@ class _RegisterConfirmationPatientPageState onClick: () { openLangList(context); }, + controller: langController, hintText: TranslationBase.of(context).lanEnglish, maxLines: 1, minLines: 1, @@ -315,6 +329,11 @@ class _RegisterConfirmationPatientPageState maxLines: 1, minLines: 1, hasBorder: true, + validationError: + emailAddressController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, ), SizedBox( height: 400, @@ -367,79 +386,93 @@ class _RegisterConfirmationPatientPageState fontColor: Colors.white, fontSize: 2.0, onPressed: () async { - print(widget.model - .getPatientInfoResponseModel.dateOfBirth); + setState(() { + isSubmitted = true; + }); + if (isFormValid()) { + print( + widget.model.getPatientInfoResponseModel.dateOfBirth); + var dateFormat = DateFormat('MM/dd/yyyy').parse( + widget.model.getPatientInfoResponseModel.dateOfBirth); + String wellFormat = + "${dateFormat.day}\/${dateFormat.month}\/${dateFormat.year}"; + print(dateFormat.toUtc().toString()); + HijriCalendar hijriDate = HijriCalendar.fromDate( + new DateTime(dateFormat.year, dateFormat.month, + dateFormat.day)); + // return ; - - var dateFormat = DateFormat('MM/dd/yyyy').parse(widget.model - .getPatientInfoResponseModel.dateOfBirth); - String wellFormat = "${dateFormat.day}\/${dateFormat.month}\/${dateFormat.year}"; - print (dateFormat.toUtc().toString()); - HijriCalendar hijriDate = HijriCalendar.fromDate(new DateTime(dateFormat.year, dateFormat.month, dateFormat.day)); - // return ; + GifLoaderDialogUtils.showMyDialog(context); + PatientRegistrationModel patientRegistrationModel = + PatientRegistrationModel( + patientobject: Patientobject( + tempValue: true, + patientIdentificationNo: widget + .model + .checkPatientForRegistrationModel + .patientIdentificationID + .toString(), + patientIdentificationType: 1, + firstName: firstNameAr.text, + firstNameN: firstNameN.text, + lastName: lastNameAr.text, + lastNameN: lastNameN.text, + middleName: middleNameAr.text, + middleNameN: middleNameN.text, + strDateofBirth: dateFormat.toUtc().toString(), + dateofBirth: AppDateUtils.convertToServerFormat( + widget.model.getPatientInfoResponseModel + .dateOfBirth, + 'MM/dd/yyyy'), + dateofBirthN: '$hijriDate', + gender: (widget.model.getPatientInfoResponseModel.gender == "M") + ? 1 + : 2, + sourceType: "1", + patientOutSA: 0, + nationalityID: widget + .model + .getPatientInfoResponseModel + .nationalityCode, + //todo Elham* change static value to dynamic + preferredLanguage: selectedLang.toString(), + marital: "0", + eHealthIDField: widget.model + .getPatientInfoResponseModel.healthId, + emailAddress: emailAddressController.text, + mobileNumber: widget + .model + .checkPatientForRegistrationModel + .patientMobileNumber), + isHijri: 0, + logInTokenID: "zjgvKtLC/EK+saznJ/OkiA==", + isDentalAllowedBackend: false, + patientOutSA: 0, + sessionID: null, + patientMobileNumber: widget + .model + .checkPatientForRegistrationModel + .patientMobileNumber + .toString(), + healthId: + widget.model.getPatientInfoResponseModel.healthId, + generalid: GENERAL_ID, + patientIdentificationID: widget.model.checkPatientForRegistrationModel.patientIdentificationID.toString(), + dOB: wellFormat, + zipCode: widget.model.checkPatientForRegistrationModel.zipCode); + await widget.model + .registrationPatient(patientRegistrationModel); + if (widget.model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(widget.model.error); + } else { + DrAppToastMsg.showSuccesToast( + "Patient added Successfully"); + Navigator.of(context).pop(); + } - GifLoaderDialogUtils.showMyDialog(context); - PatientRegistrationModel patientRegistrationModel = - PatientRegistrationModel( - patientobject: Patientobject( - tempValue: true, - patientIdentificationNo: widget - .model - .checkPatientForRegistrationModel - .patientIdentificationID - .toString(), - patientIdentificationType: 1, - firstName: firstNameAr.text, - firstNameN: firstNameN.text, - lastName: lastNameAr.text, - lastNameN: lastNameN.text, - middleName: middleNameAr.text, - middleNameN: middleNameN.text, - strDateofBirth: dateFormat.toUtc().toString(), - dateofBirth: AppDateUtils.convertToServerFormat(widget.model.getPatientInfoResponseModel.dateOfBirth, 'MM/dd/yyyy'), - dateofBirthN: '$hijriDate', - gender: (widget.model.getPatientInfoResponseModel.gender == "M") - ? 1 - : 2, - sourceType: "1", - patientOutSA: 0, - nationalityID: widget - .model - .getPatientInfoResponseModel - .nationalityCode, - //todo Elham* change static value to dynamic - preferredLanguage: "1", - marital: "0", - eHealthIDField: widget - .model.getPatientInfoResponseModel.healthId, - emailAddress: emailAddressController.text, - mobileNumber: widget - .model - .checkPatientForRegistrationModel - .patientMobileNumber), - isHijri: 0, - logInTokenID: "zjgvKtLC/EK+saznJ/OkiA==", - isDentalAllowedBackend: false, - patientOutSA: 0, - sessionID: null, - patientMobileNumber: - widget.model.checkPatientForRegistrationModel.patientMobileNumber.toString(), - healthId: widget.model.getPatientInfoResponseModel.healthId, - generalid: GENERAL_ID, - patientIdentificationID: widget.model.checkPatientForRegistrationModel.patientIdentificationID.toString(), - dOB:wellFormat, - zipCode: widget.model.checkPatientForRegistrationModel.zipCode); - await widget.model - .registrationPatient(patientRegistrationModel); - if (widget.model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(widget.model.error); - } else { - DrAppToastMsg.showSuccesToast("Patient added Successfully"); - Navigator.of(context).pop(); + GifLoaderDialogUtils.hideDialog(context); } - - GifLoaderDialogUtils.hideDialog(context); }, ), ), @@ -598,14 +631,16 @@ class _RegisterConfirmationPatientPageState height: 10, ), InkWell( - onTap: () {}, + onTap: () { + setSelectedLang(1); + }, child: Row( children: [ Radio( value: 1, - groupValue: 1, + groupValue: selectedLang, onChanged: (value) { - setState(() {}); + setSelectedLang(value); }, activeColor: Colors.red, ), @@ -619,14 +654,17 @@ class _RegisterConfirmationPatientPageState ), ), InkWell( - onTap: () {}, + onTap: () { + setSelectedLang(2); + }, child: Row( children: [ Radio( - value: 1, - groupValue: 1, + value: 2, + groupValue: selectedLang, onChanged: (value) { - setState(() {}); + setSelectedLang(value); + }, activeColor: Colors.red, ), @@ -644,4 +682,23 @@ class _RegisterConfirmationPatientPageState ); }); } + setSelectedLang(lang){ + setState(() { + selectedLang = lang; + langController.text = lang==1?"English": "العربيه"; + }); + Navigator.of(context).pop(); + } + + bool isFormValid() { + if (middleNameAr.text != null && + middleNameAr.text.isNotEmpty && + middleNameN.text != null && + middleNameN.text.isNotEmpty && + emailAddressController.text != null && + emailAddressController.text.isNotEmpty) { + return true; + } + return false; + } } diff --git a/lib/screens/patients/register_patient/RegisterPatientPage.dart b/lib/screens/patients/register_patient/RegisterPatientPage.dart index 55c27fb4..810d5cf7 100644 --- a/lib/screens/patients/register_patient/RegisterPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterPatientPage.dart @@ -52,7 +52,7 @@ class _RegisterPatientPageState extends State @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; - + ///TODO Elham* Add Translation return BaseView( builder: (_, model, w) => AppScaffold( baseViewModel: model, @@ -72,6 +72,7 @@ class _RegisterPatientPageState extends State SizedBox( height: 10, ), + //TODO Elham* Fix overflow PageStepperWidget( stepsCount: 3, currentStepIndex: _currentIndex + 1, diff --git a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart index 98ac704e..09ece413 100644 --- a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart @@ -36,6 +36,8 @@ class RegisterSearchPatientPage extends StatefulWidget { class _RegisterSearchPatientPageState extends State { String countryError; dynamic _selectedCountry; + bool isSubmitted = false; + TextEditingController _phoneController = TextEditingController(); TextEditingController _phoneCode = TextEditingController(text: "966"); @@ -51,6 +53,7 @@ class _RegisterSearchPatientPageState extends State { @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; + /// TODO Elham* add transaltion return AppScaffold( baseViewModel: widget.model, @@ -83,47 +86,32 @@ class _RegisterSearchPatientPageState extends State { ? _selectedCountry['nameEn'] : "Saudi Arabia", enabled: false, - /*onClick: widget.model.dietTypesList != null && widget.model.dietTypesList.length > 0 - ? () { - openListDialogField('nameEn', 'id', widget.model.dietTypesList, (selectedValue) { - setState(() { - _selectedCountry = selectedValue; - }); - }); - } - : () async { - GifLoaderDialogUtils.showMyDialog(context); - await model - .getDietTypes(patient.patientId) - .then((_) => GifLoaderDialogUtils.hideDialog(context)); - if (widget.model.state == ViewState.Idle && widget.model.dietTypesList.length > 0) { - openListDialogField('nameEn', 'id', widget.model.dietTypesList, (selectedValue) { - setState(() { - _selectedCountry = selectedValue; - }); - }); - } else if (widget.model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(widget.model.error); - } else { - DrAppToastMsg.showErrorToast("Empty List"); - } - },*/ ), SizedBox( height: 10, ), Row( children: [ - Container( - width: MediaQuery.of(context).size.width * 0.3, - child: AppTextFieldCustom( - height: screenSize.height * 0.075, - hintText: "Code", - inputType: TextInputType.phone, - controller: _phoneCode, - validationError: phoneError, - ), + Column( + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.28, + child: AppTextFieldCustom( + height: screenSize.height * 0.075, + hintText: "Code", + inputType: TextInputType.phone, + controller: _phoneCode, + validationError: phoneError, + ), + ), + if(_phoneController + .text.isEmpty && + isSubmitted + ) + SizedBox(height: 35,) + ], ), + SizedBox(width: 10,), Expanded( child: Container( // width: MediaQuery.of(context).size.width*0.7, @@ -132,7 +120,12 @@ class _RegisterSearchPatientPageState extends State { hintText: "Phone Number", inputType: TextInputType.phone, controller: _phoneController, - validationError: phoneError, + validationError: _phoneController + .text.isEmpty && + isSubmitted + ? TranslationBase.of(context) + .emptyMessage + : null, ), ), ), @@ -146,7 +139,12 @@ class _RegisterSearchPatientPageState extends State { hintText: "ID Number", inputType: TextInputType.phone, controller: _idController, - validationError: idError, + validationError: _idController + .text.isEmpty && + isSubmitted + ? TranslationBase.of(context) + .emptyMessage + : null, ), SizedBox( height: 12, @@ -167,7 +165,11 @@ class _RegisterSearchPatientPageState extends State { : null, enabled: false, isTextFieldHasSuffix: true, - validationError: birthdateError, + validationError: _birthDate == null && + isSubmitted + ? TranslationBase.of(context) + .emptyMessage + : null, suffixIcon: IconButton( icon: Icon( Icons.calendar_today, @@ -230,45 +232,54 @@ class _RegisterSearchPatientPageState extends State { fontColor: Colors.white, fontSize: 2.0, onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); - CheckPatientForRegistrationModel - checkPatientForRegistrationModel = - CheckPatientForRegistrationModel( - patientIdentificationID: - int.parse(_idController.text), - patientMobileNumber: - int.parse(_phoneController.text), - zipCode: _phoneCode.text, + setState(() { + isSubmitted = true; + }); + if(isFormValid()) { + GifLoaderDialogUtils.showMyDialog(context); + CheckPatientForRegistrationModel + checkPatientForRegistrationModel = + CheckPatientForRegistrationModel( + patientIdentificationID: + int.parse(_idController.text), + patientMobileNumber: + int.parse(_phoneController.text), + zipCode: _phoneCode.text, + isHijri: 0, + patientID: 0, + isRegister: false, + isDentalAllowedBackend: false, + patientOutSA: 0, + generalid: GENERAL_ID, + dOB: + "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"); + await widget.model.checkPatientForRegistration( + checkPatientForRegistrationModel); + GetPatientInfoRequestModel getPatientInfoRequestModel = + GetPatientInfoRequestModel( + //TODO Elham* this return the static to dynamic + patientIdentificationID:"1062938285", //_idController.text, isHijri: 0, - patientID: 0, - isRegister: false, isDentalAllowedBackend: false, patientOutSA: 0, generalid: GENERAL_ID, - dOB: - "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"); - await widget.model.checkPatientForRegistration( - checkPatientForRegistrationModel); - GetPatientInfoRequestModel getPatientInfoRequestModel = - GetPatientInfoRequestModel( - //TODO Elham* this return the static to dynamic - patientIdentificationID:"1062938285", //_idController.text, - isHijri: 0, - isDentalAllowedBackend: false, - patientOutSA: 0, - generalid: GENERAL_ID, - sessionID: null, - dOB:"31/07/1988",//"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}" + sessionID: null, + dOB:"31/07/1988",//"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}" - ); - await widget.model.getPatientInfo(getPatientInfoRequestModel); - if (widget.model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(widget.model.error); - } else { - widget.changePageViewIndex(1); + ); + if (widget.model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(widget.model.error); + } else { + await widget.model.getPatientInfo(getPatientInfoRequestModel); + if (widget.model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(widget.model.error); + } else { + widget.changePageViewIndex(1); + } + } + GifLoaderDialogUtils.hideDialog(context); } - GifLoaderDialogUtils.hideDialog(context); }, ), ), @@ -279,6 +290,14 @@ class _RegisterSearchPatientPageState extends State { ); } + + isFormValid() { + if(_phoneController.text!=null &&_phoneController.text.isNotEmpty&& _idController.text!=null &&_idController.text.isNotEmpty) { + return true; + } + return false; + + } Future _selectDate(BuildContext context, DateTime dateTime, Function(DateTime picked) updateDate) async { final DateTime picked = await showDatePicker( From cf498de70f1426c23859809078b31752728ee764 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 4 Nov 2021 16:27:43 +0200 Subject: [PATCH 7/8] finish confirmation page --- lib/client/base_app_client.dart | 105 ++++++++++++------ lib/config/config.dart | 4 +- ...PNotificationTypeForRegistrationModel.dart | 48 ++++---- .../service/PatientRegistrationService.dart | 48 +++++--- lib/screens/home/home_screen.dart | 3 +- .../RegisterSearchPatientPage.dart | 6 +- .../register_patient/VerifyMethodPage.dart | 51 +++++++-- 7 files changed, 176 insertions(+), 89 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 7e787b90..af4e6e97 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -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(AppGlobal.CONTEX, listen: false).logout(); + await Provider.of(AppGlobal.CONTEX, + listen: false) + .logout(); Helpers.showErrorToast('Your session expired Please login again'); locator().pushNamedAndRemoveUntil(ROOT); @@ -147,10 +164,14 @@ class BaseAppClient { String url = BASE_URL + endPoint; try { - Map headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}; + Map 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"; } } } diff --git a/lib/config/config.dart b/lib/config/config.dart index 04a6d7bc..c01434ce 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -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"; diff --git a/lib/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart b/lib/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart index 8aaf2c6c..8244a95f 100644 --- a/lib/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart +++ b/lib/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart @@ -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 json) { diff --git a/lib/core/service/PatientRegistrationService.dart b/lib/core/service/PatientRegistrationService.dart index ed3db005..236bcd42 100644 --- a/lib/core/service/PatientRegistrationService.dart +++ b/lib/core/service/PatientRegistrationService.dart @@ -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( diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 1ab61717..62988caa 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -399,7 +399,8 @@ class _HomeScreenState extends State { 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: () { diff --git a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart index 09ece413..ee8caa90 100644 --- a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart @@ -39,12 +39,12 @@ class _RegisterSearchPatientPageState extends State { 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 { 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; diff --git a/lib/screens/patients/register_patient/VerifyMethodPage.dart b/lib/screens/patients/register_patient/VerifyMethodPage.dart index b959e0a8..6426c382 100644 --- a/lib/screens/patients/register_patient/VerifyMethodPage.dart +++ b/lib/screens/patients/register_patient/VerifyMethodPage.dart @@ -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 { bool isSendOtp = false; final verifyAccountForm = GlobalKey(); + TextStyle buildTextStyle() { return TextStyle( fontSize: SizeConfig.textMultiplier * 3, @@ -74,13 +78,14 @@ class _ActivationPageState extends State { 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 { 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 { 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 { : 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: " ", From 515297ebf67e93335172bc8816f1aba4ade6d267 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 4 Nov 2021 16:27:58 +0200 Subject: [PATCH 8/8] finish confirmation page --- .../PatientRegistrationViewModel.dart | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/core/viewModel/PatientRegistrationViewModel.dart b/lib/core/viewModel/PatientRegistrationViewModel.dart index 82b43baa..866f99a8 100644 --- a/lib/core/viewModel/PatientRegistrationViewModel.dart +++ b/lib/core/viewModel/PatientRegistrationViewModel.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/PatientRegistration/CheckActivationCodeModel.dart'; import 'package:doctor_app_flutter/core/model/PatientRegistration/CheckPatientForRegistrationModel.dart'; @@ -145,26 +146,53 @@ class PatientRegistrationViewModel extends BaseViewModel { registrationModel, int otpType, PatientRegistrationViewModel user}) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); print(checkPatientForRegistrationModel); print(checkPatientForRegistrationModel); await _patientRegistrationService.sendActivationCodeByOTPNotificationType( otpType: otpType, + model: this, checkPatientForRegistrationModel: checkPatientForRegistrationModel); if (_patientRegistrationService.hasError) { error = _patientRegistrationService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } - Future checkActivationCode(CheckActivationCodeModel registrationModel) async { - setState(ViewState.Busy); - await _patientRegistrationService.checkActivationCode(registrationModel); + Future checkActivationCode(String code) async { + CheckActivationCodeModel model = CheckActivationCodeModel( + activationCode: code, + patientIdentificationID: + checkPatientForRegistrationModel.patientIdentificationID, + patientMobileNumber: checkPatientForRegistrationModel.patientMobileNumber, + zipCode: checkPatientForRegistrationModel.zipCode, + patientOutSA: 0, + healthId: getPatientInfoResponseModel.healthId, + dOB: checkPatientForRegistrationModel.dOB, + isRegister: checkPatientForRegistrationModel.isRegister, + isHijri: checkPatientForRegistrationModel.isHijri, + sessionID: null, + generalid: GENERAL_ID, + forRegisteration: true, + isDentalAllowedBackend: false, + projectOutSA: 0, + searchType: 1, + versionID: 7.1, + channel: 3, + // TODO Elham* loginType + loginType: 4, + logInTokenID:_patientRegistrationService.logInTokenID , + nationalID: checkPatientForRegistrationModel.patientIdentificationID, + patientID: 0, + mobileNo: checkPatientForRegistrationModel.patientMobileNumber.toString(), + ); + setState(ViewState.BusyLocal); + await _patientRegistrationService.checkActivationCode(model); if (_patientRegistrationService.hasError) { error = _patientRegistrationService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); }