diff --git a/lib/models/patient/patiant_info_model.dart b/lib/models/patient/patiant_info_model.dart index 94a5c09d..c85edace 100644 --- a/lib/models/patient/patiant_info_model.dart +++ b/lib/models/patient/patiant_info_model.dart @@ -50,9 +50,10 @@ class PatiantInformtion { String age; String genderDescription; String nursingStationName; + String appointmentDate; PatiantInformtion({ - this.list, + this.list, this.projectId, this.clinicId, this.doctorId, @@ -85,6 +86,8 @@ class PatiantInformtion { this.age, this.genderDescription, this.nursingStationName, + this.appointmentDate, + }); factory PatiantInformtion.fromJson(Map json) => PatiantInformtion( @@ -120,6 +123,7 @@ class PatiantInformtion { age: json["Age"], genderDescription: json["GenderDescription"], nursingStationName: json["NursingStationName"], + appointmentDate: json["AppointmentDate"], ); diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index f207ee15..bf22e565 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -44,8 +44,8 @@ class PatientsProvider with ChangeNotifier { // var srvicePatiant = ["GetMyOutPatient", "GetMyInPatient", "GtMyDischargePatient","GtMyReferredPatient","GtMyDischargeReferralPatient","GtMyTomorrowPatient","GtMyReferralPatient"]; // print("a=SERVICES_PATIANT[patientType]========='=======a"); int val = int.parse(patientType); - final url = - BASE_URL + 'DoctorApplication.svc/REST/' + SERVICES_PATIANT[val]; + 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]; // print("a===========$url=======a"); try { diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 97987ff0..2582310a 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -37,8 +37,8 @@ class _PatientSearchScreenState extends State { var _patientSearchFormValues = PatientModel( ProjectID: 15, - ClinicID: 14, - DoctorID: 243763, + ClinicID: 0, + DoctorID: 4709, FirstName: "0", MiddleName: "0", LastName: "0", @@ -64,13 +64,13 @@ class _PatientSearchScreenState extends State { if (_formKey.currentState.validate()) { // If all data are correct then save data to out variables // _formKey.currentState.save(); - // sharedPref.setString(TOKEN,'@dm!n'); + 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 = projectID; + _patientSearchFormValues.ProjectID = 15;//projectID; // print(_patientSearchFormValues.PatientMobileNumber+"dfdfdfddf"); Navigator.of(context).pushNamed(PATIENTS, arguments: { "patientSearchForm": _patientSearchFormValues, diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 91c15022..fc2eb3d6 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -6,6 +6,7 @@ *@desc: */ + 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/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/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:intl/intl.dart'; import 'package:provider/provider.dart'; //************* @@ -33,7 +36,7 @@ class PatientsScreen extends StatefulWidget { class _PatientsScreenState extends State { List litems; - // final List parsed; + // final List parsed; List parsed; //********** List date; @@ -42,10 +45,7 @@ class _PatientsScreenState extends State { List responseModelList; List responseModelList2; - - - - + // List _locations = ['Today', 'Old Date', 'YESTERDAY']; List _locations = ['Today', 'Tomorrow', 'Next Week']; int _activeLocation = 0; @@ -59,6 +59,7 @@ class _PatientsScreenState extends State { final _controller = TextEditingController(); //************** PatientModel patient; + PatientsProvider patientsProv; @override void didChangeDependencies() { @@ -71,7 +72,6 @@ class _PatientsScreenState extends State { patientType = routeArgs['selectedType']; patientTypetitle = SERVICES_PATIANT_HEADER[int.parse(patientType)]; - print(patientType); if (_isInit) { @@ -82,137 +82,301 @@ class _PatientsScreenState extends State { int val2 = int.parse(patientType); litems = res[SERVICES_PATIANT2[val2]]; - parsed = litems; + parsed = litems; responseModelList = new ModelResponse.fromJson(parsed).list; - responseModelList2=responseModelList; + responseModelList2 = responseModelList; //******************** _isLoading = false; + _hasError = res['ErrorEndUserMessage']; }); print(res); }).catchError((error) { + // patientsProv.isLoading=false; + // patientsProv.isError=true; + print("====================error================"); print(error); }); } + _isInit = false; + super.didChangeDependencies(); } + /* *@author: Amjad Amireh *@Date:2/5/2020 *@param: - *@return:PatientsScreen Search textbox + *@return:PatientsScreen Search textbox filter *@desc: */ - searchData(String str) { + + searchData(String str) { + this.responseModelList = this.responseModelList2; var strExist = str.length > 0 ? true : false; if (strExist) { - List filterData=[] ; + List filterData = []; + for (var i = 0; i < responseModelList2.length; i++) { - String firstName = responseModelList[i].firstName.toUpperCase(); String lastName = responseModelList[i].lastName.toUpperCase(); - if (firstName.contains(str.toUpperCase())||lastName.contains(str.toUpperCase())) { - print("==========data done==========="); + if (firstName.contains(str.toUpperCase()) || + lastName.contains(str.toUpperCase())) { filterData.add(responseModelList[i]); } } + setState(() { - print("==========data good==========="); this.responseModelList = filterData; }); } else { 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 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 Widget build(BuildContext context) { PatientsProvider patientsProv = Provider.of(context); return AppScaffold( - appBarTitle: patientTypetitle, + appBarTitle: patientTypetitle, //***********Modify by amjad (create List view to insert all new data webservise in scroll )************* - body: Container( - // margin: EdgeInsets.all(20), - child: ListView(scrollDirection: Axis.vertical, children: [ - Container( - child: litems == null - ? Column() - : - Column( - children: [ - Padding( - padding: EdgeInsets.only( - top: MediaQuery.of(context).size.height * 0.03), - child: _locationBar(context), - ), - SizedBox(height: 10.0), - Container( - width: SizeConfig.screenWidth * 0.80, - child: TextField( - controller: _controller, - - onChanged: (String str){ - // print(str); - 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: [ - AppText( - 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), - ], + body: patientsProv.isLoading + ? DrAppCircularProgressIndeicator() + : patientsProv.isError + ? Center( + child: Text( + patientsProv.error, + style: TextStyle(color: Theme.of(context).errorColor), + ), + ) + : Container( + + child: ListView(scrollDirection: Axis.vertical, children: < + Widget>[ + Container( + child: litems == null + ? Column( + children: [ + Container( + child: Center( + child: + DrAppCircularProgressIndeicator()), + ), + Container( + child: Text( + "Sorry There is No Data", + style: TextStyle( + color: Theme.of(context).errorColor), + ), + ) + ], + ) + : Column( + children: [ + Padding( + padding: EdgeInsets.only( + top: + MediaQuery.of(context).size.height * + 0.03), + child: SERVICES_PATIANT2[ + int.parse(patientType)] == + "List_MyOutPatient" + ? _locationBar(context) + : Container(), ), - ), - onTap: () { - Navigator.of(context).pushNamed( - PATIENTS_PROFILE, - arguments: {"patient": item}); - }, - ); - }).toList(), - ), - ), - ], - )) - ]))); + SizedBox(height: 10.0), + Container( + width: SizeConfig.screenWidth * 0.80, + child: TextField( + controller: _controller, + onChanged: (String str) { + + 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: [ + 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******** @@ -243,22 +407,27 @@ class _PatientsScreenState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, - children: _locations.map((l) { - bool _isActive = _locations[_activeLocation] == l ? true : false; + children: _locations.map((item) { + bool _isActive = _locations[_activeLocation] == item ? true : false; return Column(mainAxisSize: MainAxisSize.min, children: [ InkWell( child: Text( - l, + item, style: TextStyle( fontSize: 15, color: Colors.white, fontWeight: FontWeight.bold), ), onTap: () { - print(l); - print(_locations.indexOf(l)); + + print(_locations.indexOf(item)); + + + filterBooking(item.toString()); + setState(() { - _activeLocation = _locations.indexOf(l); + _activeLocation = _locations.indexOf(item); + }); }), _isActive