|
|
@ -18,14 +18,15 @@ import 'package:doctor_app_flutter/widgets/shared/dialogs/dailog-list-select.dar
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.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:doctor_app_flutter/widgets/shared/text_fields/country_textfield_custom.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class RegisterSearchPatientPage extends StatefulWidget {
|
|
|
|
class RegisterSearchPatientPage extends StatefulWidget {
|
|
|
|
final Function changePageViewIndex;
|
|
|
|
final Function changePageViewIndex;
|
|
|
|
final PatientRegistrationViewModel model;
|
|
|
|
final PatientRegistrationViewModel model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const RegisterSearchPatientPage(
|
|
|
|
const RegisterSearchPatientPage({Key key, this.changePageViewIndex, this.model})
|
|
|
|
{Key key, this.changePageViewIndex, this.model})
|
|
|
|
: super(key: key);
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -36,23 +37,42 @@ 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<dynamic> countryList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dynamic country;
|
|
|
|
|
|
|
|
|
|
|
|
TextEditingController _phoneController = TextEditingController(text: "508079569");
|
|
|
|
bool isSubmitted = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextEditingController _phoneController =
|
|
|
|
|
|
|
|
TextEditingController(text: "508079569");
|
|
|
|
TextEditingController _phoneCode = TextEditingController(text: "966");
|
|
|
|
TextEditingController _phoneCode = TextEditingController(text: "966");
|
|
|
|
|
|
|
|
|
|
|
|
String phoneError;
|
|
|
|
String phoneError;
|
|
|
|
|
|
|
|
|
|
|
|
TextEditingController _idController = TextEditingController(text: "1062938285");
|
|
|
|
TextEditingController _idController =
|
|
|
|
|
|
|
|
TextEditingController(text: "1062938285");
|
|
|
|
String idError;
|
|
|
|
String idError;
|
|
|
|
|
|
|
|
|
|
|
|
DateTime _birthDate;
|
|
|
|
DateTime _birthDate;
|
|
|
|
String birthdateError;
|
|
|
|
String birthdateError;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
_phoneCode.text = "";
|
|
|
|
|
|
|
|
countryList = List();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dynamic ksaCountry = {"id": 967, "name": "Saudi Arabia"};
|
|
|
|
|
|
|
|
dynamic uaeCountry = {"id": 971, "name": "United Arab Emirates"};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
countryList.add(ksaCountry);
|
|
|
|
|
|
|
|
countryList.add(uaeCountry);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
/// TODO Elham* add transaltion
|
|
|
|
|
|
|
|
|
|
|
|
return AppScaffold(
|
|
|
|
return AppScaffold(
|
|
|
@ -77,15 +97,19 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
SizedBox(
|
|
|
|
SizedBox(
|
|
|
|
height: 10,
|
|
|
|
height: 10,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
AppTextFieldCustom(
|
|
|
|
CountryTextField(
|
|
|
|
height: screenSize.height * 0.075,
|
|
|
|
elementList: countryList,
|
|
|
|
|
|
|
|
element: country,
|
|
|
|
|
|
|
|
elementError: countryError,
|
|
|
|
|
|
|
|
keyName: 'name',
|
|
|
|
|
|
|
|
keyId: 'id',
|
|
|
|
|
|
|
|
okFunction: (selectedValue) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
country = selectedValue;
|
|
|
|
|
|
|
|
_phoneCode.text = selectedValue['id'].toString();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
hintText: "Country",
|
|
|
|
hintText: "Country",
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
|
|
|
|
validationError: countryError,
|
|
|
|
|
|
|
|
dropDownText: _selectedCountry != null
|
|
|
|
|
|
|
|
? _selectedCountry['nameEn']
|
|
|
|
|
|
|
|
: "Saudi Arabia",
|
|
|
|
|
|
|
|
enabled: false,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
SizedBox(
|
|
|
|
height: 10,
|
|
|
|
height: 10,
|
|
|
@ -102,16 +126,18 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
inputType: TextInputType.phone,
|
|
|
|
inputType: TextInputType.phone,
|
|
|
|
controller: _phoneCode,
|
|
|
|
controller: _phoneCode,
|
|
|
|
validationError: phoneError,
|
|
|
|
validationError: phoneError,
|
|
|
|
|
|
|
|
enabled: false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if(_phoneController
|
|
|
|
if (_phoneController.text.isEmpty && isSubmitted)
|
|
|
|
.text.isEmpty &&
|
|
|
|
SizedBox(
|
|
|
|
isSubmitted
|
|
|
|
height: 35,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
SizedBox(height: 35,)
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(width: 10,),
|
|
|
|
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,
|
|
|
@ -120,12 +146,10 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
hintText: "Phone Number",
|
|
|
|
hintText: "Phone Number",
|
|
|
|
inputType: TextInputType.phone,
|
|
|
|
inputType: TextInputType.phone,
|
|
|
|
controller: _phoneController,
|
|
|
|
controller: _phoneController,
|
|
|
|
validationError: _phoneController
|
|
|
|
validationError:
|
|
|
|
.text.isEmpty &&
|
|
|
|
_phoneController.text.isEmpty && isSubmitted
|
|
|
|
isSubmitted
|
|
|
|
? TranslationBase.of(context).emptyMessage
|
|
|
|
? TranslationBase.of(context)
|
|
|
|
: null,
|
|
|
|
.emptyMessage
|
|
|
|
|
|
|
|
: null,
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -139,11 +163,8 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
hintText: "ID Number",
|
|
|
|
hintText: "ID Number",
|
|
|
|
inputType: TextInputType.phone,
|
|
|
|
inputType: TextInputType.phone,
|
|
|
|
controller: _idController,
|
|
|
|
controller: _idController,
|
|
|
|
validationError: _idController
|
|
|
|
validationError: _idController.text.isEmpty && isSubmitted
|
|
|
|
.text.isEmpty &&
|
|
|
|
? TranslationBase.of(context).emptyMessage
|
|
|
|
isSubmitted
|
|
|
|
|
|
|
|
? TranslationBase.of(context)
|
|
|
|
|
|
|
|
.emptyMessage
|
|
|
|
|
|
|
|
: null,
|
|
|
|
: null,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
SizedBox(
|
|
|
@ -165,10 +186,8 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
: null,
|
|
|
|
: null,
|
|
|
|
enabled: false,
|
|
|
|
enabled: false,
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
validationError: _birthDate == null &&
|
|
|
|
validationError: _birthDate == null && isSubmitted
|
|
|
|
isSubmitted
|
|
|
|
? TranslationBase.of(context).emptyMessage
|
|
|
|
? TranslationBase.of(context)
|
|
|
|
|
|
|
|
.emptyMessage
|
|
|
|
|
|
|
|
: null,
|
|
|
|
: null,
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
icon: Icon(
|
|
|
@ -235,42 +254,48 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
isSubmitted = true;
|
|
|
|
isSubmitted = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if(isFormValid()) {
|
|
|
|
if (country == null) {
|
|
|
|
|
|
|
|
countryError = TranslationBase.of(context).fieldRequired;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
countryError = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isFormValid()) {
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
CheckPatientForRegistrationModel
|
|
|
|
CheckPatientForRegistrationModel
|
|
|
|
checkPatientForRegistrationModel =
|
|
|
|
checkPatientForRegistrationModel =
|
|
|
|
CheckPatientForRegistrationModel(
|
|
|
|
CheckPatientForRegistrationModel(
|
|
|
|
patientIdentificationID:
|
|
|
|
patientIdentificationID:
|
|
|
|
int.parse(_idController.text),
|
|
|
|
int.parse(_idController.text),
|
|
|
|
patientMobileNumber:
|
|
|
|
patientMobileNumber:
|
|
|
|
int.parse(_phoneController.text),
|
|
|
|
int.parse(_phoneController.text),
|
|
|
|
zipCode: _phoneCode.text,
|
|
|
|
zipCode: _phoneCode.text,
|
|
|
|
isHijri: 0,
|
|
|
|
isHijri: 0,
|
|
|
|
patientID: 0,
|
|
|
|
patientID: 0,
|
|
|
|
isRegister: false,
|
|
|
|
isRegister: false,
|
|
|
|
isDentalAllowedBackend: false,
|
|
|
|
isDentalAllowedBackend: false,
|
|
|
|
patientOutSA: 0,
|
|
|
|
patientOutSA: 0,
|
|
|
|
generalid: GENERAL_ID,
|
|
|
|
generalid: GENERAL_ID,
|
|
|
|
dOB:
|
|
|
|
dOB:
|
|
|
|
"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}");
|
|
|
|
"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}");
|
|
|
|
await widget.model.checkPatientForRegistration(
|
|
|
|
await widget.model.checkPatientForRegistration(
|
|
|
|
checkPatientForRegistrationModel);
|
|
|
|
checkPatientForRegistrationModel);
|
|
|
|
GetPatientInfoRequestModel getPatientInfoRequestModel =
|
|
|
|
GetPatientInfoRequestModel getPatientInfoRequestModel =
|
|
|
|
GetPatientInfoRequestModel(
|
|
|
|
GetPatientInfoRequestModel(
|
|
|
|
//TODO Elham* this return the static to dynamic
|
|
|
|
//TODO Elham* this return the static to dynamic
|
|
|
|
patientIdentificationID:"1062938285", //_idController.text,
|
|
|
|
//patientIdentificationID:"1062938285", _idController.text,
|
|
|
|
isHijri: 0,
|
|
|
|
isHijri: 0,
|
|
|
|
isDentalAllowedBackend: false,
|
|
|
|
isDentalAllowedBackend: false,
|
|
|
|
patientOutSA: 0,
|
|
|
|
patientOutSA: 0,
|
|
|
|
generalid: GENERAL_ID,
|
|
|
|
generalid: GENERAL_ID,
|
|
|
|
sessionID: null,
|
|
|
|
sessionID: null,
|
|
|
|
dOB:"31/07/1988",//"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}"
|
|
|
|
dOB:
|
|
|
|
|
|
|
|
"31/07/1988", //"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
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);
|
|
|
|
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 {
|
|
|
@ -279,7 +304,6 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -290,14 +314,17 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isFormValid() {
|
|
|
|
isFormValid() {
|
|
|
|
if(_phoneController.text!=null &&_phoneController.text.isNotEmpty&& _idController.text!=null &&_idController.text.isNotEmpty &&_birthDate!=null) {
|
|
|
|
if (_phoneController.text != null &&
|
|
|
|
|
|
|
|
_phoneController.text.isNotEmpty &&
|
|
|
|
|
|
|
|
_idController.text != null &&
|
|
|
|
|
|
|
|
_idController.text.isNotEmpty &&
|
|
|
|
|
|
|
|
_birthDate != null) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
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(
|
|
|
|