diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 43d8b221..84fe8b44 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -30,9 +30,9 @@ class PatientSearchViewModel extends BaseViewModel { int firstSubsetIndex = 0; int inPatientPageSize = 20; - int lastSubsetIndex = 19; + int lastSubsetIndex = 20; - List myInpatientClinicList = []; + List InpatientClinicList = []; searchData(String str) { var strExist = str.length > 0 ? true : false; @@ -88,10 +88,8 @@ class PatientSearchViewModel extends BaseViewModel { sortOutPatient({bool isDes = false}) { if (isDes) filterData = filterData.reversed.toList(); - // filterData.sort((PatiantInformtion a, PatiantInformtion b)=>b.appointmentDateWithDateTimeForm.compareTo(a.appointmentDateWithDateTimeForm)); else filterData = filterData.reversed.toList(); - // filterData.sort((PatiantInformtion a, PatiantInformtion b)=>a.appointmentDateWithDateTimeForm.compareTo(b.appointmentDateWithDateTimeForm)); setState(ViewState.Idle); } @@ -166,6 +164,7 @@ class PatientSearchViewModel extends BaseViewModel { _inPatientService.myInPatientList; List filteredInPatientItems = List(); + List filteredMyInPatientItems = List(); Future getInPatientList(PatientSearchRequestModel requestModel, {bool isMyInpatient = false, bool isLocalBusy = false}) async { @@ -186,40 +185,69 @@ class PatientSearchViewModel extends BaseViewModel { } } else { setDefaultInPatientList(); - - generateMyInpatientClinicList(); + generateInpatientClinicList(); setState(ViewState.Idle); } } - sortInPatient({bool isDes = false}) { - if (isDes) - filteredInPatientItems.sort((PatiantInformtion a, PatiantInformtion b) => - b.admissionDateWithDateTimeForm - .compareTo(a.admissionDateWithDateTimeForm)); - else - filteredInPatientItems.sort((PatiantInformtion a, PatiantInformtion b) => - a.admissionDateWithDateTimeForm - .compareTo(b.admissionDateWithDateTimeForm)); + sortInPatient({bool isDes = false, bool isAllClinic, bool isMyInPatient}) { + if (isMyInPatient + ? myIinPatientList.length > 0 + : isAllClinic + ? inPatientList.length > 0 + : filteredInPatientItems.length > 0) { + List localInPatient = isMyInPatient + ? [...filteredMyInPatientItems] + : 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); } - Future setDefaultInPatientList() async { - setState(ViewState.BusyLocal); - await getDoctorProfile(); + resetInPatientPagination() { filteredInPatientItems.clear(); firstSubsetIndex = 0; lastSubsetIndex = inPatientPageSize - 1; + } + + Future setDefaultInPatientList() async { + setState(ViewState.BusyLocal); + await getDoctorProfile(); + resetInPatientPagination(); if (inPatientList.length > 0) filteredInPatientItems .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); + + if (myIinPatientList.length > 0) { + filteredMyInPatientItems.addAll(myIinPatientList); + } setState(ViewState.Idle); } - generateMyInpatientClinicList() { + generateInpatientClinicList() { inPatientList.forEach((element) { - if(!myInpatientClinicList.contains(element.clinicDescription)) { - myInpatientClinicList.add(element.clinicDescription); + if (!InpatientClinicList.contains(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 = []; for (var i = 0; i < inPatientList.length; i++) { if (inPatientList[i].projectId == hospitalId) { @@ -251,7 +285,7 @@ class PatientSearchViewModel extends BaseViewModel { notifyListeners(); } - filterByClinic({ String clinicName}) { + filterByClinic({String clinicName}) { filteredInPatientItems = []; for (var i = 0; i < inPatientList.length; i++) { if (inPatientList[i].clinicDescription == clinicName) { @@ -266,28 +300,95 @@ class PatientSearchViewModel extends BaseViewModel { _inPatientService.myInPatientList = []; } - void filterSearchResults(String query) { + void filterSearchResults(String query, + {bool isAllClinic, bool isMyInPatient}) { var strExist = query.length > 0 ? true : false; - 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]); + + if (isMyInPatient) { + List localFilteredMyInPatientItems = [ + ...myIinPatientList + ]; + + if (strExist) { + filteredMyInPatientItems.clear(); + for (var i = 0; i < localFilteredMyInPatientItems.length; i++) { + String firstName = + localFilteredMyInPatientItems[i].firstName.toUpperCase(); + String lastName = + 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 { - if (inPatientList.length > 0) filteredInPatientItems.clear(); - filteredInPatientItems.addAll(inPatientList); - notifyListeners(); + 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 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(); + } + } } } diff --git a/lib/screens/patients/In_patient/NoData.dart b/lib/screens/patients/In_patient/NoData.dart new file mode 100644 index 00000000..0c48cd2a --- /dev/null +++ b/lib/screens/patients/In_patient/NoData.dart @@ -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)), + ), + ); + } +} \ No newline at end of file diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart index c7b99200..61abf434 100644 --- a/lib/screens/patients/In_patient/in_patient_list_page.dart +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -1,19 +1,16 @@ import 'package:doctor_app_flutter/core/enum/viewstate.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/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'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.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 { final bool isMyInPatient; @@ -30,22 +27,16 @@ class _InPatientListPageState extends State { bool isSortDes = false; bool isAllClinic = true; + bool hasQuery = false; bool showBottomSheet = false; String selectedClinicName; - ScrollController _scrollController; @override void dispose() { _searchController.dispose(); - _scrollController.dispose(); super.dispose(); } - @override - void initState() { - _scrollController = new ScrollController(); - super.initState(); - } @override Widget build(BuildContext context) { @@ -55,76 +46,88 @@ class _InPatientListPageState extends State { body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Container( - // height: MediaQuery.of(context).size.height * 0.070, - // ), - Container( - 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; - }); - }, + if (!widget.isMyInPatient) + Container( + margin: EdgeInsets.only(left: 10.0, right: 10, top: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( child: Row( children: [ Radio( - value: 2, + value: 1, groupValue: isAllClinic ? 1 : 2, onChanged: (value) { setState(() { setState(() { - isAllClinic = false; - showBottomSheet = true; + isAllClinic = true; + showBottomSheet = false; }); + widget.patientSearchViewModel + .setDefaultInPatientList(); }); }, activeColor: Colors.red, ), - AppText(selectedClinicName ?? "Select Clinic", fontSize: 15,), - Container( - margin: EdgeInsets.only(bottom: 10), - child: Icon(FontAwesomeIcons.sortDown)) + AppText( + "All Clinic", + fontSize: 15, + ), ], - )), - ], + ), + 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( - margin: EdgeInsets.all(16.0), + margin: EdgeInsets.only( + left: 16, + right: 16, + bottom: 16, + top: widget.isMyInPatient ? 15 : 5), child: Stack( children: [ AppTextFieldCustom( @@ -139,7 +142,12 @@ class _InPatientListPageState extends State { ), controller: _searchController, onChanged: (value) { - widget.patientSearchViewModel.filterSearchResults(value); + setState(() { + hasQuery = true; + }); + widget.patientSearchViewModel.filterSearchResults(value, + isAllClinic: isAllClinic, + isMyInPatient: widget.isMyInPatient); }), Positioned( right: 35, @@ -155,8 +163,10 @@ class _InPatientListPageState extends State { // padding: EdgeInsets.only(bottom: 30), onPressed: () { GifLoaderDialogUtils.showMyDialog(context); - widget.patientSearchViewModel - .sortInPatient(isDes: isSortDes); + widget.patientSearchViewModel.sortInPatient( + isDes: isSortDes, + isAllClinic: isAllClinic, + isMyInPatient: widget.isMyInPatient); isSortDes = !isSortDes; GifLoaderDialogUtils.hideDialog(context); }, @@ -166,144 +176,26 @@ class _InPatientListPageState extends State { ), ), widget.patientSearchViewModel.state == ViewState.Idle - ? widget.patientSearchViewModel.filteredInPatientItems.length > 0 - ? (widget.isMyInPatient && - widget.patientSearchViewModel.myIinPatientList - .length == - 0) - ? NoData() - : Expanded( - child: Container( - margin: EdgeInsets.symmetric(horizontal: 16.0), - child: NotificationListener( - child: ListView.builder( - itemCount: widget.patientSearchViewModel - .filteredInPatientItems.length, - scrollDirection: Axis.vertical, - // physics: ScrollPhysics(), - shrinkWrap: true, - controller: _scrollController, - itemBuilder: (context, index) { - if (!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 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() + ? (widget.isMyInPatient && + widget.patientSearchViewModel.myIinPatientList.length > 0) + ? ListOfMyInpatient( + isAllClinic: isAllClinic, + hasQuery: hasQuery, + patientSearchViewModel: widget.patientSearchViewModel) + : widget.patientSearchViewModel.filteredInPatientItems + .length > + 0 + ? (widget.isMyInPatient && + widget.patientSearchViewModel.myIinPatientList + .length == + 0) + ? NoData() + : ListOfAllInPatient( + isAllClinic: isAllClinic, + hasQuery: hasQuery, + patientSearchViewModel: + widget.patientSearchViewModel) + : NoData() : Center( child: Container( height: 300, @@ -317,11 +209,11 @@ class _InPatientListPageState extends State { height: 0, ) : Container( - height: 500, + height: MediaQuery.of(context).size.height * 0.5, color: Colors.white, child: ListView.builder( - itemCount: widget - .patientSearchViewModel.myInpatientClinicList.length, + itemCount: + widget.patientSearchViewModel.InpatientClinicList.length, scrollDirection: Axis.vertical, physics: ScrollPhysics(), shrinkWrap: true, @@ -332,17 +224,17 @@ class _InPatientListPageState extends State { isAllClinic = false; showBottomSheet = false; selectedClinicName = widget.patientSearchViewModel - .myInpatientClinicList[index]; + .InpatientClinicList[index]; }); widget.patientSearchViewModel.filterByClinic( clinicName: widget.patientSearchViewModel - .myInpatientClinicList[index]); + .InpatientClinicList[index]); }, child: Row( children: [ Radio( value: widget.patientSearchViewModel - .myInpatientClinicList[index], + .InpatientClinicList[index], groupValue: selectedClinicName, onChanged: (value) { setState(() { @@ -357,7 +249,7 @@ class _InPatientListPageState extends State { activeColor: Colors.red, ), AppText(widget.patientSearchViewModel - .myInpatientClinicList[index]), + .InpatientClinicList[index]), ], )); }), @@ -365,20 +257,3 @@ class _InPatientListPageState extends State { ); } } - -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)), - ), - ); - } -} diff --git a/lib/screens/patients/In_patient/list_of_all_in_patient.dart b/lib/screens/patients/In_patient/list_of_all_in_patient.dart new file mode 100644 index 00000000..6aa13094 --- /dev/null +++ b/lib/screens/patients/In_patient/list_of_all_in_patient.dart @@ -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; + }, + ), + ), + ); + } +} diff --git a/lib/screens/patients/In_patient/list_of_my_inpatient.dart b/lib/screens/patients/In_patient/list_of_my_inpatient.dart new file mode 100644 index 00000000..306f99ac --- /dev/null +++ b/lib/screens/patients/In_patient/list_of_my_inpatient.dart @@ -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; + }, + ), + ), + ); + } +} diff --git a/lib/widgets/patients/patient_card/PatientCard.dart b/lib/widgets/patients/patient_card/PatientCard.dart index 4bc5d2cd..850bc18e 100644 --- a/lib/widgets/patients/patient_card/PatientCard.dart +++ b/lib/widgets/patients/patient_card/PatientCard.dart @@ -318,46 +318,65 @@ class PatientCard extends StatelessWidget { child: Row( children: [ Expanded( - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - CustomRow( - label: TranslationBase.of(context).fileNumber, - value: patientInfo.patientId.toString(), - ), - CustomRow( - label: TranslationBase.of(context).age + " : ", - value: - "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", - ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CustomRow( + label: + TranslationBase.of(context).fileNumber, + value: patientInfo.patientId.toString(), + ), + CustomRow( + label: + TranslationBase.of(context).age + " : ", + value: + "${AppDateUtils.getAgeByBirthday(patientInfo.dateofBirth, context, isServerFormat: !isFromLiveCare)}", + ), if (isInpatient) CustomRow( label: patientInfo.admissionDate == null ? "" : TranslationBase.of(context).admissionDate + " : ", - value: patientInfo.admissionDate == null - ? "" - : "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}", - ), - if (patientInfo.admissionDate != null) - CustomRow( - 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: [ + + value: patientInfo.admissionDate == null + ? "" + : "${AppDateUtils.convertDateFromServerFormat(patientInfo.admissionDate.toString(), 'yyyy-MM-dd')}", + ), + if (patientInfo.admissionDate != null) CustomRow( - label: TranslationBase.of(context).clinic + " : ", - value: patientInfo.clinicName, + label: TranslationBase.of(context) + .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( Icons.arrow_forward,