|
|
|
|
@ -20,6 +20,10 @@ import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils
|
|
|
|
|
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: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;
|
|
|
|
|
@ -54,8 +58,10 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
TextEditingController(text: "1062938285");
|
|
|
|
|
String idError;
|
|
|
|
|
|
|
|
|
|
DateTime _birthDate;
|
|
|
|
|
DateTime _birthDateInGregorian;
|
|
|
|
|
String birthdateError;
|
|
|
|
|
var birthDateInHijri = new HijriCalendar.now();
|
|
|
|
|
CalenderType calenderType = CalenderType.Gregorian;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -178,15 +184,44 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: RadioListTile<CalenderType>(
|
|
|
|
|
title: AppText("Gregorian"),
|
|
|
|
|
value: CalenderType.Gregorian,
|
|
|
|
|
groupValue: calenderType,
|
|
|
|
|
onChanged: (CalenderType value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
calenderType = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: RadioListTile<CalenderType>(
|
|
|
|
|
title: AppText("Hijri"),
|
|
|
|
|
value: CalenderType.Hijri,
|
|
|
|
|
groupValue: calenderType,
|
|
|
|
|
onChanged: (CalenderType value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
calenderType = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
),
|
|
|
|
|
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
|
|
|
|
|
validationError: _birthDateInGregorian == null && isSubmitted
|
|
|
|
|
? TranslationBase.of(context).emptyMessage
|
|
|
|
|
: null,
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
@ -197,12 +232,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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
@ -276,13 +328,14 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
patientOutSA: 0,
|
|
|
|
|
generalid: GENERAL_ID,
|
|
|
|
|
dOB:
|
|
|
|
|
"${AppDateUtils.convertStringToDateFormat(_birthDate.toString(), "yyyy/MM/dd")}");
|
|
|
|
|
"${AppDateUtils.convertStringToDateFormat(_birthDateInGregorian.toString(), "yyyy/MM/dd")}");
|
|
|
|
|
await widget.model.checkPatientForRegistration(
|
|
|
|
|
checkPatientForRegistrationModel);
|
|
|
|
|
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,
|
|
|
|
|
@ -319,25 +372,43 @@ class _RegisterSearchPatientPageState extends State<RegisterSearchPatientPage> {
|
|
|
|
|
_phoneController.text.isNotEmpty &&
|
|
|
|
|
_idController.text != null &&
|
|
|
|
|
_idController.text.isNotEmpty &&
|
|
|
|
|
_birthDate != null) {
|
|
|
|
|
_birthDateInGregorian != null) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future _selectDate(BuildContext context, DateTime dateTime,
|
|
|
|
|
Function(DateTime picked) updateDate) async {
|
|
|
|
|
Function(dynamic) updateDate) async {
|
|
|
|
|
if (calenderType == CalenderType.Hijri) {
|
|
|
|
|
HijriCalendar hijriDate = HijriCalendar.fromDate(DateTime.now());
|
|
|
|
|
final HijriCalendar pickedH = await showHijriDatePicker(
|
|
|
|
|
context: context,
|
|
|
|
|
initialDate: birthDateInHijri ?? hijriDate,
|
|
|
|
|
lastDate: new HijriCalendar()
|
|
|
|
|
..hYear = hijriDate.hYear
|
|
|
|
|
..hMonth = hijriDate.hMonth
|
|
|
|
|
..hDay = hijriDate.hDay,
|
|
|
|
|
firstDate: new HijriCalendar()
|
|
|
|
|
..hYear = 1438
|
|
|
|
|
..hMonth = 12
|
|
|
|
|
..hDay = 25,
|
|
|
|
|
initialDatePickerMode: DatePickerMode.day,
|
|
|
|
|
);
|
|
|
|
|
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,
|
|
|
|
|
List<dynamic> list, Function(dynamic selectedValue) okFunction) {
|
|
|
|
|
@ -359,4 +430,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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|