My appointment fixes

merge-update-with-lab-changes
haroon amjad 2 years ago
parent 27b6e04d33
commit 75bfeaa716

@ -158,7 +158,8 @@ class BaseAppClient {
? body['PatientOutSA'] ? body['PatientOutSA']
: user['OutSA'] : user['OutSA']
: user['OutSA']; : user['OutSA'];
body['SessionID'] = getSessionId(body['TokenID']); //getSe body['SessionID'] = getSessionId(body['TokenID'] != null ? body['TokenID'] : ""); //getSe
// body['SessionID'] = body['TokenID']; //getSe
headers = { headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -720,7 +721,8 @@ class BaseAppClient {
String getSessionId(String id) { String getSessionId(String id) {
///return id.replaceAll(RegExp('/[^\w\s]/'), ''); ///return id.replaceAll(RegExp('/[^\w\s]/'), '');
if (id != null) return id.replaceAll(RegExp('/[^a-zA-Z]'), ''); // if (id != null) return id.replaceAll(RegExp('/[^a-zA-Z]'), '');
return id.replaceAll(RegExp('/[^a-zA-Z]'), '');
} }
static defaultHttpParameters() async { static defaultHttpParameters() async {

@ -25,6 +25,11 @@ import 'package:provider/provider.dart';
import 'AppointmentDetails.dart'; import 'AppointmentDetails.dart';
class MyAppointments extends StatefulWidget { class MyAppointments extends StatefulWidget {
@override
_MyAppointmentsState createState() => _MyAppointmentsState();
}
class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProviderStateMixin {
List<AppoitmentAllHistoryResultList> upcomingAppoList = []; List<AppoitmentAllHistoryResultList> upcomingAppoList = [];
List<AppoitmentAllHistoryResultList> arrivedAppoListNew = []; List<AppoitmentAllHistoryResultList> arrivedAppoListNew = [];
@ -43,11 +48,6 @@ class MyAppointments extends StatefulWidget {
List<PatientAppointmentList> _patientBookedAndConfirmedAppointmentListHospital = List(); List<PatientAppointmentList> _patientBookedAndConfirmedAppointmentListHospital = List();
List<PatientAppointmentList> _patientBookedAndConfirmedAppointmentListClinic = List(); List<PatientAppointmentList> _patientBookedAndConfirmedAppointmentListClinic = List();
@override
_MyAppointmentsState createState() => _MyAppointmentsState();
}
class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProviderStateMixin {
bool isDataLoaded = false; bool isDataLoaded = false;
var sharedPref = new AppSharedPreferences(); var sharedPref = new AppSharedPreferences();
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>(); AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
@ -145,23 +145,23 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
DoctorsListService service = new DoctorsListService(); DoctorsListService service = new DoctorsListService();
widget.upcomingAppoList.clear(); upcomingAppoList.clear();
widget.arrivedAppoListNew.clear(); arrivedAppoListNew.clear();
widget.bookedAppoList.clear(); bookedAppoList.clear();
widget.confirmedAppoList.clear(); confirmedAppoList.clear();
widget.arrivedAppoList.clear(); arrivedAppoList.clear();
widget._patientBookedAppointmentListHospital.clear(); _patientBookedAppointmentListHospital.clear();
widget._patientConfirmedAppointmentListHospital.clear(); _patientConfirmedAppointmentListHospital.clear();
widget._patientArrivedAppointmentListHospital.clear(); _patientArrivedAppointmentListHospital.clear();
widget._patientBookedAppointmentListClinic.clear(); _patientBookedAppointmentListClinic.clear();
widget._patientConfirmedAppointmentListClinic.clear(); _patientConfirmedAppointmentListClinic.clear();
widget._patientArrivedAppointmentListClinic.clear(); _patientArrivedAppointmentListClinic.clear();
widget._patientBookedAndConfirmedAppointmentListHospital.clear(); _patientBookedAndConfirmedAppointmentListHospital.clear();
widget._patientBookedAndConfirmedAppointmentListClinic.clear(); _patientBookedAndConfirmedAppointmentListClinic.clear();
service.getPatientAppointmentHistory(false, languageID, context, isForUpcomming: isForUpcoming, IsForArrived: isForArrived).then((res) { service.getPatientAppointmentHistory(false, languageID, context, isForUpcomming: isForUpcoming, IsForArrived: isForArrived).then((res) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
@ -170,9 +170,9 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
if (res['AppoimentAllHistoryResultList'].length != 0) { if (res['AppoimentAllHistoryResultList'].length != 0) {
res['AppoimentAllHistoryResultList'].forEach((v) { res['AppoimentAllHistoryResultList'].forEach((v) {
if (isForArrived) { if (isForArrived) {
widget.arrivedAppoListNew.add(new AppoitmentAllHistoryResultList.fromJson(v)); arrivedAppoListNew.add(new AppoitmentAllHistoryResultList.fromJson(v));
} else { } else {
widget.upcomingAppoList.add(new AppoitmentAllHistoryResultList.fromJson(v)); upcomingAppoList.add(new AppoitmentAllHistoryResultList.fromJson(v));
} }
}); });
sortAppointmentList(isForUpcoming, isForArrived); sortAppointmentList(isForUpcoming, isForArrived);
@ -217,118 +217,118 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
sortAppointmentList(bool isForUpcoming, bool isForArrived) { sortAppointmentList(bool isForUpcoming, bool isForArrived) {
if (isForArrived) { if (isForArrived) {
widget.arrivedAppoListNew.forEach((v) { arrivedAppoListNew.forEach((v) {
if (isBooked(v)) { if (isBooked(v)) {
widget.bookedAppoList.add(v); bookedAppoList.add(v);
} }
if (isConfirmed(v)) { if (isConfirmed(v)) {
widget.confirmedAppoList.add(v); confirmedAppoList.add(v);
} }
if (isArrived(v)) { if (isArrived(v)) {
widget.arrivedAppoList.add(v); arrivedAppoList.add(v);
} }
}); });
} else { } else {
widget.upcomingAppoList.forEach((v) { upcomingAppoList.forEach((v) {
if (isBooked(v)) { if (isBooked(v)) {
widget.bookedAppoList.add(v); bookedAppoList.add(v);
} }
if (isConfirmed(v)) { if (isConfirmed(v)) {
widget.confirmedAppoList.add(v); confirmedAppoList.add(v);
} }
if (isArrived(v)) { if (isArrived(v)) {
widget.arrivedAppoList.add(v); arrivedAppoList.add(v);
} }
}); });
} }
widget.bookedAppoList.forEach((element) { bookedAppoList.forEach((element) {
List<PatientAppointmentList> doctorByClinic = widget._patientBookedAppointmentListClinic List<PatientAppointmentList> doctorByClinic = _patientBookedAppointmentListClinic
.where( .where(
(elementClinic) => elementClinic.filterName == element.clinicName, (elementClinic) => elementClinic.filterName == element.clinicName,
) )
.toList(); .toList();
if (doctorByClinic.length != 0) { if (doctorByClinic.length != 0) {
widget._patientBookedAppointmentListClinic[widget._patientBookedAppointmentListClinic.indexOf(doctorByClinic[0])].patientDoctorAppointmentList.add(element); _patientBookedAppointmentListClinic[_patientBookedAppointmentListClinic.indexOf(doctorByClinic[0])].patientDoctorAppointmentList.add(element);
} else { } else {
widget._patientBookedAppointmentListClinic.add(PatientAppointmentList(filterName: element.clinicName, patientDoctorAppointment: element)); _patientBookedAppointmentListClinic.add(PatientAppointmentList(filterName: element.clinicName, patientDoctorAppointment: element));
} }
List<PatientAppointmentList> doctorByHospital = widget._patientBookedAppointmentListHospital List<PatientAppointmentList> doctorByHospital = _patientBookedAppointmentListHospital
.where( .where(
(elementClinic) => elementClinic.filterName == element.projectName, (elementClinic) => elementClinic.filterName == element.projectName,
) )
.toList(); .toList();
if (doctorByHospital.length != 0) { if (doctorByHospital.length != 0) {
widget._patientBookedAppointmentListHospital[widget._patientBookedAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); _patientBookedAppointmentListHospital[_patientBookedAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element);
} else { } else {
widget._patientBookedAppointmentListHospital.add(PatientAppointmentList(filterName: element.projectName, patientDoctorAppointment: element)); _patientBookedAppointmentListHospital.add(PatientAppointmentList(filterName: element.projectName, patientDoctorAppointment: element));
} }
//Merging Booked & Confirmed Appointments into Upcoming Tab //Merging Booked & Confirmed Appointments into Upcoming Tab
widget._patientBookedAndConfirmedAppointmentListHospital.addAll(widget._patientBookedAppointmentListHospital); _patientBookedAndConfirmedAppointmentListHospital.addAll(_patientBookedAppointmentListHospital);
widget._patientBookedAndConfirmedAppointmentListClinic.addAll(widget._patientBookedAppointmentListClinic); _patientBookedAndConfirmedAppointmentListClinic.addAll(_patientBookedAppointmentListClinic);
}); });
widget.confirmedAppoList.forEach((element) { confirmedAppoList.forEach((element) {
List<PatientAppointmentList> doctorByClinic = widget._patientConfirmedAppointmentListClinic List<PatientAppointmentList> doctorByClinic = _patientConfirmedAppointmentListClinic
.where( .where(
(elementClinic) => elementClinic.filterName == element.clinicName, (elementClinic) => elementClinic.filterName == element.clinicName,
) )
.toList(); .toList();
if (doctorByClinic.length != 0) { if (doctorByClinic.length != 0) {
widget._patientConfirmedAppointmentListClinic[widget._patientConfirmedAppointmentListClinic.indexOf(doctorByClinic[0])].patientDoctorAppointmentList.add(element); _patientConfirmedAppointmentListClinic[_patientConfirmedAppointmentListClinic.indexOf(doctorByClinic[0])].patientDoctorAppointmentList.add(element);
} else { } else {
widget._patientConfirmedAppointmentListClinic.add(PatientAppointmentList(filterName: element.clinicName, patientDoctorAppointment: element)); _patientConfirmedAppointmentListClinic.add(PatientAppointmentList(filterName: element.clinicName, patientDoctorAppointment: element));
} }
List<PatientAppointmentList> doctorByHospital = widget._patientConfirmedAppointmentListHospital List<PatientAppointmentList> doctorByHospital = _patientConfirmedAppointmentListHospital
.where( .where(
(elementClinic) => elementClinic.filterName == element.projectName, (elementClinic) => elementClinic.filterName == element.projectName,
) )
.toList(); .toList();
if (doctorByHospital.length != 0) { if (doctorByHospital.length != 0) {
widget._patientConfirmedAppointmentListHospital[widget._patientConfirmedAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); _patientConfirmedAppointmentListHospital[_patientConfirmedAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element);
} else { } else {
widget._patientConfirmedAppointmentListHospital.add(PatientAppointmentList(filterName: element.projectName, patientDoctorAppointment: element)); _patientConfirmedAppointmentListHospital.add(PatientAppointmentList(filterName: element.projectName, patientDoctorAppointment: element));
} }
//Merging Booked & Confirmed Appointments into Upcoming Tab //Merging Booked & Confirmed Appointments into Upcoming Tab
widget._patientBookedAndConfirmedAppointmentListHospital.addAll(widget._patientConfirmedAppointmentListHospital); _patientBookedAndConfirmedAppointmentListHospital.addAll(_patientConfirmedAppointmentListHospital);
widget._patientBookedAndConfirmedAppointmentListClinic.addAll(widget._patientConfirmedAppointmentListClinic); _patientBookedAndConfirmedAppointmentListClinic.addAll(_patientConfirmedAppointmentListClinic);
}); });
widget.arrivedAppoList.forEach((element) { arrivedAppoList.forEach((element) {
List<PatientAppointmentList> doctorByClinic = widget._patientArrivedAppointmentListClinic List<PatientAppointmentList> doctorByClinic = _patientArrivedAppointmentListClinic
.where( .where(
(elementClinic) => elementClinic.filterName == element.clinicName, (elementClinic) => elementClinic.filterName == element.clinicName,
) )
.toList(); .toList();
if (doctorByClinic.length != 0) { if (doctorByClinic.length != 0) {
widget._patientArrivedAppointmentListClinic[widget._patientArrivedAppointmentListClinic.indexOf(doctorByClinic[0])].patientDoctorAppointmentList.add(element); _patientArrivedAppointmentListClinic[_patientArrivedAppointmentListClinic.indexOf(doctorByClinic[0])].patientDoctorAppointmentList.add(element);
} else { } else {
widget._patientArrivedAppointmentListClinic.add(PatientAppointmentList(filterName: element.clinicName, patientDoctorAppointment: element)); _patientArrivedAppointmentListClinic.add(PatientAppointmentList(filterName: element.clinicName, patientDoctorAppointment: element));
} }
List<PatientAppointmentList> doctorByHospital = widget._patientArrivedAppointmentListHospital List<PatientAppointmentList> doctorByHospital = _patientArrivedAppointmentListHospital
.where( .where(
(elementClinic) => elementClinic.filterName == element.projectName, (elementClinic) => elementClinic.filterName == element.projectName,
) )
.toList(); .toList();
if (doctorByHospital.length != 0) { if (doctorByHospital.length != 0) {
widget._patientArrivedAppointmentListHospital[widget._patientArrivedAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); _patientArrivedAppointmentListHospital[_patientArrivedAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element);
} else { } else {
widget._patientArrivedAppointmentListHospital.add(PatientAppointmentList(filterName: element.projectName, patientDoctorAppointment: element)); _patientArrivedAppointmentListHospital.add(PatientAppointmentList(filterName: element.projectName, patientDoctorAppointment: element));
} }
// openAppointmentsTab(); // openAppointmentsTab();
@ -345,11 +345,11 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
} else if (flag == 3) { } else if (flag == 3) {
index = 2; index = 2;
} else { } else {
if (widget._patientBookedAppointmentListClinic.length != 0) { if (_patientBookedAppointmentListClinic.length != 0) {
index = 0; index = 0;
} else if (widget._patientConfirmedAppointmentListClinic.length != 0) { } else if (_patientConfirmedAppointmentListClinic.length != 0) {
index = 1; index = 1;
} else if (widget._patientArrivedAppointmentListClinic.length != 0) { } else if (_patientArrivedAppointmentListClinic.length != 0) {
index = 2; index = 2;
// return; // return;
} }
@ -359,12 +359,12 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
} }
Widget getBookedAppointments() { Widget getBookedAppointments() {
return _getAppointment(widget.bookedAppoList.length, (filterType == FilterType.Clinic) ? widget._patientBookedAppointmentListClinic : widget._patientBookedAppointmentListHospital); return _getAppointment(bookedAppoList.length, (filterType == FilterType.Clinic) ? _patientBookedAppointmentListClinic : _patientBookedAppointmentListHospital);
} }
Widget getBookedAndConfirmedAppointments() { Widget getBookedAndConfirmedAppointments() {
return _getAppointment((widget.bookedAppoList.length + widget.confirmedAppoList.length), return _getAppointment(
(filterType == FilterType.Clinic) ? widget._patientBookedAndConfirmedAppointmentListClinic : widget._patientBookedAndConfirmedAppointmentListHospital); (bookedAppoList.length + confirmedAppoList.length), (filterType == FilterType.Clinic) ? _patientBookedAndConfirmedAppointmentListClinic : _patientBookedAndConfirmedAppointmentListHospital);
} }
Widget _getAppointment(int _listLength, List<PatientAppointmentList> _list) { Widget _getAppointment(int _listLength, List<PatientAppointmentList> _list) {
@ -382,7 +382,9 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
Container( Container(
margin: EdgeInsets.only(top: 10.0), margin: EdgeInsets.only(top: 10.0),
child: Text( child: Text(
_currentPage == 0 ? TranslationBase.of(context).noBookedAppo : (_currentPage == 1 ? TranslationBase.of(context).noUpcomingAppointment : TranslationBase.of(context).noArrivedAppo), _currentPage == 0
? TranslationBase.of(context).noBookedAppo
: (_currentPage == 1 ? TranslationBase.of(context).noUpcomingAppointment : TranslationBase.of(context).noArrivedAppo),
style: TextStyle( style: TextStyle(
fontSize: 16.0, fontSize: 16.0,
), ),
@ -461,11 +463,11 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
} }
Widget getConfirmedAppointments() { Widget getConfirmedAppointments() {
return _getAppointment(widget.confirmedAppoList.length, (filterType == FilterType.Clinic) ? widget._patientConfirmedAppointmentListClinic : widget._patientConfirmedAppointmentListHospital); return _getAppointment(confirmedAppoList.length, (filterType == FilterType.Clinic) ? _patientConfirmedAppointmentListClinic : _patientConfirmedAppointmentListHospital);
} }
Widget getArrivedAppointments() { Widget getArrivedAppointments() {
return _getAppointment(widget.arrivedAppoList.length, (filterType == FilterType.Clinic) ? widget._patientArrivedAppointmentListClinic : widget._patientArrivedAppointmentListHospital); return _getAppointment(arrivedAppoList.length, (filterType == FilterType.Clinic) ? _patientArrivedAppointmentListClinic : _patientArrivedAppointmentListHospital);
} }
setFilterType(FilterType filterType) { setFilterType(FilterType filterType) {
@ -479,6 +481,12 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
onTap: () { onTap: () {
setState(() { setState(() {
_currentPage = _value; _currentPage = _value;
if (_value == 1) {
getPatientAppointmentHistory(true, false);
}
if (_value == 2) {
getPatientAppointmentHistory(false, true);
}
}); });
}, },
child: Row( child: Row(

@ -706,7 +706,7 @@ class _AppDrawerState extends State<AppDrawer> {
_vitalSignService.heightCm = ""; _vitalSignService.heightCm = "";
_vitalSignService.weightKg = ""; _vitalSignService.weightKg = "";
if (pharmacyModuleViewModel.error.isNotEmpty) await pharmacyModuleViewModel.createUser(); // if (pharmacyModuleViewModel.error.isNotEmpty) await pharmacyModuleViewModel.createUser();
int languageID = Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 1 : 2; int languageID = Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 1 : 2;

Loading…
Cancel
Save