in-patient re-design
parent
98eec8fcdb
commit
3e24278d89
@ -0,0 +1,36 @@
|
||||
import 'package:doctor_app_flutter/config/config.dart';
|
||||
import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart';
|
||||
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
|
||||
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
||||
|
||||
class PatientInPatientService extends BaseService {
|
||||
List<PatiantInformtion> inPatientList = List();
|
||||
|
||||
Future getInPatientList(
|
||||
PatientSearchRequestModel requestModel, bool isMyInpatient) async {
|
||||
hasError = false;
|
||||
await getDoctorProfile();
|
||||
|
||||
if (isMyInpatient) {
|
||||
requestModel.doctorID = doctorProfile.doctorID;
|
||||
}else {
|
||||
requestModel.doctorID = 0;
|
||||
}
|
||||
|
||||
await baseAppClient.post(
|
||||
GET_PATIENT_IN_PATIENT_LIST,
|
||||
onSuccess: (dynamic response, int statusCode) {
|
||||
inPatientList.clear();
|
||||
|
||||
response['List_MyInPatient'].forEach((v) {
|
||||
inPatientList.add(PatiantInformtion.fromJson(v));
|
||||
});
|
||||
},
|
||||
onFailure: (String error, int statusCode) {
|
||||
hasError = true;
|
||||
super.error = error;
|
||||
},
|
||||
body: requestModel.toJson(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,54 @@
|
||||
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
||||
import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart';
|
||||
import 'package:doctor_app_flutter/core/service/patientInPatientService.dart';
|
||||
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
||||
|
||||
import '../../locator.dart';
|
||||
import 'base_view_model.dart';
|
||||
|
||||
class PatientSearchViewModel extends BaseViewModel{
|
||||
class PatientSearchViewModel extends BaseViewModel {
|
||||
PatientInPatientService _inPatientService =
|
||||
locator<PatientInPatientService>();
|
||||
|
||||
List<PatiantInformtion> get _inPatientList => _inPatientService.inPatientList;
|
||||
List<PatiantInformtion> filteredInPatientItems = List();
|
||||
|
||||
Future getInPatientList(PatientSearchRequestModel requestModel,
|
||||
{bool isMyInpatient = false}) async {
|
||||
setState(ViewState.Busy);
|
||||
await _inPatientService.getInPatientList(requestModel, isMyInpatient);
|
||||
if (_inPatientService.hasError) {
|
||||
error = _inPatientService.error;
|
||||
setState(ViewState.Error);
|
||||
} else {
|
||||
setState(ViewState.Idle);
|
||||
filteredInPatientItems.clear();
|
||||
filteredInPatientItems.addAll(_inPatientList);
|
||||
}
|
||||
}
|
||||
|
||||
void filterSearchResults(String query) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
} else {
|
||||
filteredInPatientItems = _inPatientList;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,189 @@
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:doctor_app_flutter/core/model/PatientSearchRequestModel.dart';
|
||||
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
|
||||
import 'package:doctor_app_flutter/models/patient/patiant_info_model.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/PatientCard.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_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/text_fields_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../routes.dart';
|
||||
|
||||
class PatientInPatientScreen extends StatefulWidget {
|
||||
@override
|
||||
_PatientInPatientScreenState createState() => _PatientInPatientScreenState();
|
||||
}
|
||||
|
||||
class _PatientInPatientScreenState extends State<PatientInPatientScreen> {
|
||||
PatientSearchRequestModel requestModel = PatientSearchRequestModel();
|
||||
int _activeTab = 0;
|
||||
|
||||
TextEditingController _searchController = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
|
||||
return BaseView<PatientSearchViewModel>(
|
||||
onModelReady: (model) => model.getInPatientList(requestModel),
|
||||
builder: (_, model, w) => AppScaffold(
|
||||
baseViewModel: model,
|
||||
isShowAppBar: false,
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 10, right: 10, bottom: 10),
|
||||
margin: EdgeInsets.only(top: 50),
|
||||
child: Row(children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_back_ios),
|
||||
color: Colors.black, //Colors.black,
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
Expanded(
|
||||
child: AppText(
|
||||
TranslationBase.of(context).inPatient,
|
||||
fontSize: SizeConfig.textMultiplier * 2.8,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF2B353E),
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
tabsBar(context, screenSize, model),
|
||||
model.filteredInPatientItems.length > 0
|
||||
? Expanded(
|
||||
child: Container(
|
||||
margin: EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppTextFieldCustom(
|
||||
hintText: TranslationBase.of(context)
|
||||
.searchPatientName,
|
||||
isTextFieldHasSuffix: true,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
Icons.search,
|
||||
color: Colors.black,
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
controller: _searchController,
|
||||
onChanged: (value) {
|
||||
model.filterSearchResults(value);
|
||||
}),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
...model.filteredInPatientItems.map((item) {
|
||||
return PatientCard(
|
||||
patientInfo: item,
|
||||
patientType: "1",
|
||||
arrivalType: "1",
|
||||
isInpatient: true,
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.pushNamed(PATIENTS_PROFILE, arguments: {
|
||||
"patient": item,
|
||||
"patientType": "1",
|
||||
"from": "0",
|
||||
"to": "0",
|
||||
"isSearch": false,
|
||||
"isInpatient": true,
|
||||
"arrivalType": "1",
|
||||
});
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
child: ErrorMessage(
|
||||
error: TranslationBase.of(context).noDataAvailable)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget tabsBar(
|
||||
BuildContext context, Size screenSize, PatientSearchViewModel model) {
|
||||
List<String> _tabs = [
|
||||
TranslationBase.of(context).inPatientAll.toUpperCase(),
|
||||
TranslationBase.of(context).inPatient.toUpperCase(),
|
||||
];
|
||||
|
||||
return Container(
|
||||
height: screenSize.height * 0.070,
|
||||
decoration: TextFieldsUtils.containerBorderDecoration(
|
||||
Color(0Xffffffff), Color(0xFFCCCCCC),
|
||||
borderRadius: 4, borderWidth: 0),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: _tabs.map((item) {
|
||||
bool _isActive = _tabs[_activeTab] == item ? true : false;
|
||||
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
setState(() {
|
||||
_activeTab = _tabs.indexOf(item);
|
||||
});
|
||||
// GifLoaderDialogUtils.showMyDialog(
|
||||
// context);
|
||||
await model.getInPatientList(requestModel,
|
||||
isMyInpatient: _activeTab == 1);
|
||||
},
|
||||
child: Center(
|
||||
child: Container(
|
||||
height: screenSize.height * 0.070,
|
||||
decoration: TextFieldsUtils.containerBorderDecoration(
|
||||
_isActive
|
||||
? Color(0xFFD02127 /*B8382B*/)
|
||||
: Color(0xFFEAEAEA),
|
||||
_isActive ? Color(0xFFD02127) : Color(0xFFEAEAEA),
|
||||
borderRadius: 4,
|
||||
borderWidth: 0),
|
||||
child: Center(
|
||||
child: AppText(
|
||||
item,
|
||||
fontSize: SizeConfig.textMultiplier * 1.8,
|
||||
color: _isActive ? Colors.white : Color(0xFF2B353E),
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue