You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
446 lines
24 KiB
Dart
446 lines
24 KiB
Dart
import 'package:doctor_app_flutter/config/config.dart';
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
|
import 'package:doctor_app_flutter/core/model/admissionRequest/admission-request.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/patient-admission-request-viewmodel.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.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/date-utils.dart';
|
|
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
|
|
import 'package:doctor_app_flutter/util/helpers.dart';
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/app_buttons_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/dialogs/dailog-list-select.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:hexcolor/hexcolor.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../../../routes.dart';
|
|
|
|
class AdmissionRequestThirdScreen extends StatefulWidget {
|
|
@override
|
|
_AdmissionRequestThirdScreenState createState() =>
|
|
_AdmissionRequestThirdScreenState();
|
|
}
|
|
|
|
class _AdmissionRequestThirdScreenState
|
|
extends State<AdmissionRequestThirdScreen> {
|
|
final _postPlansEstimatedCostController = TextEditingController();
|
|
final _dietTypeRemarksController = TextEditingController();
|
|
final _estimatedCostController = TextEditingController();
|
|
|
|
// DateTime _dischargeDate;
|
|
dynamic _selectedClinic;
|
|
dynamic _selectedDoctor;
|
|
dynamic _selectedDietType;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
|
|
PatiantInformtion patient = routeArgs['patient'];
|
|
final screenSize = MediaQuery.of(context).size;
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
return BaseView<AdmissionRequestViewModel>(
|
|
builder: (_, model, w) => AppScaffold(
|
|
baseViewModel: model,
|
|
appBarTitle: TranslationBase.of(context).admissionRequest,
|
|
body: model.doctorsList != null
|
|
? Column(
|
|
children: [
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
PatientPageHeaderWidget(patient),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(
|
|
vertical: 16, horizontal: 16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
height: 16,
|
|
),
|
|
AppText(
|
|
TranslationBase.of(context)
|
|
.specialityAndDoctorDetail,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: SizeConfig.textMultiplier * 2.5,
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: model.clinicList != null &&
|
|
model.clinicList.length > 0
|
|
? () {
|
|
openListDialogField(
|
|
'clinicGroupName',
|
|
'clinicID',
|
|
model.clinicList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedClinic = selectedValue;
|
|
});
|
|
});
|
|
}
|
|
: () async {
|
|
GifLoaderDialogUtils.showMyDialog(
|
|
context);
|
|
await model.getClinics().then((_) =>
|
|
GifLoaderDialogUtils.hideDialog(
|
|
context));
|
|
if (model.state == ViewState.Idle &&
|
|
model.clinicList.length > 0) {
|
|
openListDialogField(
|
|
'clinicGroupName',
|
|
'clinicID',
|
|
model.clinicList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedClinic =
|
|
selectedValue;
|
|
});
|
|
});
|
|
} else if (model.state ==
|
|
ViewState.ErrorLocal) {
|
|
DrAppToastMsg.showErrorToast(
|
|
model.error);
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
"Empty List");
|
|
}
|
|
},
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.clinic,
|
|
_selectedClinic != null
|
|
? _selectedClinic[
|
|
'clinicGroupName']
|
|
: null,
|
|
true),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: _selectedClinic != null
|
|
? model.doctorsList != null &&
|
|
model.doctorsList.length > 0
|
|
? () {
|
|
openListDialogField(
|
|
'DoctorName',
|
|
'DoctorID',
|
|
model.doctorsList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedDoctor =
|
|
selectedValue;
|
|
});
|
|
});
|
|
}
|
|
: () async {
|
|
GifLoaderDialogUtils
|
|
.showMyDialog(context);
|
|
await model
|
|
.getClinicDoctors(
|
|
_selectedClinic[
|
|
'clinicID'])
|
|
.then((_) =>
|
|
GifLoaderDialogUtils
|
|
.hideDialog(
|
|
context));
|
|
if (model.state ==
|
|
ViewState.Idle &&
|
|
model.doctorsList.length >
|
|
0) {
|
|
openListDialogField(
|
|
'DoctorName',
|
|
'DoctorID',
|
|
model.doctorsList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedDoctor =
|
|
selectedValue;
|
|
});
|
|
});
|
|
} else if (model.state ==
|
|
ViewState.ErrorLocal) {
|
|
DrAppToastMsg.showErrorToast(
|
|
model.error);
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
"Empty List");
|
|
}
|
|
}
|
|
: null,
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.doctor,
|
|
_selectedDoctor != null
|
|
? _selectedDoctor[
|
|
'DoctorName']
|
|
: null,
|
|
true),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
AppText(
|
|
TranslationBase.of(context)
|
|
.postPlansEstimatedCost,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: SizeConfig.textMultiplier * 2.5,
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.estimatedCost,
|
|
null,
|
|
false),
|
|
enabled: true,
|
|
controller: _estimatedCostController,
|
|
inputFormatters: [
|
|
FilteringTextInputFormatter.allow(
|
|
RegExp(ONLY_NUMBERS))
|
|
],
|
|
keyboardType: TextInputType.number,
|
|
)),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context).postPlans,
|
|
null,
|
|
false),
|
|
enabled: true,
|
|
controller: _postPlansEstimatedCostController,
|
|
keyboardType: TextInputType.text,
|
|
minLines: 4,
|
|
maxLines: 6,
|
|
)),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
/* Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: () {
|
|
if (_dischargeDate == null) {
|
|
_dischargeDate = DateTime.now();
|
|
}
|
|
_selectDate(context, _dischargeDate,
|
|
(picked) {
|
|
setState(() {
|
|
_dischargeDate = picked;
|
|
});
|
|
});
|
|
},
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.expectedAdmissionDate,
|
|
_dischargeDate != null
|
|
? "${DateUtils.convertStringToDateFormat(_dischargeDate.toString(), "yyyy-MM-dd")}"
|
|
: null,
|
|
true,
|
|
suffixIcon: Icon(
|
|
Icons.calendar_today,
|
|
color: Colors.black,
|
|
)),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),*/
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: model.dietTypesList != null &&
|
|
model.dietTypesList.length > 0
|
|
? () {
|
|
openListDialogField('nameEn', 'id',
|
|
model.dietTypesList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedDietType =
|
|
selectedValue;
|
|
});
|
|
});
|
|
}
|
|
: () async {
|
|
GifLoaderDialogUtils.showMyDialog(
|
|
context);
|
|
await model.getDietTypes().then(
|
|
(_) => GifLoaderDialogUtils
|
|
.hideDialog(context));
|
|
if (model.state == ViewState.Idle &&
|
|
model.dietTypesList.length >
|
|
0) {
|
|
openListDialogField('nameEn',
|
|
'id', model.dietTypesList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedDietType =
|
|
selectedValue;
|
|
});
|
|
});
|
|
} else if (model.state ==
|
|
ViewState.ErrorLocal) {
|
|
DrAppToastMsg.showErrorToast(
|
|
model.error);
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
"Empty List");
|
|
}
|
|
},
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.dietType,
|
|
_selectedDietType != null
|
|
? _selectedDietType['nameEn']
|
|
: null,
|
|
true),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.dietTypeRemarks,
|
|
null,
|
|
false),
|
|
enabled: true,
|
|
controller: _dietTypeRemarksController,
|
|
keyboardType: TextInputType.text,
|
|
minLines: 4,
|
|
maxLines: 6,
|
|
)),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: AppButton(
|
|
title: TranslationBase.of(context).next,
|
|
color: HexColor("#B8382B"),
|
|
onPressed: () {
|
|
model.admissionRequestData = AdmissionRequest();
|
|
if (_selectedClinic != null &&
|
|
_selectedDoctor != null &&
|
|
_estimatedCostController.text != "" &&
|
|
_postPlansEstimatedCostController.text != "") {
|
|
model.admissionRequestData.patientMRN = patient.patientMRN;
|
|
model.admissionRequestData.appointmentNo = patient.appointmentNo;
|
|
model.admissionRequestData.episodeID = patient.episodeNo;
|
|
model.admissionRequestData.admissionRequestNo = 0;
|
|
|
|
model.admissionRequestData.admitToClinic = _selectedClinic['clinicID'];
|
|
model.admissionRequestData.mrpDoctorID = _selectedDoctor['DoctorID'];
|
|
model.admissionRequestData.estimatedCost = int.parse(_estimatedCostController.text);
|
|
model.admissionRequestData.elementsForImprovement = _postPlansEstimatedCostController.text;
|
|
model.admissionRequestData.isDietType = _selectedDietType != null ? true : false;
|
|
model.admissionRequestData.dietType = _selectedDietType != null ? _selectedDietType['id'] : 0;
|
|
model.admissionRequestData.dietRemarks = _dietTypeRemarksController.text;
|
|
Navigator.of(context).pushNamed(
|
|
PATIENT_ADMISSION_REQUEST_2,
|
|
arguments: {'patient': patient, 'admission-data' : model.admissionRequestData});
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
TranslationBase.of(context).pleaseFill);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: Container(),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future _selectDate(BuildContext context, DateTime dateTime,
|
|
Function(DateTime picked) updateDate) async {
|
|
final DateTime picked = await showDatePicker(
|
|
context: context,
|
|
initialDate: dateTime,
|
|
firstDate: DateTime.now(),
|
|
lastDate: DateTime(2040),
|
|
initialEntryMode: DatePickerEntryMode.calendar,
|
|
);
|
|
if (picked != null && picked != dateTime) {
|
|
updateDate(picked);
|
|
}
|
|
}
|
|
|
|
void openListDialogField(String attributeName, String attributeValueId,
|
|
List<dynamic> list, Function(dynamic selectedValue) okFunction) {
|
|
ListSelectDialog dialog = ListSelectDialog(
|
|
list: list,
|
|
attributeName: attributeName,
|
|
attributeValueId: attributeValueId,
|
|
usingSearch: true,
|
|
okText: TranslationBase.of(context).ok,
|
|
okFunction: (selectedValue) {
|
|
okFunction(selectedValue);
|
|
},
|
|
);
|
|
showDialog(
|
|
barrierDismissible: false,
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return dialog;
|
|
},
|
|
);
|
|
}
|
|
}
|