separate in patient and my in patient to 2 files

merge-requests/829/head
Elham Rababh 5 years ago
parent 37cd34f568
commit ce199f7d98

@ -30,9 +30,9 @@ class PatientSearchViewModel extends BaseViewModel {
int firstSubsetIndex = 0; int firstSubsetIndex = 0;
int inPatientPageSize = 20; int inPatientPageSize = 20;
int lastSubsetIndex = 19; int lastSubsetIndex = 20;
List<String> myInpatientClinicList = []; List<String> InpatientClinicList = [];
searchData(String str) { searchData(String str) {
var strExist = str.length > 0 ? true : false; var strExist = str.length > 0 ? true : false;
@ -88,10 +88,8 @@ class PatientSearchViewModel extends BaseViewModel {
sortOutPatient({bool isDes = false}) { sortOutPatient({bool isDes = false}) {
if (isDes) if (isDes)
filterData = filterData.reversed.toList(); filterData = filterData.reversed.toList();
// filterData.sort((PatiantInformtion a, PatiantInformtion b)=>b.appointmentDateWithDateTimeForm.compareTo(a.appointmentDateWithDateTimeForm));
else else
filterData = filterData.reversed.toList(); filterData = filterData.reversed.toList();
// filterData.sort((PatiantInformtion a, PatiantInformtion b)=>a.appointmentDateWithDateTimeForm.compareTo(b.appointmentDateWithDateTimeForm));
setState(ViewState.Idle); setState(ViewState.Idle);
} }
@ -166,6 +164,7 @@ class PatientSearchViewModel extends BaseViewModel {
_inPatientService.myInPatientList; _inPatientService.myInPatientList;
List<PatiantInformtion> filteredInPatientItems = List(); List<PatiantInformtion> filteredInPatientItems = List();
List<PatiantInformtion> filteredMyInPatientItems = List();
Future getInPatientList(PatientSearchRequestModel requestModel, Future getInPatientList(PatientSearchRequestModel requestModel,
{bool isMyInpatient = false, bool isLocalBusy = false}) async { {bool isMyInpatient = false, bool isLocalBusy = false}) async {
@ -186,17 +185,22 @@ class PatientSearchViewModel extends BaseViewModel {
} }
} else { } else {
setDefaultInPatientList(); setDefaultInPatientList();
generateMyInpatientClinicList(); generateInpatientClinicList();
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
sortInPatient({bool isDes = false, bool isAllClinic}) { sortInPatient({bool isDes = false, bool isAllClinic, bool isMyInPatient}) {
if (isAllClinic if (isMyInPatient
? inPatientList.length > 0 ? myIinPatientList.length > 0
: filteredInPatientItems.length > 0) { : isAllClinic
List<PatiantInformtion> localInPatient = ? inPatientList.length > 0
isAllClinic ? [...inPatientList] : [...filteredInPatientItems]; : filteredInPatientItems.length > 0) {
List<PatiantInformtion> localInPatient = isMyInPatient
? [...filteredMyInPatientItems]
: isAllClinic
? [...inPatientList]
: [...filteredInPatientItems];
if (isDes) if (isDes)
localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => b localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => b
.admissionDateWithDateTimeForm .admissionDateWithDateTimeForm
@ -205,8 +209,10 @@ class PatientSearchViewModel extends BaseViewModel {
localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => a localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => a
.admissionDateWithDateTimeForm .admissionDateWithDateTimeForm
.compareTo(b.admissionDateWithDateTimeForm)); .compareTo(b.admissionDateWithDateTimeForm));
if (isMyInPatient) {
if (isAllClinic) { filteredMyInPatientItems.clear();
filteredMyInPatientItems.addAll(localInPatient);
} else if (isAllClinic) {
resetInPatientPagination(); resetInPatientPagination();
filteredInPatientItems filteredInPatientItems
.addAll(localInPatient.sublist(firstSubsetIndex, lastSubsetIndex)); .addAll(localInPatient.sublist(firstSubsetIndex, lastSubsetIndex));
@ -231,13 +237,17 @@ class PatientSearchViewModel extends BaseViewModel {
if (inPatientList.length > 0) if (inPatientList.length > 0)
filteredInPatientItems filteredInPatientItems
.addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex));
if (myIinPatientList.length > 0) {
filteredMyInPatientItems.addAll(myIinPatientList);
}
setState(ViewState.Idle); setState(ViewState.Idle);
} }
generateMyInpatientClinicList() { generateInpatientClinicList() {
inPatientList.forEach((element) { inPatientList.forEach((element) {
if (!myInpatientClinicList.contains(element.clinicDescription)) { if (!InpatientClinicList.contains(element.clinicDescription)) {
myInpatientClinicList.add(element.clinicDescription); InpatientClinicList.add(element.clinicDescription);
} }
}); });
} }
@ -259,9 +269,8 @@ class PatientSearchViewModel extends BaseViewModel {
} }
removeOnFilteredList() { removeOnFilteredList() {
if (lastSubsetIndex-inPatientPageSize - 1 > 0) { if (lastSubsetIndex - inPatientPageSize - 1 > 0) {
filteredInPatientItems filteredInPatientItems.removeAt(lastSubsetIndex - inPatientPageSize - 1);
.removeAt(lastSubsetIndex-inPatientPageSize - 1);
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
@ -291,61 +300,95 @@ class PatientSearchViewModel extends BaseViewModel {
_inPatientService.myInPatientList = []; _inPatientService.myInPatientList = [];
} }
void filterSearchResults(String query, {bool isAllClinic}) { void filterSearchResults(String query,
{bool isAllClinic, bool isMyInPatient}) {
var strExist = query.length > 0 ? true : false; var strExist = query.length > 0 ? true : false;
if (isAllClinic) {
if (strExist) {
filteredInPatientItems = [];
for (var i = 0; i < inPatientList.length; i++) {
String firstName = inPatientList[i].firstName.toUpperCase();
String lastName = inPatientList[i].lastName.toUpperCase();
String mobile = inPatientList[i].mobileNumber.toUpperCase();
String patientID = inPatientList[i].patientId.toString();
if (firstName.contains(query.toUpperCase()) || if (isMyInPatient) {
lastName.contains(query.toUpperCase()) || List<PatiantInformtion> localFilteredMyInPatientItems = [
mobile.contains(query) || ...myIinPatientList
patientID.contains(query)) {
filteredInPatientItems.add(inPatientList[i]);
}
}
notifyListeners();
} else {
if (inPatientList.length > 0) filteredInPatientItems.clear();
filteredInPatientItems.addAll(inPatientList);
notifyListeners();
}
} else {
List<PatiantInformtion> localFilteredInPatientItems = [
...filteredInPatientItems
]; ];
if (strExist) { if (strExist) {
filteredInPatientItems.clear(); filteredMyInPatientItems.clear();
for (var i = 0; i < localFilteredInPatientItems.length; i++) { for (var i = 0; i < localFilteredMyInPatientItems.length; i++) {
String firstName = String firstName =
localFilteredInPatientItems[i].firstName.toUpperCase(); localFilteredMyInPatientItems[i].firstName.toUpperCase();
String lastName = String lastName =
localFilteredInPatientItems[i].lastName.toUpperCase(); localFilteredMyInPatientItems[i].lastName.toUpperCase();
String mobile = String mobile =
localFilteredInPatientItems[i].mobileNumber.toUpperCase(); localFilteredMyInPatientItems[i].mobileNumber.toUpperCase();
String patientID = String patientID =
localFilteredInPatientItems[i].patientId.toString(); localFilteredMyInPatientItems[i].patientId.toString();
if (firstName.contains(query.toUpperCase()) || if (firstName.contains(query.toUpperCase()) ||
lastName.contains(query.toUpperCase()) || lastName.contains(query.toUpperCase()) ||
mobile.contains(query) || mobile.contains(query) ||
patientID.contains(query)) { patientID.contains(query)) {
filteredInPatientItems.add(localFilteredInPatientItems[i]); filteredMyInPatientItems.add(localFilteredMyInPatientItems[i]);
} }
} }
notifyListeners(); notifyListeners();
} else { } else {
if (localFilteredInPatientItems.length > 0) if (myIinPatientList.length > 0) filteredMyInPatientItems.clear();
filteredInPatientItems.clear(); filteredMyInPatientItems.addAll(myIinPatientList);
filteredInPatientItems.addAll(localFilteredInPatientItems);
notifyListeners(); notifyListeners();
} }
} else {
if (isAllClinic) {
if (strExist) {
filteredInPatientItems = [];
for (var i = 0; i < inPatientList.length; i++) {
String firstName = inPatientList[i].firstName.toUpperCase();
String lastName = inPatientList[i].lastName.toUpperCase();
String mobile = inPatientList[i].mobileNumber.toUpperCase();
String patientID = inPatientList[i].patientId.toString();
if (firstName.contains(query.toUpperCase()) ||
lastName.contains(query.toUpperCase()) ||
mobile.contains(query) ||
patientID.contains(query)) {
filteredInPatientItems.add(inPatientList[i]);
}
}
notifyListeners();
} else {
if (inPatientList.length > 0) filteredInPatientItems.clear();
filteredInPatientItems.addAll(inPatientList);
notifyListeners();
}
} else {
List<PatiantInformtion> localFilteredInPatientItems = [
...filteredInPatientItems
];
if (strExist) {
filteredInPatientItems.clear();
for (var i = 0; i < localFilteredInPatientItems.length; i++) {
String firstName =
localFilteredInPatientItems[i].firstName.toUpperCase();
String lastName =
localFilteredInPatientItems[i].lastName.toUpperCase();
String mobile =
localFilteredInPatientItems[i].mobileNumber.toUpperCase();
String patientID =
localFilteredInPatientItems[i].patientId.toString();
if (firstName.contains(query.toUpperCase()) ||
lastName.contains(query.toUpperCase()) ||
mobile.contains(query) ||
patientID.contains(query)) {
filteredInPatientItems.add(localFilteredInPatientItems[i]);
}
}
notifyListeners();
} else {
if (localFilteredInPatientItems.length > 0)
filteredInPatientItems.clear();
filteredInPatientItems.addAll(localFilteredInPatientItems);
notifyListeners();
}
}
} }
} }

@ -1,20 +1,16 @@
import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/patient_card/PatientCard.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.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/errors/error_message.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_container.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '../../../routes.dart';
import 'NoData.dart'; import 'NoData.dart';
import 'list_of_all_in_patient.dart';
import 'list_of_my_inpatient.dart';
class InPatientListPage extends StatefulWidget { class InPatientListPage extends StatefulWidget {
final bool isMyInPatient; final bool isMyInPatient;
@ -49,82 +45,88 @@ class _InPatientListPageState extends State<InPatientListPage> {
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if(!widget.isMyInPatient) if (!widget.isMyInPatient)
Container( Container(
margin: EdgeInsets.only(left: 10.0, right: 10, top: 10), margin: EdgeInsets.only(left: 10.0, right: 10, top: 10),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
InkWell( InkWell(
child: Row(
children: [
Radio(
value: 1,
groupValue: isAllClinic ? 1 : 2,
onChanged: (value) {
setState(() {
setState(() {
isAllClinic = true;
showBottomSheet = false;
});
widget.patientSearchViewModel
.setDefaultInPatientList();
});
},
activeColor: Colors.red,
),
AppText(
"All Clinic",
fontSize: 15,
),
],
),
onTap: () {
setState(() {
isAllClinic = true;
showBottomSheet = false;
});
widget.patientSearchViewModel.setDefaultInPatientList();
},
),
InkWell(
onTap: () {
setState(() {
isAllClinic = false;
if(widget.patientSearchViewModel.myInpatientClinicList.length > 0)
showBottomSheet = true;
});
},
child: Row( child: Row(
children: [ children: [
Radio( Radio(
value: 2, value: 1,
groupValue: isAllClinic ? 1 : 2, groupValue: isAllClinic ? 1 : 2,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
setState(() { setState(() {
isAllClinic = false; isAllClinic = true;
if(widget.patientSearchViewModel.myInpatientClinicList.length > 0) showBottomSheet = false;
showBottomSheet = true;
}); });
widget.patientSearchViewModel
.setDefaultInPatientList();
}); });
}, },
activeColor: Colors.red, activeColor: Colors.red,
), ),
AppText( AppText(
selectedClinicName ?? "Select Clinic", "All Clinic",
fontSize: 15, fontSize: 15,
), ),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Icon(FontAwesomeIcons.sortDown))
], ],
)), ),
], onTap: () {
setState(() {
isAllClinic = true;
showBottomSheet = false;
});
widget.patientSearchViewModel.setDefaultInPatientList();
},
),
InkWell(
onTap: () {
setState(() {
isAllClinic = false;
if (widget.patientSearchViewModel.InpatientClinicList
.length >
0) showBottomSheet = true;
});
},
child: Row(
children: [
Radio(
value: 2,
groupValue: isAllClinic ? 1 : 2,
onChanged: (value) {
setState(() {
setState(() {
isAllClinic = false;
if (widget.patientSearchViewModel
.InpatientClinicList.length >
0) showBottomSheet = true;
});
});
},
activeColor: Colors.red,
),
AppText(
selectedClinicName ?? "Select Clinic",
fontSize: 15,
),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Icon(FontAwesomeIcons.sortDown))
],
)),
],
),
), ),
),
Container( Container(
margin: EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 5), margin: EdgeInsets.only(
left: 16,
right: 16,
bottom: 16,
top: widget.isMyInPatient ? 15 : 5),
child: Stack( child: Stack(
children: [ children: [
AppTextFieldCustom( AppTextFieldCustom(
@ -143,7 +145,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
hasQuery = true; hasQuery = true;
}); });
widget.patientSearchViewModel widget.patientSearchViewModel
.filterSearchResults(value, isAllClinic: isAllClinic); .filterSearchResults(value, isAllClinic: isAllClinic, isMyInPatient:widget.isMyInPatient);
}), }),
Positioned( Positioned(
right: 35, right: 35,
@ -160,7 +162,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
onPressed: () { onPressed: () {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
widget.patientSearchViewModel.sortInPatient( widget.patientSearchViewModel.sortInPatient(
isDes: isSortDes, isAllClinic: isAllClinic); isDes: isSortDes, isAllClinic: isAllClinic, isMyInPatient:widget.isMyInPatient);
isSortDes = !isSortDes; isSortDes = !isSortDes;
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
}, },
@ -170,146 +172,26 @@ class _InPatientListPageState extends State<InPatientListPage> {
), ),
), ),
widget.patientSearchViewModel.state == ViewState.Idle widget.patientSearchViewModel.state == ViewState.Idle
? widget.patientSearchViewModel.filteredInPatientItems.length > 0 ? (widget.isMyInPatient &&
? (widget.isMyInPatient && widget.patientSearchViewModel.myIinPatientList.length > 0)
widget.patientSearchViewModel.myIinPatientList ? ListOfMyInpatient(
.length == isAllClinic: isAllClinic,
0) hasQuery: hasQuery,
? NoData() patientSearchViewModel: widget.patientSearchViewModel)
: Expanded( : widget.patientSearchViewModel.filteredInPatientItems
child: Container( .length >
margin: EdgeInsets.symmetric(horizontal: 16.0), 0
child: NotificationListener( ? (widget.isMyInPatient &&
child: ListView.builder( widget.patientSearchViewModel.myIinPatientList
itemCount: widget.patientSearchViewModel .length ==
.filteredInPatientItems.length, 0)
scrollDirection: Axis.vertical, ? NoData()
// physics: ScrollPhysics(), : ListOfAllInPatient(
shrinkWrap: true, isAllClinic: isAllClinic,
itemBuilder: (context, index) { hasQuery: hasQuery,
if (!widget.isMyInPatient) patientSearchViewModel:
return PatientCard( widget.patientSearchViewModel)
patientInfo: widget : NoData()
.patientSearchViewModel
.filteredInPatientItems[index],
patientType: "1",
arrivalType: "1",
isInpatient: true,
isMyPatient: widget
.patientSearchViewModel
.filteredInPatientItems[index]
.doctorId ==
widget.patientSearchViewModel
.doctorProfile.doctorID,
onTap: () {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
Navigator.of(context).pushNamed(
PATIENTS_PROFILE,
arguments: {
"patient": widget
.patientSearchViewModel
.filteredInPatientItems[
index],
"patientType": "1",
"from": "0",
"to": "0",
"isSearch": false,
"isInpatient": true,
"arrivalType": "1",
"isMyPatient": widget
.patientSearchViewModel
.filteredInPatientItems[
index]
.doctorId ==
widget
.patientSearchViewModel
.doctorProfile
.doctorID,
});
},
);
else if (widget
.patientSearchViewModel
.filteredInPatientItems[index]
.doctorId ==
widget.patientSearchViewModel
.doctorProfile.doctorID &&
widget.isMyInPatient)
return PatientCard(
patientInfo: widget
.patientSearchViewModel
.filteredInPatientItems[index],
patientType: "1",
arrivalType: "1",
isInpatient: true,
isMyPatient: widget
.patientSearchViewModel
.filteredInPatientItems[index]
.doctorId ==
widget.patientSearchViewModel
.doctorProfile.doctorID,
onTap: () {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
Navigator.of(context).pushNamed(
PATIENTS_PROFILE,
arguments: {
"patient": widget
.patientSearchViewModel
.filteredInPatientItems[
index],
"patientType": "1",
"from": "0",
"to": "0",
"isSearch": false,
"isInpatient": true,
"arrivalType": "1",
"isMyPatient": widget
.patientSearchViewModel
.filteredInPatientItems[
index]
.doctorId ==
widget
.patientSearchViewModel
.doctorProfile
.doctorID,
});
},
);
else
return SizedBox();
}),
onNotification: (t) {
if (isAllClinic && !hasQuery) if (t
is ScrollUpdateNotification) {
if (t.metrics.pixels >=
t.metrics.maxScrollExtent - 50) {
widget.patientSearchViewModel
.addOnFilteredList();
}
if (t.metrics.pixels <=
t.metrics.minScrollExtent - 50) {
widget.patientSearchViewModel
.removeOnFilteredList();
}
}
return;
},
),
),
)
: NoData()
: Center( : Center(
child: Container( child: Container(
height: 300, height: 300,
@ -326,8 +208,8 @@ class _InPatientListPageState extends State<InPatientListPage> {
height: MediaQuery.of(context).size.height * 0.5, height: MediaQuery.of(context).size.height * 0.5,
color: Colors.white, color: Colors.white,
child: ListView.builder( child: ListView.builder(
itemCount: widget itemCount:
.patientSearchViewModel.myInpatientClinicList.length, widget.patientSearchViewModel.InpatientClinicList.length,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
physics: ScrollPhysics(), physics: ScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
@ -338,17 +220,17 @@ class _InPatientListPageState extends State<InPatientListPage> {
isAllClinic = false; isAllClinic = false;
showBottomSheet = false; showBottomSheet = false;
selectedClinicName = widget.patientSearchViewModel selectedClinicName = widget.patientSearchViewModel
.myInpatientClinicList[index]; .InpatientClinicList[index];
}); });
widget.patientSearchViewModel.filterByClinic( widget.patientSearchViewModel.filterByClinic(
clinicName: widget.patientSearchViewModel clinicName: widget.patientSearchViewModel
.myInpatientClinicList[index]); .InpatientClinicList[index]);
}, },
child: Row( child: Row(
children: [ children: [
Radio( Radio(
value: widget.patientSearchViewModel value: widget.patientSearchViewModel
.myInpatientClinicList[index], .InpatientClinicList[index],
groupValue: selectedClinicName, groupValue: selectedClinicName,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
@ -363,7 +245,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
activeColor: Colors.red, activeColor: Colors.red,
), ),
AppText(widget.patientSearchViewModel AppText(widget.patientSearchViewModel
.myInpatientClinicList[index]), .InpatientClinicList[index]),
], ],
)); ));
}), }),
@ -373,3 +255,4 @@ class _InPatientListPageState extends State<InPatientListPage> {
} }

@ -0,0 +1,124 @@
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/widgets/patients/patient_card/PatientCard.dart';
import 'package:flutter/material.dart';
import '../../../routes.dart';
import 'NoData.dart';
class ListOfAllInPatient extends StatelessWidget {
const ListOfAllInPatient({
Key key,
@required this.isAllClinic,
@required this.hasQuery,
this.patientSearchViewModel,
}) : super(key: key);
final bool isAllClinic;
final bool hasQuery;
final PatientSearchViewModel patientSearchViewModel;
@override
Widget build(BuildContext context) {
return Expanded(
child: Container(
margin: EdgeInsets.symmetric(horizontal: 16.0),
child: patientSearchViewModel.filteredInPatientItems.length == 0
? NoData()
:NotificationListener(
child: ListView.builder(
itemCount:
patientSearchViewModel.filteredInPatientItems.length,
scrollDirection: Axis.vertical,
// physics: ScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
// if (!isMyInPatient)
return PatientCard(
patientInfo: patientSearchViewModel
.filteredInPatientItems[index],
patientType: "1",
arrivalType: "1",
isInpatient: true,
isMyPatient: patientSearchViewModel
.filteredInPatientItems[index].doctorId ==
patientSearchViewModel.doctorProfile.doctorID,
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
Navigator.of(context)
.pushNamed(PATIENTS_PROFILE, arguments: {
"patient": patientSearchViewModel
.filteredInPatientItems[index],
"patientType": "1",
"from": "0",
"to": "0",
"isSearch": false,
"isInpatient": true,
"arrivalType": "1",
"isMyPatient": patientSearchViewModel
.filteredInPatientItems[index].doctorId ==
patientSearchViewModel.doctorProfile.doctorID,
});
},
);
// else if (widget.patientSearchViewModel
// .filteredInPatientItems[index].doctorId ==
// widget.patientSearchViewModel.doctorProfile.doctorID &&
// widget.isMyInPatient)
// return PatientCard(
// patientInfo: widget
// .patientSearchViewModel.filteredInPatientItems[index],
// patientType: "1",
// arrivalType: "1",
// isInpatient: true,
// isMyPatient: widget.patientSearchViewModel
// .filteredInPatientItems[index].doctorId ==
// widget.patientSearchViewModel.doctorProfile.doctorID,
// onTap: () {
// FocusScopeNode currentFocus = FocusScope.of(context);
// if (!currentFocus.hasPrimaryFocus) {
// currentFocus.unfocus();
// }
//
// Navigator.of(context)
// .pushNamed(PATIENTS_PROFILE, arguments: {
// "patient": widget.patientSearchViewModel
// .filteredInPatientItems[index],
// "patientType": "1",
// "from": "0",
// "to": "0",
// "isSearch": false,
// "isInpatient": true,
// "arrivalType": "1",
// "isMyPatient": widget.patientSearchViewModel
// .filteredInPatientItems[index].doctorId ==
// widget
// .patientSearchViewModel.doctorProfile.doctorID,
// });
// },
// );
// else
// return SizedBox();
}),
onNotification: (t) {
if (isAllClinic && !hasQuery) if (t
is ScrollUpdateNotification) {
if (t.metrics.pixels >= t.metrics.maxScrollExtent - 50) {
patientSearchViewModel.addOnFilteredList();
}
if (t.metrics.pixels <= t.metrics.minScrollExtent - 50) {
patientSearchViewModel.removeOnFilteredList();
}
}
return;
},
),
),
);
}
}

@ -0,0 +1,76 @@
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/widgets/patients/patient_card/PatientCard.dart';
import 'package:flutter/material.dart';
import '../../../routes.dart';
import 'NoData.dart';
class ListOfMyInpatient extends StatelessWidget {
const ListOfMyInpatient({
Key key,
@required this.isAllClinic,
@required this.hasQuery,
this.patientSearchViewModel,
}) : super(key: key);
final bool isAllClinic;
final bool hasQuery;
final PatientSearchViewModel patientSearchViewModel;
@override
Widget build(BuildContext context) {
return Expanded(
child:Container(
margin: EdgeInsets.symmetric(horizontal: 16.0),
child: patientSearchViewModel.filteredMyInPatientItems.length == 0
? NoData():NotificationListener(
child: ListView.builder(
itemCount: patientSearchViewModel.filteredMyInPatientItems.length,
scrollDirection: Axis.vertical,
// physics: ScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return PatientCard(
patientInfo: patientSearchViewModel.filteredMyInPatientItems[index],
patientType: "1",
arrivalType: "1",
isInpatient: true,
isMyPatient: true,
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
Navigator.of(context)
.pushNamed(PATIENTS_PROFILE, arguments: {
"patient":
patientSearchViewModel.filteredInPatientItems[index],
"patientType": "1",
"from": "0",
"to": "0",
"isSearch": false,
"isInpatient": true,
"arrivalType": "1",
"isMyPatient": true,
});
},
);
}),
onNotification: (t) {
if (isAllClinic && !hasQuery) if (t is ScrollUpdateNotification) {
//TODO Elham*
// if (t.metrics.pixels >= t.metrics.maxScrollExtent - 50) {
// patientSearchViewModel.addOnFilteredList();
// }
//
// if (t.metrics.pixels <= t.metrics.minScrollExtent - 50) {
// patientSearchViewModel.removeOnFilteredList();
// }
}
return;
},
),
),
);
}
}
Loading…
Cancel
Save