|
|
|
|
@ -22,14 +22,14 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hijri/hijri_calendar.dart';
|
|
|
|
|
import 'package:hijri_picker/hijri_picker.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/enum/CalenderType.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
|
|
class RegisterSearchPatientPage extends StatefulWidget {
|
|
|
|
|
final Function changePageViewIndex;
|
|
|
|
|
final PatientRegistrationViewModel model;
|
|
|
|
|
|
|
|
|
|
final PatientRegistrationViewModel model;
|
|
|
|
|
|
|
|
|
|
const RegisterSearchPatientPage({Key key, this.changePageViewIndex, this.model})
|
|
|
|
|
const RegisterSearchPatientPage(
|
|
|
|
|
{Key key, this.changePageViewIndex, this.model})
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -42,25 +42,25 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
dynamic _selectedCountry;
|
|
|
|
|
bool isSubmitted = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextEditingController _phoneController = TextEditingController(text: "508079569");
|
|
|
|
|
TextEditingController _phoneController =
|
|
|
|
|
TextEditingController(text: "508079569");
|
|
|
|
|
TextEditingController _phoneCode = TextEditingController(text: "966");
|
|
|
|
|
|
|
|
|
|
String phoneError;
|
|
|
|
|
|
|
|
|
|
TextEditingController _idController = TextEditingController(text: "1062938285");
|
|
|
|
|
TextEditingController _idController =
|
|
|
|
|
TextEditingController(text: "1062938285");
|
|
|
|
|
String idError;
|
|
|
|
|
|
|
|
|
|
DateTime _birthDate;
|
|
|
|
|
DateTime _birthDateInGregorian;
|
|
|
|
|
String birthdateError;
|
|
|
|
|
var selectedHijriDate = new HijriCalendar.now();
|
|
|
|
|
var birthDateInHijri = new HijriCalendar.now();
|
|
|
|
|
CalenderType calenderType = CalenderType.Gregorian;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final screenSize = MediaQuery.of(context).size;
|
|
|
|
|
|
|
|
|
|
/// TODO Elham* add transaltion
|
|
|
|
|
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
@ -112,14 +112,15 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
validationError: phoneError,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if(_phoneController
|
|
|
|
|
.text.isEmpty &&
|
|
|
|
|
isSubmitted
|
|
|
|
|
)
|
|
|
|
|
SizedBox(height: 35,)
|
|
|
|
|
if (_phoneController.text.isEmpty && isSubmitted)
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 35,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 10,),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 10,
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
// width: MediaQuery.of(context).size.width*0.7,
|
|
|
|
|
@ -128,12 +129,10 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
hintText: "Phone Number",
|
|
|
|
|
inputType: TextInputType.phone,
|
|
|
|
|
controller: _phoneController,
|
|
|
|
|
validationError: _phoneController
|
|
|
|
|
.text.isEmpty &&
|
|
|
|
|
isSubmitted
|
|
|
|
|
? TranslationBase.of(context)
|
|
|
|
|
.emptyMessage
|
|
|
|
|
: null,
|
|
|
|
|
validationError:
|
|
|
|
|
_phoneController.text.isEmpty && isSubmitted
|
|
|
|
|
? TranslationBase.of(context).emptyMessage
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -147,11 +146,8 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
hintText: "ID Number",
|
|
|
|
|
inputType: TextInputType.phone,
|
|
|
|
|
controller: _idController,
|
|
|
|
|
validationError: _idController
|
|
|
|
|
.text.isEmpty &&
|
|
|
|
|
isSubmitted
|
|
|
|
|
? TranslationBase.of(context)
|
|
|
|
|
.emptyMessage
|
|
|
|
|
validationError: _idController.text.isEmpty && isSubmitted
|
|
|
|
|
? TranslationBase.of(context).emptyMessage
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
@ -199,15 +195,11 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
AppTextFieldCustom(
|
|
|
|
|
height: screenSize.height * 0.075,
|
|
|
|
|
hintText: "Birthdate",
|
|
|
|
|
dropDownText: _birthDate != null
|
|
|
|
|
? "${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}"
|
|
|
|
|
: null,
|
|
|
|
|
dropDownText: getBirthdate(),
|
|
|
|
|
enabled: false,
|
|
|
|
|
isTextFieldHasSuffix: true,
|
|
|
|
|
validationError: _birthDate == null &&
|
|
|
|
|
isSubmitted
|
|
|
|
|
? TranslationBase.of(context)
|
|
|
|
|
.emptyMessage
|
|
|
|
|
validationError: _birthDateInGregorian == null && isSubmitted
|
|
|
|
|
? TranslationBase.of(context).emptyMessage
|
|
|
|
|
: null,
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
@ -217,12 +209,29 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
onPressed: null,
|
|
|
|
|
),
|
|
|
|
|
onClick: () {
|
|
|
|
|
if (_birthDate == null) {
|
|
|
|
|
_birthDate = DateTime.now();
|
|
|
|
|
if (_birthDateInGregorian == null) {
|
|
|
|
|
_birthDateInGregorian = DateTime.now();
|
|
|
|
|
}
|
|
|
|
|
_selectDate(context, _birthDate, (picked) {
|
|
|
|
|
_selectDate(context, _birthDateInGregorian,
|
|
|
|
|
(dynamic selectedDate) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_birthDate = picked;
|
|
|
|
|
if (calenderType == CalenderType.Hijri) {
|
|
|
|
|
birthDateInHijri = selectedDate;
|
|
|
|
|
_birthDateInGregorian = HijriCalendar().hijriToGregorian(
|
|
|
|
|
birthDateInHijri.hYear,
|
|
|
|
|
birthDateInHijri.hMonth,
|
|
|
|
|
birthDateInHijri.hDay);
|
|
|
|
|
print(_birthDateInGregorian);
|
|
|
|
|
print(birthDateInHijri);
|
|
|
|
|
} else {
|
|
|
|
|
_birthDateInGregorian = selectedDate;
|
|
|
|
|
birthDateInHijri = HijriCalendar()
|
|
|
|
|
.gregorianToHijri(
|
|
|
|
|
selectedDate.year, selectedDate.month, selectedDate.day);
|
|
|
|
|
|
|
|
|
|
print(_birthDateInGregorian);
|
|
|
|
|
print(birthDateInHijri);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
@ -274,42 +283,44 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
setState(() {
|
|
|
|
|
isSubmitted = true;
|
|
|
|
|
});
|
|
|
|
|
if(isFormValid()) {
|
|
|
|
|
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")}");
|
|
|
|
|
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(_birthDateInGregorian.toString(), "yyyy/MM/dd")}");
|
|
|
|
|
await widget.model.checkPatientForRegistration(
|
|
|
|
|
checkPatientForRegistrationModel);
|
|
|
|
|
GetPatientInfoRequestModel getPatientInfoRequestModel =
|
|
|
|
|
GetPatientInfoRequestModel(
|
|
|
|
|
GetPatientInfoRequestModel(
|
|
|
|
|
//TODO Elham* this return the static to dynamic
|
|
|
|
|
patientIdentificationID:"1062938285", //_idController.text,
|
|
|
|
|
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")}"
|
|
|
|
|
|
|
|
|
|
dOB:
|
|
|
|
|
"31/07/1988", //"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "dd/MM/yyyy")}"
|
|
|
|
|
);
|
|
|
|
|
if (widget.model.state == ViewState.ErrorLocal) {
|
|
|
|
|
Helpers.showErrorToast(widget.model.error);
|
|
|
|
|
} else {
|
|
|
|
|
await widget.model.getPatientInfo(getPatientInfoRequestModel);
|
|
|
|
|
await widget.model
|
|
|
|
|
.getPatientInfo(getPatientInfoRequestModel);
|
|
|
|
|
if (widget.model.state == ViewState.ErrorLocal) {
|
|
|
|
|
Helpers.showErrorToast(widget.model.error);
|
|
|
|
|
} else {
|
|
|
|
|
@ -318,7 +329,6 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
}
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -329,49 +339,47 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 &&
|
|
|
|
|
_birthDateInGregorian != null) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future _selectDate(BuildContext context, DateTime dateTime,
|
|
|
|
|
Function(DateTime picked) updateDate) async {
|
|
|
|
|
if(calenderType == CalenderType.Hijri) {
|
|
|
|
|
final HijriCalendar picked = await showHijriDatePicker(
|
|
|
|
|
Function(dynamic) updateDate) async {
|
|
|
|
|
if (calenderType == CalenderType.Hijri) {
|
|
|
|
|
HijriCalendar hijriDate = HijriCalendar.fromDate(DateTime.now());
|
|
|
|
|
final HijriCalendar pickedH = await showHijriDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: selectedHijriDate,
|
|
|
|
|
|
|
|
|
|
initialDate: birthDateInHijri ?? hijriDate,
|
|
|
|
|
lastDate: new HijriCalendar()
|
|
|
|
|
..hYear = 1445
|
|
|
|
|
..hMonth = 9
|
|
|
|
|
..hDay = 25,
|
|
|
|
|
..hYear = hijriDate.hYear
|
|
|
|
|
..hMonth = hijriDate.hMonth
|
|
|
|
|
..hDay = hijriDate.hDay,
|
|
|
|
|
firstDate: new HijriCalendar()
|
|
|
|
|
..hYear = 1438
|
|
|
|
|
..hMonth = 12
|
|
|
|
|
..hDay = 25,
|
|
|
|
|
initialDatePickerMode: DatePickerMode.day,
|
|
|
|
|
);
|
|
|
|
|
if (picked != null && selectedHijriDate != picked)
|
|
|
|
|
setState(() {
|
|
|
|
|
selectedHijriDate = picked;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
if (pickedH != null && birthDateInHijri != pickedH) updateDate(pickedH);
|
|
|
|
|
} else {
|
|
|
|
|
final DateTime picked = await showDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: dateTime,
|
|
|
|
|
initialDate: dateTime ?? DateTime.now(),
|
|
|
|
|
firstDate: DateTime(DateTime.now().year - 150),
|
|
|
|
|
lastDate: DateTime(DateTime.now().year + 150),
|
|
|
|
|
lastDate: DateTime.now(),
|
|
|
|
|
initialEntryMode: DatePickerEntryMode.calendar,
|
|
|
|
|
);
|
|
|
|
|
if (picked != null && picked != dateTime) {
|
|
|
|
|
updateDate(picked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void openListDialogField(String attributeName, String attributeValueId,
|
|
|
|
|
@ -394,4 +402,18 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getBirthdate() {
|
|
|
|
|
|
|
|
|
|
if (calenderType == CalenderType.Hijri) {
|
|
|
|
|
return birthDateInHijri != null
|
|
|
|
|
? "$birthDateInHijri"
|
|
|
|
|
: null;
|
|
|
|
|
}else{
|
|
|
|
|
return _birthDateInGregorian != null
|
|
|
|
|
? "${AppDateUtils.convertStringToDateFormat(_birthDateInGregorian.toString(), "yyyy/MM/dd")}"
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|