Merge branch 'Amjad_search' into 'master'

Filter search in outpatient and format time

See merge request Cloud_Solution/doctor_app_flutter!51
merge-requests/52/merge
amjad nabil amireh 6 years ago
commit f4e82f9fd9

@ -50,9 +50,10 @@ class PatiantInformtion {
String age; String age;
String genderDescription; String genderDescription;
String nursingStationName; String nursingStationName;
String appointmentDate;
PatiantInformtion({ PatiantInformtion({
this.list, this.list,
this.projectId, this.projectId,
this.clinicId, this.clinicId,
this.doctorId, this.doctorId,
@ -85,6 +86,8 @@ class PatiantInformtion {
this.age, this.age,
this.genderDescription, this.genderDescription,
this.nursingStationName, this.nursingStationName,
this.appointmentDate,
}); });
factory PatiantInformtion.fromJson(Map<String, dynamic> json) => PatiantInformtion( factory PatiantInformtion.fromJson(Map<String, dynamic> json) => PatiantInformtion(
@ -120,6 +123,7 @@ class PatiantInformtion {
age: json["Age"], age: json["Age"],
genderDescription: json["GenderDescription"], genderDescription: json["GenderDescription"],
nursingStationName: json["NursingStationName"], nursingStationName: json["NursingStationName"],
appointmentDate: json["AppointmentDate"],
); );

@ -44,8 +44,8 @@ class PatientsProvider with ChangeNotifier {
// var srvicePatiant = ["GetMyOutPatient", "GetMyInPatient", "GtMyDischargePatient","GtMyReferredPatient","GtMyDischargeReferralPatient","GtMyTomorrowPatient","GtMyReferralPatient"]; // var srvicePatiant = ["GetMyOutPatient", "GetMyInPatient", "GtMyDischargePatient","GtMyReferredPatient","GtMyDischargeReferralPatient","GtMyTomorrowPatient","GtMyReferralPatient"];
// print("a=SERVICES_PATIANT[patientType]========='=======a"); // print("a=SERVICES_PATIANT[patientType]========='=======a");
int val = int.parse(patientType); int val = int.parse(patientType);
final url = final url ="https://uat.hmgwebservices.com/Services/DoctorApplication.svc/REST/"+ SERVICES_PATIANT[val];///"https://uat.hmgwebservices.com/Services/Doctors.svc/REST/";
BASE_URL + 'DoctorApplication.svc/REST/' + SERVICES_PATIANT[val]; //BASE_URL + 'DoctorApplication.svc/REST/' + SERVICES_PATIANT[val];
// print("a===========$url=======a"); // print("a===========$url=======a");
try { try {

@ -37,8 +37,8 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
var _patientSearchFormValues = PatientModel( var _patientSearchFormValues = PatientModel(
ProjectID: 15, ProjectID: 15,
ClinicID: 14, ClinicID: 0,
DoctorID: 243763, DoctorID: 4709,
FirstName: "0", FirstName: "0",
MiddleName: "0", MiddleName: "0",
LastName: "0", LastName: "0",
@ -64,13 +64,13 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
if (_formKey.currentState.validate()) { if (_formKey.currentState.validate()) {
// If all data are correct then save data to out variables // If all data are correct then save data to out variables
// _formKey.currentState.save(); // _formKey.currentState.save();
// sharedPref.setString(TOKEN,'@dm!n'); sharedPref.setString(TOKEN,'@dm!n');
sharedPref.setString(SLECTED_PATIENT_TYPE,_selectedType); sharedPref.setString(SLECTED_PATIENT_TYPE,_selectedType);
print('_selectedType${_selectedType}'); print('_selectedType${_selectedType}');
String token = await sharedPref.getString(TOKEN); String token = await sharedPref.getString(TOKEN);
int projectID = await sharedPref.getInt(PROJECT_ID); int projectID = await sharedPref.getInt(PROJECT_ID);
_patientSearchFormValues.TokenID = token; _patientSearchFormValues.TokenID = token;
_patientSearchFormValues.ProjectID = projectID; _patientSearchFormValues.ProjectID = 15;//projectID;
// print(_patientSearchFormValues.PatientMobileNumber+"dfdfdfddf"); // print(_patientSearchFormValues.PatientMobileNumber+"dfdfdfddf");
Navigator.of(context).pushNamed(PATIENTS, arguments: { Navigator.of(context).pushNamed(PATIENTS, arguments: {
"patientSearchForm": _patientSearchFormValues, "patientSearchForm": _patientSearchFormValues,

@ -6,6 +6,7 @@
*@desc: *@desc:
*/ */
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/models/patient/patient_model.dart';
import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart'; import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart';
@ -13,7 +14,9 @@ import 'package:doctor_app_flutter/providers/patients_provider.dart';
import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/routes.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
//************* //*************
@ -33,7 +36,7 @@ class PatientsScreen extends StatefulWidget {
class _PatientsScreenState extends State<PatientsScreen> { class _PatientsScreenState extends State<PatientsScreen> {
List<dynamic> litems; List<dynamic> litems;
// final List parsed; // final List parsed;
List parsed; List parsed;
//********** //**********
List date; List date;
@ -42,10 +45,7 @@ class _PatientsScreenState extends State<PatientsScreen> {
List<PatiantInformtion> responseModelList; List<PatiantInformtion> responseModelList;
List<PatiantInformtion> responseModelList2; List<PatiantInformtion> responseModelList2;
// List<String> _locations = ['Today', 'Old Date', 'YESTERDAY'];
List<String> _locations = ['Today', 'Tomorrow', 'Next Week']; List<String> _locations = ['Today', 'Tomorrow', 'Next Week'];
int _activeLocation = 0; int _activeLocation = 0;
@ -59,6 +59,7 @@ class _PatientsScreenState extends State<PatientsScreen> {
final _controller = TextEditingController(); final _controller = TextEditingController();
//************** //**************
PatientModel patient; PatientModel patient;
PatientsProvider patientsProv;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
@ -71,7 +72,6 @@ class _PatientsScreenState extends State<PatientsScreen> {
patientType = routeArgs['selectedType']; patientType = routeArgs['selectedType'];
patientTypetitle = SERVICES_PATIANT_HEADER[int.parse(patientType)]; patientTypetitle = SERVICES_PATIANT_HEADER[int.parse(patientType)];
print(patientType); print(patientType);
if (_isInit) { if (_isInit) {
@ -82,137 +82,301 @@ class _PatientsScreenState extends State<PatientsScreen> {
int val2 = int.parse(patientType); int val2 = int.parse(patientType);
litems = res[SERVICES_PATIANT2[val2]]; litems = res[SERVICES_PATIANT2[val2]];
parsed = litems; parsed = litems;
responseModelList = new ModelResponse.fromJson(parsed).list; responseModelList = new ModelResponse.fromJson(parsed).list;
responseModelList2=responseModelList; responseModelList2 = responseModelList;
//******************** //********************
_isLoading = false; _isLoading = false;
_hasError = res['ErrorEndUserMessage']; _hasError = res['ErrorEndUserMessage'];
}); });
print(res); print(res);
}).catchError((error) { }).catchError((error) {
// patientsProv.isLoading=false;
// patientsProv.isError=true;
print("====================error================");
print(error); print(error);
}); });
} }
_isInit = false; _isInit = false;
super.didChangeDependencies(); super.didChangeDependencies();
} }
/* /*
*@author: Amjad Amireh *@author: Amjad Amireh
*@Date:2/5/2020 *@Date:2/5/2020
*@param: *@param:
*@return:PatientsScreen Search textbox *@return:PatientsScreen Search textbox filter
*@desc: *@desc:
*/ */
searchData(String str) {
searchData(String str) {
this.responseModelList = this.responseModelList2;
var strExist = str.length > 0 ? true : false; var strExist = str.length > 0 ? true : false;
if (strExist) { if (strExist) {
List<PatiantInformtion> filterData=[] ; List<PatiantInformtion> filterData = [];
for (var i = 0; i < responseModelList2.length; i++) { for (var i = 0; i < responseModelList2.length; i++) {
String firstName = responseModelList[i].firstName.toUpperCase(); String firstName = responseModelList[i].firstName.toUpperCase();
String lastName = responseModelList[i].lastName.toUpperCase(); String lastName = responseModelList[i].lastName.toUpperCase();
if (firstName.contains(str.toUpperCase())||lastName.contains(str.toUpperCase())) { if (firstName.contains(str.toUpperCase()) ||
print("==========data done==========="); lastName.contains(str.toUpperCase())) {
filterData.add(responseModelList[i]); filterData.add(responseModelList[i]);
} }
} }
setState(() { setState(() {
print("==========data good===========");
this.responseModelList = filterData; this.responseModelList = filterData;
}); });
} else { } else {
setState(() { setState(() {
print("==========no data==========="); this.responseModelList = this.responseModelList2;
});
this.responseModelList =this.responseModelList2; }
}
//***********DateFormat**************
/*
*@author: Amjad Amireh
*@Date:5/5/2020
*@param:
*@return:Convert time from Milesecond to date with time
*@desc:
*/
convertDate(String str) {
String timeConvert;
const start = "/Date(";
const end = "+0300)";
final startIndex = str.indexOf(start);
final endIndex = str.indexOf(end, startIndex + start.length);
var date = new DateTime.fromMillisecondsSinceEpoch(
int.parse(str.substring(startIndex + start.length, endIndex)));
String newDateformat = date.year.toString() +
"/" +
date.month.toString().padLeft(2, '0') +
"/" +
date.day.toString().padLeft(2, '0') +
" " +
"-" +
" " +
date.hour.toString().padLeft(2, '0') +
":" +
date.minute.toString().toString().padLeft(2, '0');
return newDateformat.toString();
}
/*
*@author: Amjad Amireh
*@Date:5/5/2020
*@param:
*@return:Convert time from Milesecond to date
*@desc:
*/
convertDateFormat(String str) {
String timeConvert;
const start = "/Date(";
const end = "+0300)";
final startIndex = str.indexOf(start);
final endIndex = str.indexOf(end, startIndex + start.length);
var date = new DateTime.fromMillisecondsSinceEpoch(
int.parse(str.substring(startIndex + start.length, endIndex)));
String newDate = date.year.toString() +
"-" +
date.month.toString().padLeft(2, '0') +
"-" +
date.day.toString().padLeft(2, '0');
return newDate.toString();
}
filterBooking(String str) {
this.responseModelList = this.responseModelList2;
var strExist = str.length > 0 ? true : false;
if (true) {
List<PatiantInformtion> filterDate = [];
for (var i = 0; i < responseModelList2.length; i++) {
String patiantAppointment =
convertDateFormat(responseModelList[i].appointmentDate);
String dateAppointment = checkDate(patiantAppointment);
if (dateAppointment.contains(str)) {
filterDate.add(responseModelList[i]);
}
}
setState(() {
this.responseModelList = filterDate;
});
} else {
setState(() {
this.responseModelList = this.responseModelList2;
}); });
} }
} }
String checkDate(String dateString) {
String date;
DateTime checkedTime = DateTime.parse(dateString);
DateTime currentTime = DateTime.now();
if ((currentTime.year == checkedTime.year) &&
(currentTime.month == checkedTime.month) &&
(currentTime.day == checkedTime.day)) {
return "TODAY";
} else if ((currentTime.year == checkedTime.year) &&
(currentTime.month == checkedTime.month)) {
if ((currentTime.day - checkedTime.day) == 1) {
return "YESTERDAY";
} else if ((currentTime.day - checkedTime.day) == -1) {
return "TOMORROW";
}
if ((currentTime.day - checkedTime.day) <= -2) {
return "Next Week";
} else {
return "Old Date";
}
}
return "Old Date";
}
//*************************
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context); PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
return AppScaffold( return AppScaffold(
appBarTitle: patientTypetitle, appBarTitle: patientTypetitle,
//***********Modify by amjad (create List view to insert all new data webservise in scroll )************* //***********Modify by amjad (create List view to insert all new data webservise in scroll )*************
body: Container( body: patientsProv.isLoading
// margin: EdgeInsets.all(20), ? DrAppCircularProgressIndeicator()
child: ListView(scrollDirection: Axis.vertical, children: <Widget>[ : patientsProv.isError
Container( ? Center(
child: litems == null child: Text(
? Column() patientsProv.error,
: style: TextStyle(color: Theme.of(context).errorColor),
Column( ),
children: <Widget>[ )
Padding( : Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.03), child: ListView(scrollDirection: Axis.vertical, children: <
child: _locationBar(context), Widget>[
), Container(
SizedBox(height: 10.0), child: litems == null
Container( ? Column(
width: SizeConfig.screenWidth * 0.80, children: <Widget>[
child: TextField( Container(
controller: _controller, child: Center(
child:
onChanged: (String str){ DrAppCircularProgressIndeicator()),
// print(str); ),
this.searchData(str); Container(
child: Text(
}, "Sorry There is No Data",
decoration: style: TextStyle(
buildInputDecoration(context, 'Search patiant'), color: Theme.of(context).errorColor),
), ),
), )
Container( ],
margin: EdgeInsets.fromLTRB(15, 0, 15, 0), )
child: Column( : Column(
children: <Widget>[
children: Padding(
responseModelList.map((PatiantInformtion item) { padding: EdgeInsets.only(
return InkWell( top:
child: CardWithBgWidget( MediaQuery.of(context).size.height *
0.03),
widget: Column( child: SERVICES_PATIANT2[
int.parse(patientType)] ==
crossAxisAlignment: CrossAxisAlignment.start, "List_MyOutPatient"
children: <Widget>[ ? _locationBar(context)
AppText( : Container(),
item.firstName,
fontSize: 2.5 * SizeConfig.textMultiplier,
),
SizedBox(
height: 8,
),
AppText(item.lastName,
fontSize:
2.5 * SizeConfig.textMultiplier),
SizedBox(
height: 8,
),
AppText(item.middleName,
fontSize:
2.5 * SizeConfig.textMultiplier),
],
), ),
), SizedBox(height: 10.0),
onTap: () { Container(
Navigator.of(context).pushNamed( width: SizeConfig.screenWidth * 0.80,
PATIENTS_PROFILE, child: TextField(
arguments: {"patient": item}); controller: _controller,
}, onChanged: (String str) {
);
}).toList(), this.searchData(str);
), },
), decoration: buildInputDecoration(
], context, 'Search patiant'),
)) ),
]))); ),
Container(
margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
child: Column(
children: responseModelList
.map((PatiantInformtion item) {
return InkWell(
child: CardWithBgWidget(
widget: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
AppText(
item.firstName +
" " +
item.lastName +
"- " +
item.patientId.toString(),
fontSize: 2.5 *
SizeConfig.textMultiplier,
fontWeight: FontWeight.bold,
),
SizedBox(
height: 8,
),
SERVICES_PATIANT2[int.parse(
patientType)] ==
"List_MyOutPatient"
? AppText(
convertDate(item
.appointmentDate
.toString()),
fontSize: 2.5 *
SizeConfig
.textMultiplier)
: AppText(
item.nationalityName,
fontSize: 2.5 *
SizeConfig
.textMultiplier)
],
),
),
onTap: () {
Navigator.of(context).pushNamed(
PATIENTS_PROFILE,
arguments: {"patient": item});
},
);
}).toList(),
),
),
],
))
])));
} }
//***********amjad update**buildInputDecoration ***to search box******** //***********amjad update**buildInputDecoration ***to search box********
@ -243,22 +407,27 @@ class _PatientsScreenState extends State<PatientsScreen> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: _locations.map((l) { children: _locations.map((item) {
bool _isActive = _locations[_activeLocation] == l ? true : false; bool _isActive = _locations[_activeLocation] == item ? true : false;
return Column(mainAxisSize: MainAxisSize.min, children: <Widget>[ return Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
InkWell( InkWell(
child: Text( child: Text(
l, item,
style: TextStyle( style: TextStyle(
fontSize: 15, fontSize: 15,
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
onTap: () { onTap: () {
print(l);
print(_locations.indexOf(l)); print(_locations.indexOf(item));
filterBooking(item.toString());
setState(() { setState(() {
_activeLocation = _locations.indexOf(l); _activeLocation = _locations.indexOf(item);
}); });
}), }),
_isActive _isActive

Loading…
Cancel
Save