Merge branch 'episode_inpatient_changes' into 'development'

Episode inpatient changes

See merge request Cloud_Solution/doctor_app_flutter!829
merge-requests/831/merge
Mohammad Aljammal 5 years ago
commit ca3dddd581

@ -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,40 +185,69 @@ class PatientSearchViewModel extends BaseViewModel {
} }
} else { } else {
setDefaultInPatientList(); setDefaultInPatientList();
generateInpatientClinicList();
generateMyInpatientClinicList();
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
sortInPatient({bool isDes = false}) { sortInPatient({bool isDes = false, bool isAllClinic, bool isMyInPatient}) {
if (isDes) if (isMyInPatient
filteredInPatientItems.sort((PatiantInformtion a, PatiantInformtion b) => ? myIinPatientList.length > 0
b.admissionDateWithDateTimeForm : isAllClinic
.compareTo(a.admissionDateWithDateTimeForm)); ? inPatientList.length > 0
else : filteredInPatientItems.length > 0) {
filteredInPatientItems.sort((PatiantInformtion a, PatiantInformtion b) => List<PatiantInformtion> localInPatient = isMyInPatient
a.admissionDateWithDateTimeForm ? [...filteredMyInPatientItems]
.compareTo(b.admissionDateWithDateTimeForm)); : isAllClinic
? [...inPatientList]
: [...filteredInPatientItems];
if (isDes)
localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => b
.admissionDateWithDateTimeForm
.compareTo(a.admissionDateWithDateTimeForm));
else
localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => a
.admissionDateWithDateTimeForm
.compareTo(b.admissionDateWithDateTimeForm));
if (isMyInPatient) {
filteredMyInPatientItems.clear();
filteredMyInPatientItems.addAll(localInPatient);
} else if (isAllClinic) {
resetInPatientPagination();
filteredInPatientItems
.addAll(localInPatient.sublist(firstSubsetIndex, lastSubsetIndex));
} else {
filteredInPatientItems.clear();
filteredInPatientItems.addAll(localInPatient);
}
}
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future setDefaultInPatientList() async { resetInPatientPagination() {
setState(ViewState.BusyLocal);
await getDoctorProfile();
filteredInPatientItems.clear(); filteredInPatientItems.clear();
firstSubsetIndex = 0; firstSubsetIndex = 0;
lastSubsetIndex = inPatientPageSize - 1; lastSubsetIndex = inPatientPageSize - 1;
}
Future setDefaultInPatientList() async {
setState(ViewState.BusyLocal);
await getDoctorProfile();
resetInPatientPagination();
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);
} }
}); });
} }
@ -240,8 +268,14 @@ class PatientSearchViewModel extends BaseViewModel {
} }
} }
removeOnFilteredList() {
if (lastSubsetIndex - inPatientPageSize - 1 > 0) {
filteredInPatientItems.removeAt(lastSubsetIndex - inPatientPageSize - 1);
setState(ViewState.Idle);
}
}
filterByHospital({ int hospitalId}) { filterByHospital({int hospitalId}) {
filteredInPatientItems = []; filteredInPatientItems = [];
for (var i = 0; i < inPatientList.length; i++) { for (var i = 0; i < inPatientList.length; i++) {
if (inPatientList[i].projectId == hospitalId) { if (inPatientList[i].projectId == hospitalId) {
@ -251,7 +285,7 @@ class PatientSearchViewModel extends BaseViewModel {
notifyListeners(); notifyListeners();
} }
filterByClinic({ String clinicName}) { filterByClinic({String clinicName}) {
filteredInPatientItems = []; filteredInPatientItems = [];
for (var i = 0; i < inPatientList.length; i++) { for (var i = 0; i < inPatientList.length; i++) {
if (inPatientList[i].clinicDescription == clinicName) { if (inPatientList[i].clinicDescription == clinicName) {
@ -266,28 +300,95 @@ class PatientSearchViewModel extends BaseViewModel {
_inPatientService.myInPatientList = []; _inPatientService.myInPatientList = [];
} }
void filterSearchResults(String query) { void filterSearchResults(String query,
{bool isAllClinic, bool isMyInPatient}) {
var strExist = query.length > 0 ? true : false; var strExist = query.length > 0 ? true : false;
if (strExist) {
filteredInPatientItems = []; if (isMyInPatient) {
for (var i = 0; i < inPatientList.length; i++) { List<PatiantInformtion> localFilteredMyInPatientItems = [
String firstName = inPatientList[i].firstName.toUpperCase(); ...myIinPatientList
String lastName = inPatientList[i].lastName.toUpperCase(); ];
String mobile = inPatientList[i].mobileNumber.toUpperCase();
String patientID = inPatientList[i].patientId.toString(); if (strExist) {
filteredMyInPatientItems.clear();
if (firstName.contains(query.toUpperCase()) || for (var i = 0; i < localFilteredMyInPatientItems.length; i++) {
lastName.contains(query.toUpperCase()) || String firstName =
mobile.contains(query) || localFilteredMyInPatientItems[i].firstName.toUpperCase();
patientID.contains(query)) { String lastName =
filteredInPatientItems.add(inPatientList[i]); localFilteredMyInPatientItems[i].lastName.toUpperCase();
String mobile =
localFilteredMyInPatientItems[i].mobileNumber.toUpperCase();
String patientID =
localFilteredMyInPatientItems[i].patientId.toString();
if (firstName.contains(query.toUpperCase()) ||
lastName.contains(query.toUpperCase()) ||
mobile.contains(query) ||
patientID.contains(query)) {
filteredMyInPatientItems.add(localFilteredMyInPatientItems[i]);
}
} }
notifyListeners();
} else {
if (myIinPatientList.length > 0) filteredMyInPatientItems.clear();
filteredMyInPatientItems.addAll(myIinPatientList);
notifyListeners();
} }
notifyListeners();
} else { } else {
if (inPatientList.length > 0) filteredInPatientItems.clear(); if (isAllClinic) {
filteredInPatientItems.addAll(inPatientList); if (strExist) {
notifyListeners(); 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();
}
}
} }
} }

@ -0,0 +1,20 @@
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart';
import 'package:flutter/material.dart';
class NoData extends StatelessWidget {
const NoData({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Expanded(
child: SingleChildScrollView(
child: Container(
child: ErrorMessage(
error: TranslationBase.of(context).noDataAvailable)),
),
);
}
}

@ -1,19 +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 '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;
@ -30,22 +27,16 @@ class _InPatientListPageState extends State<InPatientListPage> {
bool isSortDes = false; bool isSortDes = false;
bool isAllClinic = true; bool isAllClinic = true;
bool hasQuery = false;
bool showBottomSheet = false; bool showBottomSheet = false;
String selectedClinicName; String selectedClinicName;
ScrollController _scrollController;
@override @override
void dispose() { void dispose() {
_searchController.dispose(); _searchController.dispose();
_scrollController.dispose();
super.dispose(); super.dispose();
} }
@override
void initState() {
_scrollController = new ScrollController();
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -55,76 +46,88 @@ class _InPatientListPageState extends State<InPatientListPage> {
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Container( if (!widget.isMyInPatient)
// height: MediaQuery.of(context).size.height * 0.070, Container(
// ), margin: EdgeInsets.only(left: 10.0, right: 10, top: 10),
Container( child: Row(
margin: EdgeInsets.symmetric(horizontal: 14.0, vertical: 10), mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: Row( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, InkWell(
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( 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;
showBottomSheet = true; showBottomSheet = false;
}); });
widget.patientSearchViewModel
.setDefaultInPatientList();
}); });
}, },
activeColor: Colors.red, activeColor: Colors.red,
), ),
AppText(selectedClinicName ?? "Select Clinic", fontSize: 15,), AppText(
Container( "All Clinic",
margin: EdgeInsets.only(bottom: 10), fontSize: 15,
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.all(16.0), margin: EdgeInsets.only(
left: 16,
right: 16,
bottom: 16,
top: widget.isMyInPatient ? 15 : 5),
child: Stack( child: Stack(
children: [ children: [
AppTextFieldCustom( AppTextFieldCustom(
@ -139,7 +142,12 @@ class _InPatientListPageState extends State<InPatientListPage> {
), ),
controller: _searchController, controller: _searchController,
onChanged: (value) { onChanged: (value) {
widget.patientSearchViewModel.filterSearchResults(value); setState(() {
hasQuery = true;
});
widget.patientSearchViewModel.filterSearchResults(value,
isAllClinic: isAllClinic,
isMyInPatient: widget.isMyInPatient);
}), }),
Positioned( Positioned(
right: 35, right: 35,
@ -155,8 +163,10 @@ class _InPatientListPageState extends State<InPatientListPage> {
// padding: EdgeInsets.only(bottom: 30), // padding: EdgeInsets.only(bottom: 30),
onPressed: () { onPressed: () {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
widget.patientSearchViewModel widget.patientSearchViewModel.sortInPatient(
.sortInPatient(isDes: isSortDes); isDes: isSortDes,
isAllClinic: isAllClinic,
isMyInPatient: widget.isMyInPatient);
isSortDes = !isSortDes; isSortDes = !isSortDes;
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
}, },
@ -166,144 +176,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<ScrollEndNotification>( ? (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,
controller: _scrollController, hasQuery: hasQuery,
itemBuilder: (context, index) { patientSearchViewModel:
if (!widget.isMyInPatient) widget.patientSearchViewModel)
return PatientCard( : NoData()
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 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: (notification) {
if (isAllClinic) if (notification
is ScrollUpdateNotification &&
notification.metrics.pixels >=
notification.metrics.maxScrollExtent - 50) {
widget.patientSearchViewModel
.addOnFilteredList();
}
// print("scroll position scroll ${_scrollController.position.pixels}");
// if(_scrollController.position.pixels > widget.patientSearchViewModel
// .filteredInPatientItems.length / 4){
// _scrollController.jumpTo(0);
// }
return;
},
),
),
)
: NoData()
: Center( : Center(
child: Container( child: Container(
height: 300, height: 300,
@ -317,11 +209,11 @@ class _InPatientListPageState extends State<InPatientListPage> {
height: 0, height: 0,
) )
: Container( : Container(
height: 500, 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,
@ -332,17 +224,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(() {
@ -357,7 +249,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
activeColor: Colors.red, activeColor: Colors.red,
), ),
AppText(widget.patientSearchViewModel AppText(widget.patientSearchViewModel
.myInpatientClinicList[index]), .InpatientClinicList[index]),
], ],
)); ));
}), }),
@ -365,20 +257,3 @@ class _InPatientListPageState extends State<InPatientListPage> {
); );
} }
} }
class NoData extends StatelessWidget {
const NoData({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Expanded(
child: SingleChildScrollView(
child: Container(
child: ErrorMessage(
error: TranslationBase.of(context).noDataAvailable)),
),
);
}
}

@ -0,0 +1,123 @@
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,
shrinkWrap: true,
itemBuilder: (context, index) {
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: (notification) {
if (isAllClinic && !hasQuery) if (notification
is ScrollUpdateNotification) {
if (notification.metrics.pixels >= notification.metrics.maxScrollExtent - 50) {
patientSearchViewModel.addOnFilteredList();
}
if (notification.metrics.pixels <= notification.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;
},
),
),
);
}
}

@ -318,46 +318,65 @@ class PatientCard extends StatelessWidget {
child: Row( child: Row(
children: [ children: [
Expanded( Expanded(
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ child: Column(
CustomRow( crossAxisAlignment: CrossAxisAlignment.start,
label: TranslationBase.of(context).fileNumber, children: [
value: patientInfo.patientId.toString(), CustomRow(
), label:
CustomRow( TranslationBase.of(context).fileNumber,
label: TranslationBase.of(context).age + " : ", value: patientInfo.patientId.toString(),
value: ),
"${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", CustomRow(
), label:
TranslationBase.of(context).age + " : ",
value:
"${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}",
),
if (isInpatient) if (isInpatient)
CustomRow( CustomRow(
label: patientInfo.admissionDate == null label: patientInfo.admissionDate == null
? "" ? ""
: TranslationBase.of(context).admissionDate + " : ", : TranslationBase.of(context).admissionDate + " : ",
value: patientInfo.admissionDate == null
? "" value: patientInfo.admissionDate == null
: "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}", ? ""
), : "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}",
if (patientInfo.admissionDate != null) ),
CustomRow( if (patientInfo.admissionDate != null)
label: TranslationBase.of(context).numOfDays + " : ",
value:
"${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}",
),
if (patientInfo.admissionDate != null)
CustomRow(
label: TranslationBase.of(context).roomNo + " : ",
value: "${patientInfo.roomId}",
),
if (isFromLiveCare)
Column(
children: [
CustomRow( CustomRow(
label: TranslationBase.of(context).clinic + " : ", label: TranslationBase.of(context)
value: patientInfo.clinicName, .numOfDays +
" : ",
value:
"${DateTime.now().difference(AppDateUtils.getDateTimeFromServerFormat(patientInfo.admissionDate)).inDays + 1}",
), ),
], if (patientInfo.admissionDate != null)
), CustomRow(
]), // TODO Elham* add translation
label:
"Clinic Name" +
" : ",
value: "${patientInfo.clinicDescription}",
),
if (patientInfo.admissionDate != null)
CustomRow(
label:
TranslationBase.of(context).roomNo +
" : ",
value: "${patientInfo.roomId}",
),
if (isFromLiveCare)
Column(
children: [
CustomRow(
label: TranslationBase.of(context)
.clinic +
" : ",
value: patientInfo.clinicName,
),
],
),
]),
), ),
Icon( Icon(
Icons.arrow_forward, Icons.arrow_forward,

Loading…
Cancel
Save