|
|
|
|
@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/patient/patient_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/routes.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/helpers.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
|
|
import '../../config/size_config.dart';
|
|
|
|
|
@ -19,6 +20,7 @@ import '../../config/config.dart';
|
|
|
|
|
import '../../models/doctor_profile_model.dart';
|
|
|
|
|
|
|
|
|
|
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
|
|
|
|
Helpers helpers = Helpers();
|
|
|
|
|
|
|
|
|
|
// OWNER : Ibrahim albitar
|
|
|
|
|
// DATE : 19-04-2020
|
|
|
|
|
@ -32,7 +34,7 @@ class PatientSearchScreen extends StatefulWidget {
|
|
|
|
|
class _PatientSearchScreenState extends State<PatientSearchScreen> {
|
|
|
|
|
String _selectedType = '1';
|
|
|
|
|
String _selectedLocation = '1';
|
|
|
|
|
|
|
|
|
|
String error = '';
|
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
bool _autoValidate = false;
|
|
|
|
|
|
|
|
|
|
@ -59,45 +61,50 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
|
|
|
|
|
PatientOutSA: false);
|
|
|
|
|
|
|
|
|
|
void _validateInputs() async {
|
|
|
|
|
print("####IBRAHIM TEST#####" + _patientSearchFormValues.From);
|
|
|
|
|
// _patientSearchFormValues.TokenID =
|
|
|
|
|
List <dynamic> doctorProfiles = await sharedPref.getObj(DOCTOR_PROFILE);
|
|
|
|
|
DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(doctorProfiles[0]);
|
|
|
|
|
print(doctorProfile.doctorName);
|
|
|
|
|
if (_formKey.currentState.validate()) {
|
|
|
|
|
try {
|
|
|
|
|
print("####IBRAHIM TEST#####" + _patientSearchFormValues.From);
|
|
|
|
|
// _patientSearchFormValues.TokenID =
|
|
|
|
|
List<dynamic> doctorProfiles = await sharedPref.getObj(DOCTOR_PROFILE);
|
|
|
|
|
DoctorProfileModel doctorProfile =
|
|
|
|
|
DoctorProfileModel.fromJson(doctorProfiles[0]);
|
|
|
|
|
print(doctorProfile.doctorName);
|
|
|
|
|
if (_formKey.currentState.validate()) {
|
|
|
|
|
//*****If all data are correct then save data to out variables****
|
|
|
|
|
|
|
|
|
|
_patientSearchFormValues.setFrom = "0";
|
|
|
|
|
_patientSearchFormValues.setTo = "0";
|
|
|
|
|
print("***************Check validate1*************");
|
|
|
|
|
|
|
|
|
|
print(_patientSearchFormValues.getFirstName.trim().length);
|
|
|
|
|
print("***************Check validate2*************");
|
|
|
|
|
|
|
|
|
|
_formKey.currentState.save();
|
|
|
|
|
_patientSearchFormValues.setFrom = "0";
|
|
|
|
|
_patientSearchFormValues.setTo = "0";
|
|
|
|
|
|
|
|
|
|
//*********************************** */
|
|
|
|
|
sharedPref.setString(TOKEN, '@dm!n');
|
|
|
|
|
sharedPref.setString(SLECTED_PATIENT_TYPE, _selectedType);
|
|
|
|
|
print('_selectedType${_selectedType}');
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
int projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
_patientSearchFormValues.TokenID = token;
|
|
|
|
|
_patientSearchFormValues.ProjectID = 15; //projectID;
|
|
|
|
|
// print(_patientSearchFormValues.PatientMobileNumber+"dfdfdfddf");
|
|
|
|
|
Navigator.of(context).pushNamed(PATIENTS, arguments: {
|
|
|
|
|
"patientSearchForm": _patientSearchFormValues,
|
|
|
|
|
"selectedType": _selectedType
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
//*********************************** */
|
|
|
|
|
sharedPref.setString(TOKEN, '@dm!n');
|
|
|
|
|
sharedPref.setString(SLECTED_PATIENT_TYPE, _selectedType);
|
|
|
|
|
print('_selectedType${_selectedType}');
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
int projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
_patientSearchFormValues.TokenID = token;
|
|
|
|
|
_patientSearchFormValues.ProjectID = 15; //projectID;
|
|
|
|
|
// print(_patientSearchFormValues.PatientMobileNumber+"dfdfdfddf");
|
|
|
|
|
Navigator.of(context).pushNamed(PATIENTS, arguments: {
|
|
|
|
|
"patientSearchForm": _patientSearchFormValues,
|
|
|
|
|
"selectedType": _selectedType
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// If all data are not valid then start auto validation.
|
|
|
|
|
setState(() {
|
|
|
|
|
_autoValidate = true;
|
|
|
|
|
});
|
|
|
|
|
setState(() {
|
|
|
|
|
_autoValidate = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handelCatchErrorCase(err) {
|
|
|
|
|
//isLoading = false;
|
|
|
|
|
//isError = true;
|
|
|
|
|
error = helpers.generateContactAdminMsg(err);
|
|
|
|
|
//notifyListeners();
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
@ -187,17 +194,13 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
hintText: 'First Name',
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
// _patientSearchFormValues.FirstName = value;
|
|
|
|
|
value == null
|
|
|
|
|
? _patientSearchFormValues.setFirstName =
|
|
|
|
|
"0"
|
|
|
|
|
: _patientSearchFormValues.setFirstName =
|
|
|
|
|
value;
|
|
|
|
|
print("**********Value********");
|
|
|
|
|
print(value.toString().trim().isEmpty);
|
|
|
|
|
print("**********Value********");
|
|
|
|
|
|
|
|
|
|
if (value.toString().trim().isEmpty) {
|
|
|
|
|
|
|
|
|
|
_patientSearchFormValues.setFirstName = "0";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -211,19 +214,14 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
hintText: 'Middle Name',
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
//_patientSearchFormValues.MiddleName = value;
|
|
|
|
|
|
|
|
|
|
value == null
|
|
|
|
|
? _patientSearchFormValues.setMiddleName =
|
|
|
|
|
"0"
|
|
|
|
|
: _patientSearchFormValues.setMiddleName =
|
|
|
|
|
value;
|
|
|
|
|
|
|
|
|
|
// value.toString().trim().isEmpty
|
|
|
|
|
// ? _patientSearchFormValues.setMiddleName =
|
|
|
|
|
// "0"
|
|
|
|
|
// : _patientSearchFormValues.setMiddleName =
|
|
|
|
|
// value;
|
|
|
|
|
if (value.toString().trim().isEmpty) {
|
|
|
|
|
_patientSearchFormValues.setMiddleName = "0";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// validator: (value) {
|
|
|
|
|
// return TextValidator().validateName(value);
|
|
|
|
|
@ -235,16 +233,13 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
|
|
|
|
|
AppTextFormField(
|
|
|
|
|
hintText: 'Last Name',
|
|
|
|
|
onSaved: (value) {
|
|
|
|
|
// _patientSearchFormValues.LastName = value;
|
|
|
|
|
value == null
|
|
|
|
|
? _patientSearchFormValues.setLastName = "0"
|
|
|
|
|
: _patientSearchFormValues.setLastName =
|
|
|
|
|
value;
|
|
|
|
|
|
|
|
|
|
// value.toString().trim().isEmpty
|
|
|
|
|
// ? _patientSearchFormValues.setLastName = "0"
|
|
|
|
|
// : _patientSearchFormValues.setLastName =
|
|
|
|
|
// value;
|
|
|
|
|
if (value.toString().trim().isEmpty) {
|
|
|
|
|
_patientSearchFormValues.setLastName = "0";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// validator: (value) {
|
|
|
|
|
// return TextValidator().validateName(value);
|
|
|
|
|
@ -266,8 +261,11 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
|
|
|
|
|
.setPatientMobileNumber = "0"
|
|
|
|
|
: _patientSearchFormValues
|
|
|
|
|
.setPatientMobileNumber = value;
|
|
|
|
|
// _patientSearchFormValues.PatientMobileNumber =
|
|
|
|
|
// value;
|
|
|
|
|
|
|
|
|
|
if (value.toString().trim().isEmpty) {
|
|
|
|
|
_patientSearchFormValues
|
|
|
|
|
.setPatientMobileNumber = "0";
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
@ -285,6 +283,9 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
|
|
|
|
|
? _patientSearchFormValues.setPatientID = 0
|
|
|
|
|
: _patientSearchFormValues.setPatientID =
|
|
|
|
|
int.parse(value);
|
|
|
|
|
if (value.toString().trim().isEmpty) {
|
|
|
|
|
_patientSearchFormValues.setPatientID = 0;
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 10,
|
|
|
|
|
|