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/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<CustomEditableText> {
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,

@ -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;
}
}

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

@ -36,6 +36,8 @@ class RegisterSearchPatientPage extends StatefulWidget {
class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
String countryError;
dynamic _selectedCountry;
bool isSubmitted = false;
TextEditingController _phoneController = TextEditingController();
TextEditingController _phoneCode = TextEditingController(text: "966");
@ -51,6 +53,7 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
@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<RegisterSearchPatientPage> {
? _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<RegisterSearchPatientPage> {
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<RegisterSearchPatientPage> {
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<RegisterSearchPatientPage> {
: 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<RegisterSearchPatientPage> {
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<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,
Function(DateTime picked) updateDate) async {
final DateTime picked = await showDatePicker(

Loading…
Cancel
Save