finish confirmation page

merge-requests/879/head
Elham Rababh 4 years ago
parent 4fe53ef71e
commit ad845b882c

@ -1,4 +1,5 @@
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; 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/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -8,13 +9,14 @@ class CustomEditableText extends StatefulWidget {
Key key, Key key,
@required this.controller, @required this.controller,
this.hint, this.hint,
this.isEditable = false, this.isEditable = false, this.isSubmitted,
}) : super(key: key); }) : super(key: key);
final TextEditingController controller; final TextEditingController controller;
final String hint; final String hint;
bool isEditable; bool isEditable;
final bool isSubmitted;
@override @override
_CustomEditableTextState createState() => _CustomEditableTextState(); _CustomEditableTextState createState() => _CustomEditableTextState();
@ -77,6 +79,12 @@ class _CustomEditableTextState extends State<CustomEditableText> {
hintText: widget.hint, hintText: widget.hint,
//TranslationBase.of(context).addoperationReports, //TranslationBase.of(context).addoperationReports,
controller: widget.controller, controller: widget.controller,
validationError: widget.controller
.text.isEmpty &&
widget.isSubmitted
? TranslationBase.of(context)
.emptyMessage
: null,
maxLines: 1, maxLines: 1,
minLines: 1, minLines: 1,
hasBorder: true, hasBorder: true,

@ -63,6 +63,9 @@ class _RegisterConfirmationPatientPageState
TextEditingController middleNameAr; TextEditingController middleNameAr;
TextEditingController lastNameAr; TextEditingController lastNameAr;
TextEditingController emailAddressController; TextEditingController emailAddressController;
TextEditingController langController = TextEditingController(
text: "English");
int selectedLang = 1;
@override @override
void initState() { void initState() {
@ -84,6 +87,8 @@ class _RegisterConfirmationPatientPageState
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectViewModel = Provider.of(context); projectViewModel = Provider.of(context);
///TODO Elham* add translation
return AppScaffold( return AppScaffold(
isShowAppBar: false, isShowAppBar: false,
backgroundColor: Color(0xFFF8F8F8), backgroundColor: Color(0xFFF8F8F8),
@ -107,36 +112,44 @@ class _RegisterConfirmationPatientPageState
children: [ children: [
CustomEditableText( CustomEditableText(
controller: firstNameN, controller: firstNameN,
isSubmitted: isSubmitted,
hint: TranslationBase.of(context).firstName), hint: TranslationBase.of(context).firstName),
SizedBox( SizedBox(
height: 4, height: 4,
), ),
CustomEditableText( CustomEditableText(
controller: middleNameN, controller: middleNameN,
isEditable: middleNameN.text.isEmpty,
isSubmitted: isSubmitted,
hint: TranslationBase.of(context).middleName), hint: TranslationBase.of(context).middleName),
SizedBox( SizedBox(
height: 4, height: 4,
), ),
CustomEditableText( CustomEditableText(
controller: lastNameN, controller: lastNameN,
isSubmitted: isSubmitted,
hint: TranslationBase.of(context).lastName), hint: TranslationBase.of(context).lastName),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
CustomEditableText( CustomEditableText(
controller: firstNameAr, controller: firstNameAr,
isSubmitted: isSubmitted,
hint: "First Name Arabic"), hint: "First Name Arabic"),
SizedBox( SizedBox(
height: 4, height: 4,
), ),
CustomEditableText( CustomEditableText(
controller: middleNameAr, controller: middleNameAr,
isEditable: middleNameN.text.isEmpty,
isSubmitted: isSubmitted,
hint: "Middle Name Arabic"), hint: "Middle Name Arabic"),
SizedBox( SizedBox(
height: 4, height: 4,
), ),
CustomEditableText( CustomEditableText(
controller: lastNameAr, controller: lastNameAr,
isSubmitted: isSubmitted,
hint: "Last Name Arabic"), hint: "Last Name Arabic"),
SizedBox( SizedBox(
height: 20, height: 20,
@ -294,6 +307,7 @@ class _RegisterConfirmationPatientPageState
onClick: () { onClick: () {
openLangList(context); openLangList(context);
}, },
controller: langController,
hintText: TranslationBase.of(context).lanEnglish, hintText: TranslationBase.of(context).lanEnglish,
maxLines: 1, maxLines: 1,
minLines: 1, minLines: 1,
@ -315,6 +329,11 @@ class _RegisterConfirmationPatientPageState
maxLines: 1, maxLines: 1,
minLines: 1, minLines: 1,
hasBorder: true, hasBorder: true,
validationError:
emailAddressController.text.isEmpty &&
isSubmitted
? TranslationBase.of(context).emptyMessage
: null,
), ),
SizedBox( SizedBox(
height: 400, height: 400,
@ -367,79 +386,93 @@ class _RegisterConfirmationPatientPageState
fontColor: Colors.white, fontColor: Colors.white,
fontSize: 2.0, fontSize: 2.0,
onPressed: () async { onPressed: () async {
print(widget.model setState(() {
.getPatientInfoResponseModel.dateOfBirth); 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 ;
GifLoaderDialogUtils.showMyDialog(context);
var dateFormat = DateFormat('MM/dd/yyyy').parse(widget.model PatientRegistrationModel patientRegistrationModel =
.getPatientInfoResponseModel.dateOfBirth); PatientRegistrationModel(
String wellFormat = "${dateFormat.day}\/${dateFormat.month}\/${dateFormat.year}"; patientobject: Patientobject(
print (dateFormat.toUtc().toString()); tempValue: true,
HijriCalendar hijriDate = HijriCalendar.fromDate(new DateTime(dateFormat.year, dateFormat.month, dateFormat.day)); patientIdentificationNo: widget
// return ; .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); GifLoaderDialogUtils.hideDialog(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);
}, },
), ),
), ),
@ -598,14 +631,16 @@ class _RegisterConfirmationPatientPageState
height: 10, height: 10,
), ),
InkWell( InkWell(
onTap: () {}, onTap: () {
setSelectedLang(1);
},
child: Row( child: Row(
children: [ children: [
Radio( Radio(
value: 1, value: 1,
groupValue: 1, groupValue: selectedLang,
onChanged: (value) { onChanged: (value) {
setState(() {}); setSelectedLang(value);
}, },
activeColor: Colors.red, activeColor: Colors.red,
), ),
@ -619,14 +654,17 @@ class _RegisterConfirmationPatientPageState
), ),
), ),
InkWell( InkWell(
onTap: () {}, onTap: () {
setSelectedLang(2);
},
child: Row( child: Row(
children: [ children: [
Radio( Radio(
value: 1, value: 2,
groupValue: 1, groupValue: selectedLang,
onChanged: (value) { onChanged: (value) {
setState(() {}); setSelectedLang(value);
}, },
activeColor: Colors.red, 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;
}
} }

@ -52,7 +52,7 @@ class _RegisterPatientPageState extends State<RegisterPatientPage>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
///TODO Elham* Add Translation
return BaseView<PatientRegistrationViewModel>( return BaseView<PatientRegistrationViewModel>(
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
@ -72,6 +72,7 @@ class _RegisterPatientPageState extends State<RegisterPatientPage>
SizedBox( SizedBox(
height: 10, height: 10,
), ),
//TODO Elham* Fix overflow
PageStepperWidget( PageStepperWidget(
stepsCount: 3, stepsCount: 3,
currentStepIndex: _currentIndex + 1, currentStepIndex: _currentIndex + 1,

@ -36,6 +36,8 @@ class RegisterSearchPatientPage extends StatefulWidget {
class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> { class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
String countryError; String countryError;
dynamic _selectedCountry; dynamic _selectedCountry;
bool isSubmitted = false;
TextEditingController _phoneController = TextEditingController(); TextEditingController _phoneController = TextEditingController();
TextEditingController _phoneCode = TextEditingController(text: "966"); TextEditingController _phoneCode = TextEditingController(text: "966");
@ -51,6 +53,7 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
/// TODO Elham* add transaltion
return AppScaffold( return AppScaffold(
baseViewModel: widget.model, baseViewModel: widget.model,
@ -83,47 +86,32 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
? _selectedCountry['nameEn'] ? _selectedCountry['nameEn']
: "Saudi Arabia", : "Saudi Arabia",
enabled: false, 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( SizedBox(
height: 10, height: 10,
), ),
Row( Row(
children: [ children: [
Container( Column(
width: MediaQuery.of(context).size.width * 0.3, children: [
child: AppTextFieldCustom( Container(
height: screenSize.height * 0.075, width: MediaQuery.of(context).size.width * 0.28,
hintText: "Code", child: AppTextFieldCustom(
inputType: TextInputType.phone, height: screenSize.height * 0.075,
controller: _phoneCode, hintText: "Code",
validationError: phoneError, inputType: TextInputType.phone,
), controller: _phoneCode,
validationError: phoneError,
),
),
if(_phoneController
.text.isEmpty &&
isSubmitted
)
SizedBox(height: 35,)
],
), ),
SizedBox(width: 10,),
Expanded( Expanded(
child: Container( child: Container(
// width: MediaQuery.of(context).size.width*0.7, // width: MediaQuery.of(context).size.width*0.7,
@ -132,7 +120,12 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
hintText: "Phone Number", hintText: "Phone Number",
inputType: TextInputType.phone, inputType: TextInputType.phone,
controller: _phoneController, controller: _phoneController,
validationError: phoneError, validationError: _phoneController
.text.isEmpty &&
isSubmitted
? TranslationBase.of(context)
.emptyMessage
: null,
), ),
), ),
), ),
@ -146,7 +139,12 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
hintText: "ID Number", hintText: "ID Number",
inputType: TextInputType.phone, inputType: TextInputType.phone,
controller: _idController, controller: _idController,
validationError: idError, validationError: _idController
.text.isEmpty &&
isSubmitted
? TranslationBase.of(context)
.emptyMessage
: null,
), ),
SizedBox( SizedBox(
height: 12, height: 12,
@ -167,7 +165,11 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
: null, : null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: birthdateError, validationError: _birthDate == null &&
isSubmitted
? TranslationBase.of(context)
.emptyMessage
: null,
suffixIcon: IconButton( suffixIcon: IconButton(
icon: Icon( icon: Icon(
Icons.calendar_today, Icons.calendar_today,
@ -230,45 +232,54 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
fontColor: Colors.white, fontColor: Colors.white,
fontSize: 2.0, fontSize: 2.0,
onPressed: () async { onPressed: () async {
GifLoaderDialogUtils.showMyDialog(context); setState(() {
CheckPatientForRegistrationModel isSubmitted = true;
checkPatientForRegistrationModel = });
CheckPatientForRegistrationModel( if(isFormValid()) {
patientIdentificationID: GifLoaderDialogUtils.showMyDialog(context);
int.parse(_idController.text), CheckPatientForRegistrationModel
patientMobileNumber: checkPatientForRegistrationModel =
int.parse(_phoneController.text), CheckPatientForRegistrationModel(
zipCode: _phoneCode.text, 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, isHijri: 0,
patientID: 0,
isRegister: false,
isDentalAllowedBackend: false, isDentalAllowedBackend: false,
patientOutSA: 0, patientOutSA: 0,
generalid: GENERAL_ID, generalid: GENERAL_ID,
dOB: sessionID: null,
"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"); dOB:"31/07/1988",//"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}"
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")}"
); );
await widget.model.getPatientInfo(getPatientInfoRequestModel); if (widget.model.state == ViewState.ErrorLocal) {
if (widget.model.state == ViewState.ErrorLocal) { Helpers.showErrorToast(widget.model.error);
Helpers.showErrorToast(widget.model.error); } else {
} else { await widget.model.getPatientInfo(getPatientInfoRequestModel);
widget.changePageViewIndex(1); 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<RegisterSearchPatientPage> {
); );
} }
isFormValid() {
if(_phoneController.text!=null &&_phoneController.text.isNotEmpty&& _idController.text!=null &&_idController.text.isNotEmpty) {
return true;
}
return false;
}
Future _selectDate(BuildContext context, DateTime dateTime, Future _selectDate(BuildContext context, DateTime dateTime,
Function(DateTime picked) updateDate) async { Function(DateTime picked) updateDate) async {
final DateTime picked = await showDatePicker( final DateTime picked = await showDatePicker(

Loading…
Cancel
Save