add filter on in patient screen by clinic and by all clinic

replay_status
Elham Rababh 5 years ago
parent 1fd192e4bc
commit e9e86e4d8c

@ -32,6 +32,8 @@ class PatientSearchViewModel extends BaseViewModel {
int inPatientPageSize = 20; int inPatientPageSize = 20;
int lastSubsetIndex = 19; int lastSubsetIndex = 19;
List<String> myInpatientClinicList = [];
searchData(String str) { searchData(String str) {
var strExist = str.length > 0 ? true : false; var strExist = str.length > 0 ? true : false;
if (strExist) { if (strExist) {
@ -184,6 +186,8 @@ class PatientSearchViewModel extends BaseViewModel {
} }
} else { } else {
setDefaultInPatientList(); setDefaultInPatientList();
generateMyInpatientClinicList();
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
@ -212,6 +216,14 @@ class PatientSearchViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
generateMyInpatientClinicList() {
inPatientList.forEach((element) {
if(!myInpatientClinicList.contains(element.clinicDescription)) {
myInpatientClinicList.add(element.clinicDescription);
}
});
}
addOnFilteredList() { addOnFilteredList() {
if (lastSubsetIndex < inPatientList.length) { if (lastSubsetIndex < inPatientList.length) {
firstSubsetIndex = firstSubsetIndex + firstSubsetIndex = firstSubsetIndex +
@ -228,6 +240,27 @@ class PatientSearchViewModel extends BaseViewModel {
} }
} }
filterByHospital({ int hospitalId}) {
filteredInPatientItems = [];
for (var i = 0; i < inPatientList.length; i++) {
if (inPatientList[i].projectId == hospitalId) {
filteredInPatientItems.add(inPatientList[i]);
}
}
notifyListeners();
}
filterByClinic({ String clinicName}) {
filteredInPatientItems = [];
for (var i = 0; i < inPatientList.length; i++) {
if (inPatientList[i].clinicDescription == clinicName) {
filteredInPatientItems.add(inPatientList[i]);
}
}
notifyListeners();
}
void clearPatientList() { void clearPatientList() {
_inPatientService.inPatientList = []; _inPatientService.inPatientList = [];
_inPatientService.myInPatientList = []; _inPatientService.myInPatientList = [];

@ -5,6 +5,7 @@ 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/patients/patient_card/PatientCard.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.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/errors/error_message.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_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';
@ -28,6 +29,9 @@ class _InPatientListPageState extends State<InPatientListPage> {
TextEditingController _searchController = TextEditingController(); TextEditingController _searchController = TextEditingController();
bool isSortDes = false; bool isSortDes = false;
bool isAllClinic = true;
bool showBottomSheet = false;
String selectedClinicName;
@override @override
void dispose() { void dispose() {
@ -43,8 +47,73 @@ class _InPatientListPageState extends State<InPatientListPage> {
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Container(
// height: MediaQuery.of(context).size.height * 0.070,
// ),
Container( Container(
height: MediaQuery.of(context).size.height * 0.070, margin: EdgeInsets.symmetric(horizontal: 14.0, vertical: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
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;
showBottomSheet = true;
});
},
child: Row(
children: [
Radio(
value: 2,
groupValue: isAllClinic ? 1 : 2,
onChanged: (value) {
setState(() {
setState(() {
isAllClinic = false;
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.all(16.0), margin: EdgeInsets.all(16.0),
@ -103,7 +172,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
itemCount: widget.patientSearchViewModel itemCount: widget.patientSearchViewModel
.filteredInPatientItems.length, .filteredInPatientItems.length,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
physics: ScrollPhysics(), // physics: ScrollPhysics(),
shrinkWrap: true, shrinkWrap: true,
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (!widget.isMyInPatient) if (!widget.isMyInPatient)
@ -116,16 +185,14 @@ class _InPatientListPageState extends State<InPatientListPage> {
isInpatient: true, isInpatient: true,
isMyPatient: widget isMyPatient: widget
.patientSearchViewModel .patientSearchViewModel
.filteredInPatientItems[ .filteredInPatientItems[index]
index]
.doctorId == .doctorId ==
widget.patientSearchViewModel widget.patientSearchViewModel
.doctorProfile.doctorID, .doctorProfile.doctorID,
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScopeNode currentFocus =
FocusScope.of(context); FocusScope.of(context);
if (!currentFocus if (!currentFocus.hasPrimaryFocus) {
.hasPrimaryFocus) {
currentFocus.unfocus(); currentFocus.unfocus();
} }
@ -133,8 +200,9 @@ class _InPatientListPageState extends State<InPatientListPage> {
PATIENTS_PROFILE, PATIENTS_PROFILE,
arguments: { arguments: {
"patient": widget "patient": widget
.patientSearchViewModel .patientSearchViewModel
.filteredInPatientItems[index], .filteredInPatientItems[
index],
"patientType": "1", "patientType": "1",
"from": "0", "from": "0",
"to": "0", "to": "0",
@ -155,8 +223,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
); );
else if (widget else if (widget
.patientSearchViewModel .patientSearchViewModel
.filteredInPatientItems[ .filteredInPatientItems[index]
index]
.doctorId == .doctorId ==
widget.patientSearchViewModel widget.patientSearchViewModel
.doctorProfile.doctorID && .doctorProfile.doctorID &&
@ -170,16 +237,14 @@ class _InPatientListPageState extends State<InPatientListPage> {
isInpatient: true, isInpatient: true,
isMyPatient: widget isMyPatient: widget
.patientSearchViewModel .patientSearchViewModel
.filteredInPatientItems[ .filteredInPatientItems[index]
index]
.doctorId == .doctorId ==
widget.patientSearchViewModel widget.patientSearchViewModel
.doctorProfile.doctorID, .doctorProfile.doctorID,
onTap: () { onTap: () {
FocusScopeNode currentFocus = FocusScopeNode currentFocus =
FocusScope.of(context); FocusScope.of(context);
if (!currentFocus if (!currentFocus.hasPrimaryFocus) {
.hasPrimaryFocus) {
currentFocus.unfocus(); currentFocus.unfocus();
} }
@ -187,8 +252,9 @@ class _InPatientListPageState extends State<InPatientListPage> {
PATIENTS_PROFILE, PATIENTS_PROFILE,
arguments: { arguments: {
"patient": widget "patient": widget
.patientSearchViewModel .patientSearchViewModel
.filteredInPatientItems[index], .filteredInPatientItems[
index],
"patientType": "1", "patientType": "1",
"from": "0", "from": "0",
"to": "0", "to": "0",
@ -210,9 +276,13 @@ class _InPatientListPageState extends State<InPatientListPage> {
else else
return SizedBox(); return SizedBox();
}), }),
onNotification: (t) { onNotification: (t) {
if (t is ScrollUpdateNotification && t.metrics.pixels >= t.metrics.maxScrollExtent - 50 ) { if (isAllClinic) if (t
widget.patientSearchViewModel.addOnFilteredList(); is ScrollUpdateNotification &&
t.metrics.pixels >=
t.metrics.maxScrollExtent - 50) {
widget.patientSearchViewModel
.addOnFilteredList();
} }
return; return;
}, },
@ -228,6 +298,56 @@ class _InPatientListPageState extends State<InPatientListPage> {
), ),
], ],
), ),
bottomSheet: !showBottomSheet
? Container(
height: 0,
)
: Container(
height: 500,
color: Colors.white,
child: ListView.builder(
itemCount: widget
.patientSearchViewModel.myInpatientClinicList.length,
scrollDirection: Axis.vertical,
physics: ScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
setState(() {
isAllClinic = false;
showBottomSheet = false;
selectedClinicName = widget.patientSearchViewModel
.myInpatientClinicList[index];
});
widget.patientSearchViewModel.filterByClinic(
clinicName: widget.patientSearchViewModel
.myInpatientClinicList[index]);
},
child: Row(
children: [
Radio(
value: widget.patientSearchViewModel
.myInpatientClinicList[index],
groupValue: selectedClinicName,
onChanged: (value) {
setState(() {
setState(() {
isAllClinic = false;
showBottomSheet = false;
});
widget.patientSearchViewModel
.filterByClinic(clinicName: value);
});
},
activeColor: Colors.red,
),
AppText(widget.patientSearchViewModel
.myInpatientClinicList[index]),
],
));
}),
),
); );
} }
} }

@ -221,7 +221,7 @@ class _InPatientScreenState extends State<InPatientScreen>
), ),
Expanded( Expanded(
child: Scaffold( child: Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: false,
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: Size.fromHeight( preferredSize: Size.fromHeight(
MediaQuery.of(context).size.height * 0.070), MediaQuery.of(context).size.height * 0.070),

Loading…
Cancel
Save