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

@ -1,13 +1,30 @@
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/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class InPatientHeader extends StatelessWidget with PreferredSizeWidget{
const InPatientHeader() : super();
class InPatientHeader extends StatelessWidget with PreferredSizeWidget {
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
Widget build(BuildContext context) {
ProjectViewModel projectsProvider = Provider.of<ProjectViewModel>(context);
return Container(
padding: EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5),
decoration: BoxDecoration(
@ -24,19 +41,87 @@ class InPatientHeader extends StatelessWidget with PreferredSizeWidget{
),
Expanded(
child: AppText(
TranslationBase
.of(context)
.inPatient,
TranslationBase.of(context).inPatient,
fontSize: SizeConfig.textMultiplier * 2.8,
fontWeight: FontWeight.bold,
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
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 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
_InPatientListPageState createState() => _InPatientListPageState();
@ -28,10 +39,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
TextEditingController _searchController = TextEditingController();
bool isSortDes = false;
bool isAllClinic = true;
bool hasQuery = false;
bool showBottomSheet = false;
String selectedClinicName;
@override
void dispose() {
@ -47,7 +55,8 @@ class _InPatientListPageState extends State<InPatientListPage> {
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!widget.isMyInPatient)
if (!widget.isMyInPatient &&
widget.patientSearchViewModel.inPatientList.isNotEmpty)
Container(
margin: EdgeInsets.only(left: 10.0, right: 10, top: 10),
child: Row(
@ -58,14 +67,14 @@ class _InPatientListPageState extends State<InPatientListPage> {
children: [
Radio(
value: 1,
groupValue: isAllClinic ? 1 : 2,
groupValue: widget.isAllClinic ? 1 : 2,
onChanged: (value) {
setState(() {
setState(() {
isAllClinic = true;
showBottomSheet = false;
selectedClinicName = null;
});
widget.onChangeValue(
isAllClinic: true,
showBottomSheet: false,
selectedClinicName: null);
widget.patientSearchViewModel
.setDefaultInPatientList();
});
@ -79,48 +88,55 @@ class _InPatientListPageState extends State<InPatientListPage> {
],
),
onTap: () {
setState(() {
isAllClinic = true;
selectedClinicName = null;
showBottomSheet = false;
});
widget.onChangeValue(
isAllClinic: true,
showBottomSheet: false,
selectedClinicName: null);
widget.patientSearchViewModel.setDefaultInPatientList();
},
),
InkWell(
onTap: () {
setState(() {
if (widget
.patientSearchViewModel.InpatientClinicList.isNotEmpty)
InkWell(
onTap: () {
if (widget.patientSearchViewModel.InpatientClinicList
.length >
0) showBottomSheet = true;
});
},
child: Row(
children: [
Radio(
value: 2,
groupValue: isAllClinic ? 1 : 2,
onChanged: (value) {
setState(() {
setState(() {
if (widget.patientSearchViewModel
.InpatientClinicList.length >
0) showBottomSheet = true;
});
});
},
activeColor: Colors.red,
),
AppText(
selectedClinicName ?? TranslationBase.of(context).clinicSelect,
fontSize: 15,
),
Container(
margin: EdgeInsets.only(bottom: 10),
child: Icon(FontAwesomeIcons.sortDown))
],
)),
0) {
widget.onChangeValue(
isAllClinic: false,
showBottomSheet: true,
selectedClinicName: widget.selectedClinicName);
}
},
child: Row(
children: [
Radio(
value: 2,
groupValue: widget.isAllClinic ? 1 : 2,
onChanged: (value) {
if (widget.patientSearchViewModel
.InpatientClinicList.length >
0) {
widget.onChangeValue(
isAllClinic: false,
showBottomSheet: true,
selectedClinicName:
widget.selectedClinicName);
}
},
activeColor: Colors.red,
),
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;
});
widget.patientSearchViewModel.filterSearchResults(value,
isAllClinic: isAllClinic,
isAllClinic: widget.isAllClinic,
isMyInPatient: widget.isMyInPatient);
}),
Positioned(
@ -167,7 +183,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
GifLoaderDialogUtils.showMyDialog(context);
widget.patientSearchViewModel.sortInPatient(
isDes: isSortDes,
isAllClinic: isAllClinic,
isAllClinic: widget.isAllClinic,
isMyInPatient: widget.isMyInPatient);
isSortDes = !isSortDes;
GifLoaderDialogUtils.hideDialog(context);
@ -181,7 +197,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
? (widget.isMyInPatient &&
widget.patientSearchViewModel.myIinPatientList.length > 0)
? ListOfMyInpatient(
isAllClinic: isAllClinic,
isAllClinic: widget.isAllClinic,
hasQuery: hasQuery,
patientSearchViewModel: widget.patientSearchViewModel)
: widget.patientSearchViewModel.filteredInPatientItems
@ -193,7 +209,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
0)
? NoData()
: ListOfAllInPatient(
isAllClinic: isAllClinic,
isAllClinic: widget.isAllClinic,
hasQuery: hasQuery,
patientSearchViewModel:
widget.patientSearchViewModel)
@ -206,7 +222,7 @@ class _InPatientListPageState extends State<InPatientListPage> {
),
],
),
bottomSheet: !showBottomSheet
bottomSheet: !widget.showBottomSheet
? Container(
height: 0,
)
@ -224,9 +240,10 @@ class _InPatientListPageState extends State<InPatientListPage> {
children: [
InkWell(
onTap: () {
setState(() {
showBottomSheet = false;
});
widget.onChangeValue(
isAllClinic: widget.isAllClinic,
showBottomSheet: false,
selectedClinicName: widget.selectedClinicName);
},
child: Icon(DoctorApp.close_1,
size: SizeConfig.getTextMultiplierBasedOnWidth() *
@ -257,13 +274,13 @@ class _InPatientListPageState extends State<InPatientListPage> {
itemBuilder: (context, index) {
return InkWell(
onTap: () {
setState(() {
isAllClinic = false;
showBottomSheet = false;
selectedClinicName = widget
.patientSearchViewModel
.InpatientClinicList[index];
});
widget.onChangeValue(
isAllClinic: false,
showBottomSheet: false,
selectedClinicName: widget
.patientSearchViewModel
.InpatientClinicList[index]);
widget.patientSearchViewModel.filterByClinic(
clinicName: widget.patientSearchViewModel
.InpatientClinicList[index]);
@ -273,16 +290,15 @@ class _InPatientListPageState extends State<InPatientListPage> {
Radio(
value: widget.patientSearchViewModel
.InpatientClinicList[index],
groupValue: selectedClinicName,
groupValue: widget.selectedClinicName,
onChanged: (value) {
setState(() {
setState(() {
isAllClinic = false;
showBottomSheet = false;
selectedClinicName = widget
.patientSearchViewModel
.InpatientClinicList[index];
});
widget.onChangeValue(
isAllClinic: false,
showBottomSheet: false,
selectedClinicName: widget
.patientSearchViewModel
.InpatientClinicList[index]);
widget.patientSearchViewModel
.filterByClinic(clinicName: value);
});

@ -21,6 +21,9 @@ import 'in_patient_list_page.dart';
class InPatientScreen extends StatefulWidget {
GetSpecialClinicalCareListResponseModel specialClinic;
bool isAllClinic = true;
bool showBottomSheet = false;
String selectedClinicName;
InPatientScreen({Key key, this.specialClinic});
@override
@ -31,7 +34,6 @@ class _InPatientScreenState extends State<InPatientScreen>
with SingleTickerProviderStateMixin {
TabController _tabController;
int _activeTab = 0;
int selectedMapId;
@override
@ -74,95 +76,35 @@ class _InPatientScreenState extends State<InPatientScreen>
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
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(
crossAxisAlignment: CrossAxisAlignment.start,
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(
child: Scaffold(
extendBodyBehindAppBar: false,
@ -210,8 +152,20 @@ class _InPatientScreenState extends State<InPatientScreen>
physics: BouncingScrollPhysics(),
controller: _tabController,
children: [
InPatientListPage(false, model),
InPatientListPage(true, model),
InPatientListPage(
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(),
],
),
@ -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,
{int counter = -1}) {
return Center(

Loading…
Cancel
Save