fix in patient issues

merge-requests/840/head
Elham Rababh 4 years ago
parent b2ce970195
commit 47df7e5919

@ -234,9 +234,14 @@ class PatientSearchViewModel extends BaseViewModel {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await getDoctorProfile(); await getDoctorProfile();
resetInPatientPagination(); resetInPatientPagination();
if (inPatientList.length > 0) if (inPatientList.length > 0) {
lastSubsetIndex = (inPatientList.length < inPatientPageSize - 1
? inPatientList.length
: inPatientPageSize - 1);
filteredInPatientItems filteredInPatientItems
.addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex));
}
if (myIinPatientList.length > 0) { if (myIinPatientList.length > 0) {
filteredMyInPatientItems.addAll(myIinPatientList); filteredMyInPatientItems.addAll(myIinPatientList);
@ -245,6 +250,7 @@ class PatientSearchViewModel extends BaseViewModel {
} }
generateInpatientClinicList() { generateInpatientClinicList() {
InpatientClinicList.clear();
inPatientList.forEach((element) { inPatientList.forEach((element) {
if (!InpatientClinicList.contains(element.clinicDescription)) { if (!InpatientClinicList.contains(element.clinicDescription)) {
InpatientClinicList.add(element.clinicDescription); InpatientClinicList.add(element.clinicDescription);

@ -1,13 +1,30 @@
import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/models/dashboard/get_special_clinical_care_List_Respose_Model.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/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class InPatientHeader extends StatelessWidget with PreferredSizeWidget{ class InPatientHeader extends StatelessWidget with PreferredSizeWidget {
const InPatientHeader() : super(); InPatientHeader(
{this.model,
this.specialClinic,
this.activeTab,
this.selectedMapId,
this.onChangeFunc})
: super();
final PatientSearchViewModel model;
final GetSpecialClinicalCareListResponseModel specialClinic;
final activeTab;
final selectedMapId;
final onChangeFunc;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectsProvider = Provider.of<ProjectViewModel>(context);
return Container( return Container(
padding: EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5), padding: EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -24,19 +41,87 @@ class InPatientHeader extends StatelessWidget with PreferredSizeWidget{
), ),
Expanded( Expanded(
child: AppText( child: AppText(
TranslationBase TranslationBase.of(context).inPatient,
.of(context)
.inPatient,
fontSize: SizeConfig.textMultiplier * 2.8, fontSize: SizeConfig.textMultiplier * 2.8,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Color(0xFF2B353E), color: Color(0xFF2B353E),
), ),
), ),
if (model.specialClinicalCareMappingList.isNotEmpty &&
specialClinic != null &&
activeTab != 2)
Container(
width: MediaQuery.of(context).size.width * .3,
child: DropdownButtonHideUnderline(
child: DropdownButton(
dropdownColor: Colors.white,
iconEnabledColor: Colors.black,
isExpanded: true,
value: selectedMapId == null
? model.specialClinicalCareMappingList[0].nursingStationID
: selectedMapId,
iconSize: 25,
elevation: 16,
selectedItemBuilder: (BuildContext context) {
return model.specialClinicalCareMappingList.map((item) {
return Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(2),
margin: EdgeInsets.all(2),
decoration: new BoxDecoration(
color: Colors.red[800],
borderRadius: BorderRadius.circular(20),
),
constraints: BoxConstraints(
minWidth: 20,
minHeight: 20,
),
child: Center(
child: AppText(
model.specialClinicalCareMappingList.length
.toString(),
color: Colors.white,
fontSize:
projectsProvider.isArabic ? 10 : 11,
textAlign: TextAlign.center,
),
)),
],
),
AppText(item.description,
fontSize: 12,
color: Colors.black,
fontWeight: FontWeight.bold,
textAlign: TextAlign.end),
],
);
}).toList();
},
onChanged: (newValue) async {
onChangeFunc(newValue);
},
items: model.specialClinicalCareMappingList.map((item) {
return DropdownMenuItem(
child: AppText(
item.description,
textAlign: TextAlign.left,
),
value: item.nursingStationID,
);
}).toList(),
)),
),
]), ]),
), ),
); );
} }
@override @override
Size get preferredSize => Size(double.maxFinite,85); Size get preferredSize => Size(double.maxFinite, 85);
} }

@ -18,7 +18,18 @@ class InPatientListPage extends StatefulWidget {
final bool isMyInPatient; final bool isMyInPatient;
final PatientSearchViewModel patientSearchViewModel; final PatientSearchViewModel patientSearchViewModel;
InPatientListPage(this.isMyInPatient, this.patientSearchViewModel); final bool isAllClinic;
final bool showBottomSheet;
final String selectedClinicName;
final Function onChangeValue;
InPatientListPage(
{this.isMyInPatient,
this.patientSearchViewModel,
this.selectedClinicName,
this.onChangeValue,
this.isAllClinic,
this.showBottomSheet});
@override @override
_InPatientListPageState createState() => _InPatientListPageState(); _InPatientListPageState createState() => _InPatientListPageState();
@ -28,10 +39,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
TextEditingController _searchController = TextEditingController(); TextEditingController _searchController = TextEditingController();
bool isSortDes = false; bool isSortDes = false;
bool isAllClinic = true;
bool hasQuery = false; bool hasQuery = false;
bool showBottomSheet = false;
String selectedClinicName;
@override @override
void dispose() { void dispose() {
@ -47,7 +55,8 @@ class _InPatientListPageState extends State<InPatientListPage> {
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (!widget.isMyInPatient) if (!widget.isMyInPatient &&
widget.patientSearchViewModel.inPatientList.isNotEmpty)
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(
@ -58,14 +67,14 @@ class _InPatientListPageState extends State<InPatientListPage> {
children: [ children: [
Radio( Radio(
value: 1, value: 1,
groupValue: isAllClinic ? 1 : 2, groupValue: widget.isAllClinic ? 1 : 2,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
setState(() { widget.onChangeValue(
isAllClinic = true; isAllClinic: true,
showBottomSheet = false; showBottomSheet: false,
selectedClinicName = null; selectedClinicName: null);
});
widget.patientSearchViewModel widget.patientSearchViewModel
.setDefaultInPatientList(); .setDefaultInPatientList();
}); });
@ -79,48 +88,55 @@ class _InPatientListPageState extends State<InPatientListPage> {
], ],
), ),
onTap: () { onTap: () {
setState(() { widget.onChangeValue(
isAllClinic = true; isAllClinic: true,
selectedClinicName = null; showBottomSheet: false,
showBottomSheet = false; selectedClinicName: null);
});
widget.patientSearchViewModel.setDefaultInPatientList(); widget.patientSearchViewModel.setDefaultInPatientList();
}, },
), ),
InkWell( if (widget
onTap: () { .patientSearchViewModel.InpatientClinicList.isNotEmpty)
setState(() { InkWell(
onTap: () {
if (widget.patientSearchViewModel.InpatientClinicList if (widget.patientSearchViewModel.InpatientClinicList
.length > .length >
0) showBottomSheet = true; 0) {
}); widget.onChangeValue(
}, isAllClinic: false,
child: Row( showBottomSheet: true,
children: [ selectedClinicName: widget.selectedClinicName);
Radio( }
value: 2, },
groupValue: isAllClinic ? 1 : 2, child: Row(
onChanged: (value) { children: [
setState(() { Radio(
setState(() { value: 2,
if (widget.patientSearchViewModel groupValue: widget.isAllClinic ? 1 : 2,
.InpatientClinicList.length > onChanged: (value) {
0) showBottomSheet = true; if (widget.patientSearchViewModel
}); .InpatientClinicList.length >
}); 0) {
}, widget.onChangeValue(
activeColor: Colors.red, isAllClinic: false,
), showBottomSheet: true,
AppText( selectedClinicName:
selectedClinicName ?? TranslationBase.of(context).clinicSelect, widget.selectedClinicName);
fontSize: 15, }
), },
Container( activeColor: Colors.red,
margin: EdgeInsets.only(bottom: 10), ),
child: Icon(FontAwesomeIcons.sortDown)) AppText(
], widget.selectedClinicName ??
)), TranslationBase.of(context).clinicSelect,
fontSize: 15,
),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Icon(FontAwesomeIcons.sortDown))
],
)),
], ],
), ),
), ),
@ -148,7 +164,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
hasQuery = true; hasQuery = true;
}); });
widget.patientSearchViewModel.filterSearchResults(value, widget.patientSearchViewModel.filterSearchResults(value,
isAllClinic: isAllClinic, isAllClinic: widget.isAllClinic,
isMyInPatient: widget.isMyInPatient); isMyInPatient: widget.isMyInPatient);
}), }),
Positioned( Positioned(
@ -167,7 +183,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
widget.patientSearchViewModel.sortInPatient( widget.patientSearchViewModel.sortInPatient(
isDes: isSortDes, isDes: isSortDes,
isAllClinic: isAllClinic, isAllClinic: widget.isAllClinic,
isMyInPatient: widget.isMyInPatient); isMyInPatient: widget.isMyInPatient);
isSortDes = !isSortDes; isSortDes = !isSortDes;
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
@ -181,7 +197,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
? (widget.isMyInPatient && ? (widget.isMyInPatient &&
widget.patientSearchViewModel.myIinPatientList.length > 0) widget.patientSearchViewModel.myIinPatientList.length > 0)
? ListOfMyInpatient( ? ListOfMyInpatient(
isAllClinic: isAllClinic, isAllClinic: widget.isAllClinic,
hasQuery: hasQuery, hasQuery: hasQuery,
patientSearchViewModel: widget.patientSearchViewModel) patientSearchViewModel: widget.patientSearchViewModel)
: widget.patientSearchViewModel.filteredInPatientItems : widget.patientSearchViewModel.filteredInPatientItems
@ -193,7 +209,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
0) 0)
? NoData() ? NoData()
: ListOfAllInPatient( : ListOfAllInPatient(
isAllClinic: isAllClinic, isAllClinic: widget.isAllClinic,
hasQuery: hasQuery, hasQuery: hasQuery,
patientSearchViewModel: patientSearchViewModel:
widget.patientSearchViewModel) widget.patientSearchViewModel)
@ -206,7 +222,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
), ),
], ],
), ),
bottomSheet: !showBottomSheet bottomSheet: !widget.showBottomSheet
? Container( ? Container(
height: 0, height: 0,
) )
@ -224,9 +240,10 @@ class _InPatientListPageState extends State<InPatientListPage> {
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () {
setState(() { widget.onChangeValue(
showBottomSheet = false; isAllClinic: widget.isAllClinic,
}); showBottomSheet: false,
selectedClinicName: widget.selectedClinicName);
}, },
child: Icon(DoctorApp.close_1, child: Icon(DoctorApp.close_1,
size: SizeConfig.getTextMultiplierBasedOnWidth() * size: SizeConfig.getTextMultiplierBasedOnWidth() *
@ -257,13 +274,13 @@ class _InPatientListPageState extends State<InPatientListPage> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
return InkWell( return InkWell(
onTap: () { onTap: () {
setState(() { widget.onChangeValue(
isAllClinic = false; isAllClinic: false,
showBottomSheet = false; showBottomSheet: false,
selectedClinicName = widget selectedClinicName: widget
.patientSearchViewModel .patientSearchViewModel
.InpatientClinicList[index]; .InpatientClinicList[index]);
});
widget.patientSearchViewModel.filterByClinic( widget.patientSearchViewModel.filterByClinic(
clinicName: widget.patientSearchViewModel clinicName: widget.patientSearchViewModel
.InpatientClinicList[index]); .InpatientClinicList[index]);
@ -273,16 +290,15 @@ class _InPatientListPageState extends State<InPatientListPage> {
Radio( Radio(
value: widget.patientSearchViewModel value: widget.patientSearchViewModel
.InpatientClinicList[index], .InpatientClinicList[index],
groupValue: selectedClinicName, groupValue: widget.selectedClinicName,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
setState(() { widget.onChangeValue(
isAllClinic = false; isAllClinic: false,
showBottomSheet = false; showBottomSheet: false,
selectedClinicName = widget selectedClinicName: widget
.patientSearchViewModel .patientSearchViewModel
.InpatientClinicList[index]; .InpatientClinicList[index]);
});
widget.patientSearchViewModel widget.patientSearchViewModel
.filterByClinic(clinicName: value); .filterByClinic(clinicName: value);
}); });

@ -21,6 +21,9 @@ import 'in_patient_list_page.dart';
class InPatientScreen extends StatefulWidget { class InPatientScreen extends StatefulWidget {
GetSpecialClinicalCareListResponseModel specialClinic; GetSpecialClinicalCareListResponseModel specialClinic;
bool isAllClinic = true;
bool showBottomSheet = false;
String selectedClinicName;
InPatientScreen({Key key, this.specialClinic}); InPatientScreen({Key key, this.specialClinic});
@override @override
@ -31,7 +34,6 @@ class _InPatientScreenState extends State<InPatientScreen>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
TabController _tabController; TabController _tabController;
int _activeTab = 0; int _activeTab = 0;
int selectedMapId; int selectedMapId;
@override @override
@ -74,95 +76,35 @@ class _InPatientScreenState extends State<InPatientScreen>
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
isShowAppBar: true, isShowAppBar: true,
appBar: InPatientHeader(), appBar: InPatientHeader(
model: model,
selectedMapId: selectedMapId,
specialClinic: widget.specialClinic,
activeTab: _activeTab,
onChangeFunc: (newValue) async {
setState(() {
selectedMapId = newValue;
});
model.clearPatientList();
GifLoaderDialogUtils.showMyDialog(context);
PatientSearchRequestModel requestModel =
PatientSearchRequestModel(
nursingStationID: selectedMapId, clinicID: 0);
await model.getInPatientList(requestModel, isLocalBusy: true);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
} else {
onChangeState(
isAllClinic: true,
showBottomSheet: false,
selectedClinicName: null);
}
}),
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (model.specialClinicalCareMappingList.isNotEmpty &&
widget.specialClinic != null &&
_activeTab != 2)
Container(
width: MediaQuery.of(context).size.width * .3,
child: DropdownButtonHideUnderline(
child: DropdownButton(
dropdownColor: Colors.white,
iconEnabledColor: Colors.black,
isExpanded: true,
value: selectedMapId == null
? model.specialClinicalCareMappingList[0].nursingStationID
: selectedMapId,
iconSize: 25,
elevation: 16,
selectedItemBuilder: (BuildContext context) {
return model.specialClinicalCareMappingList.map((item) {
return Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(2),
margin: EdgeInsets.all(2),
decoration: new BoxDecoration(
color: Colors.red[800],
borderRadius: BorderRadius.circular(20),
),
constraints: BoxConstraints(
minWidth: 20,
minHeight: 20,
),
child: Center(
child: AppText(
model
.specialClinicalCareMappingList.length
.toString(),
color: Colors.white,
fontSize:
projectsProvider.isArabic ? 10 : 11,
textAlign: TextAlign.center,
),
)),
],
),
AppText(item.description,
fontSize: 12,
color: Colors.black,
fontWeight: FontWeight.bold,
textAlign: TextAlign.end),
],
);
}).toList();
},
onChanged: (newValue) async {
setState(() {
selectedMapId = newValue;
});
model.clearPatientList();
GifLoaderDialogUtils.showMyDialog(context);
PatientSearchRequestModel requestModel =
PatientSearchRequestModel(
nursingStationID: selectedMapId, clinicID: 0);
await model.getInPatientList(requestModel,
isLocalBusy: true);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
}
},
items: model.specialClinicalCareMappingList.map((item) {
return DropdownMenuItem(
child: AppText(
item.description,
textAlign: TextAlign.left,
),
value: item.nursingStationID,
);
}).toList(),
)),
),
Expanded( Expanded(
child: Scaffold( child: Scaffold(
extendBodyBehindAppBar: false, extendBodyBehindAppBar: false,
@ -210,8 +152,20 @@ class _InPatientScreenState extends State<InPatientScreen>
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
controller: _tabController, controller: _tabController,
children: [ children: [
InPatientListPage(false, model), InPatientListPage(
InPatientListPage(true, model), isMyInPatient: false,
patientSearchViewModel: model,
isAllClinic: widget.isAllClinic,
showBottomSheet: widget.showBottomSheet,
selectedClinicName: widget.selectedClinicName,
onChangeValue: onChangeState),
InPatientListPage(
isMyInPatient: true,
patientSearchViewModel: model,
isAllClinic: widget.isAllClinic,
showBottomSheet: widget.showBottomSheet,
selectedClinicName: widget.selectedClinicName,
onChangeValue: onChangeState),
DischargedPatient(), DischargedPatient(),
], ],
), ),
@ -226,6 +180,14 @@ class _InPatientScreenState extends State<InPatientScreen>
); );
} }
onChangeState({isAllClinic, showBottomSheet, selectedClinicName}) {
setState(() {
widget.isAllClinic = isAllClinic;
widget.showBottomSheet = showBottomSheet;
widget.selectedClinicName = selectedClinicName;
});
}
Widget tabWidget(Size screenSize, bool isActive, String title, Widget tabWidget(Size screenSize, bool isActive, String title,
{int counter = -1}) { {int counter = -1}) {
return Center( return Center(

Loading…
Cancel
Save