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

replay_status
Elham Rababh 4 years ago
parent 1fd192e4bc
commit e9e86e4d8c

@ -32,6 +32,8 @@ class PatientSearchViewModel extends BaseViewModel {
int inPatientPageSize = 20;
int lastSubsetIndex = 19;
List<String> myInpatientClinicList = [];
searchData(String str) {
var strExist = str.length > 0 ? true : false;
if (strExist) {
@ -184,6 +186,8 @@ class PatientSearchViewModel extends BaseViewModel {
}
} else {
setDefaultInPatientList();
generateMyInpatientClinicList();
setState(ViewState.Idle);
}
}
@ -212,6 +216,14 @@ class PatientSearchViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
generateMyInpatientClinicList() {
inPatientList.forEach((element) {
if(!myInpatientClinicList.contains(element.clinicDescription)) {
myInpatientClinicList.add(element.clinicDescription);
}
});
}
addOnFilteredList() {
if (lastSubsetIndex < inPatientList.length) {
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() {
_inPatientService.inPatientList = [];
_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/shared/app_loader_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/loader/gif_loader_container.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();
bool isSortDes = false;
bool isAllClinic = true;
bool showBottomSheet = false;
String selectedClinicName;
@override
void dispose() {
@ -43,8 +47,73 @@ class _InPatientListPageState extends State<InPatientListPage> {
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Container(
// height: MediaQuery.of(context).size.height * 0.070,
// ),
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(
margin: EdgeInsets.all(16.0),
@ -103,7 +172,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
itemCount: widget.patientSearchViewModel
.filteredInPatientItems.length,
scrollDirection: Axis.vertical,
physics: ScrollPhysics(),
// physics: ScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
if (!widget.isMyInPatient)
@ -116,16 +185,14 @@ class _InPatientListPageState extends State<InPatientListPage> {
isInpatient: true,
isMyPatient: widget
.patientSearchViewModel
.filteredInPatientItems[
index]
.filteredInPatientItems[index]
.doctorId ==
widget.patientSearchViewModel
.doctorProfile.doctorID,
onTap: () {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus
.hasPrimaryFocus) {
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
@ -133,8 +200,9 @@ class _InPatientListPageState extends State<InPatientListPage> {
PATIENTS_PROFILE,
arguments: {
"patient": widget
.patientSearchViewModel
.filteredInPatientItems[index],
.patientSearchViewModel
.filteredInPatientItems[
index],
"patientType": "1",
"from": "0",
"to": "0",
@ -155,8 +223,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
);
else if (widget
.patientSearchViewModel
.filteredInPatientItems[
index]
.filteredInPatientItems[index]
.doctorId ==
widget.patientSearchViewModel
.doctorProfile.doctorID &&
@ -170,16 +237,14 @@ class _InPatientListPageState extends State<InPatientListPage> {
isInpatient: true,
isMyPatient: widget
.patientSearchViewModel
.filteredInPatientItems[
index]
.filteredInPatientItems[index]
.doctorId ==
widget.patientSearchViewModel
.doctorProfile.doctorID,
onTap: () {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus
.hasPrimaryFocus) {
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
@ -187,8 +252,9 @@ class _InPatientListPageState extends State<InPatientListPage> {
PATIENTS_PROFILE,
arguments: {
"patient": widget
.patientSearchViewModel
.filteredInPatientItems[index],
.patientSearchViewModel
.filteredInPatientItems[
index],
"patientType": "1",
"from": "0",
"to": "0",
@ -210,9 +276,13 @@ class _InPatientListPageState extends State<InPatientListPage> {
else
return SizedBox();
}),
onNotification: (t) {
if (t is ScrollUpdateNotification && t.metrics.pixels >= t.metrics.maxScrollExtent - 50 ) {
widget.patientSearchViewModel.addOnFilteredList();
onNotification: (t) {
if (isAllClinic) if (t
is ScrollUpdateNotification &&
t.metrics.pixels >=
t.metrics.maxScrollExtent - 50) {
widget.patientSearchViewModel
.addOnFilteredList();
}
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(
child: Scaffold(
extendBodyBehindAppBar: true,
extendBodyBehindAppBar: false,
appBar: PreferredSize(
preferredSize: Size.fromHeight(
MediaQuery.of(context).size.height * 0.070),

Loading…
Cancel
Save