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.
524 lines
28 KiB
Dart
524 lines
28 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/master_lookup_key.dart';
|
|
import 'package:doctor_app_flutter/core/enum/viewstate.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:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:hexcolor/hexcolor.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../../../routes.dart';
|
|
|
|
class AdmissionRequestSecondScreen extends StatefulWidget {
|
|
@override
|
|
_AdmissionRequestSecondScreenState createState() =>
|
|
_AdmissionRequestSecondScreenState();
|
|
}
|
|
|
|
class _AdmissionRequestSecondScreenState
|
|
extends State<AdmissionRequestSecondScreen> {
|
|
final _expectedDaysController = TextEditingController();
|
|
final _treatmentLineController = TextEditingController();
|
|
final _preOperativeOrdersController = TextEditingController();
|
|
DateTime _expectedAdmissionDate;
|
|
bool _emergencyAdmission = false;
|
|
bool _patientPregnant = false;
|
|
bool _preAnesthesiaReferred = false;
|
|
dynamic _selectedWard;
|
|
dynamic _selectedAdmissionType;
|
|
dynamic _selectedDiagnosis;
|
|
dynamic _selectedAllergies;
|
|
|
|
@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).otherInformation,
|
|
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)
|
|
.expectedDays,
|
|
null,
|
|
false),
|
|
enabled: true,
|
|
controller: _expectedDaysController,
|
|
inputFormatters: [
|
|
FilteringTextInputFormatter.allow(
|
|
RegExp(ONLY_NUMBERS))
|
|
],
|
|
keyboardType: TextInputType.number,
|
|
)),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: () {
|
|
if (_expectedAdmissionDate == null) {
|
|
_expectedAdmissionDate = DateTime.now();
|
|
}
|
|
_selectDate(
|
|
context, _expectedAdmissionDate,
|
|
(picked) {
|
|
setState(() {
|
|
_expectedAdmissionDate = picked;
|
|
});
|
|
});
|
|
},
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.expectedAdmissionDate,
|
|
_expectedAdmissionDate != null
|
|
? "${DateUtils.convertStringToDateFormat(_expectedAdmissionDate.toString(), "yyyy-MM-dd")}"
|
|
: null,
|
|
true,
|
|
suffixIcon: Icon(
|
|
Icons.calendar_today,
|
|
color: Colors.black,
|
|
)),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
CheckboxListTile(
|
|
title: AppText(
|
|
TranslationBase.of(context)
|
|
.emergencyAdmission,
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: SizeConfig.textMultiplier * 2.1,
|
|
),
|
|
value: _emergencyAdmission,
|
|
onChanged: (newValue) {
|
|
setState(() {
|
|
_emergencyAdmission = newValue;
|
|
});
|
|
},
|
|
controlAffinity:
|
|
ListTileControlAffinity.leading,
|
|
contentPadding: EdgeInsets.all(0),
|
|
),
|
|
CheckboxListTile(
|
|
title: AppText(
|
|
TranslationBase.of(context).patientPregnant,
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: SizeConfig.textMultiplier * 2.1,
|
|
),
|
|
value: _patientPregnant,
|
|
onChanged: (newValue) {
|
|
setState(() {
|
|
_patientPregnant = newValue;
|
|
});
|
|
},
|
|
controlAffinity:
|
|
ListTileControlAffinity.leading,
|
|
contentPadding: EdgeInsets.all(0),
|
|
),
|
|
Container(
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.treatmentLine,
|
|
null,
|
|
false),
|
|
enabled: true,
|
|
controller: _treatmentLineController,
|
|
keyboardType: TextInputType.text,
|
|
minLines: 4,
|
|
maxLines: 6,
|
|
)),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: model.wardList != null &&
|
|
model.wardList.length > 0
|
|
? () {
|
|
openListDialogField('description',
|
|
'description', model.wardList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedWard = selectedValue;
|
|
});
|
|
});
|
|
}
|
|
: () async {
|
|
await model.getWards();
|
|
if (model.state == ViewState.Idle &&
|
|
model.wardList.length > 0) {
|
|
openListDialogField('description',
|
|
'description', model.wardList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedWard = selectedValue;
|
|
});
|
|
});
|
|
} else if (model.state ==
|
|
ViewState.ErrorLocal) {
|
|
DrAppToastMsg.showErrorToast(
|
|
model.error);
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
"Empty List");
|
|
}
|
|
},
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context).ward,
|
|
_selectedWard != null
|
|
? _selectedWard['description']
|
|
: null,
|
|
true),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
CheckboxListTile(
|
|
title: AppText(
|
|
TranslationBase.of(context)
|
|
.preAnesthesiaReferred,
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: SizeConfig.textMultiplier * 2.1,
|
|
),
|
|
value: _preAnesthesiaReferred,
|
|
onChanged: (newValue) {
|
|
setState(() {
|
|
_preAnesthesiaReferred = newValue;
|
|
});
|
|
},
|
|
controlAffinity:
|
|
ListTileControlAffinity.leading,
|
|
contentPadding: EdgeInsets.all(0),
|
|
),
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: model.admissionTypeList != null &&
|
|
model.admissionTypeList.length > 0
|
|
? () {
|
|
openListDialogField('nameEn', 'id',
|
|
model.admissionTypeList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedAdmissionType =
|
|
selectedValue;
|
|
});
|
|
});
|
|
}
|
|
: () async {
|
|
await model.getMasterLookup(
|
|
MasterKeysService
|
|
.AdmissionRequestType);
|
|
if (model.state == ViewState.Idle &&
|
|
model.admissionTypeList.length >
|
|
0) {
|
|
openListDialogField('nameEn',
|
|
'id', model.admissionTypeList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedAdmissionType =
|
|
selectedValue;
|
|
});
|
|
});
|
|
} else if (model.state ==
|
|
ViewState.ErrorLocal) {
|
|
DrAppToastMsg.showErrorToast(
|
|
model.error);
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
"Empty List");
|
|
}
|
|
},
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.admissionType,
|
|
_selectedAdmissionType != null
|
|
? _selectedAdmissionType[
|
|
'nameEn']
|
|
: null,
|
|
true),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: model.diagnosisTypesList != null &&
|
|
model.diagnosisTypesList.length > 0
|
|
? () {
|
|
openListDialogField('nameEn', 'id',
|
|
model.diagnosisTypesList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedDiagnosis =
|
|
selectedValue;
|
|
});
|
|
});
|
|
}
|
|
: () async {
|
|
await model.getDiagnosis();
|
|
if (model.state == ViewState.Idle &&
|
|
model.diagnosisTypesList
|
|
.length >
|
|
0) {
|
|
openListDialogField(
|
|
'nameEn',
|
|
'id',
|
|
model.diagnosisTypesList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedDiagnosis =
|
|
selectedValue;
|
|
});
|
|
});
|
|
} else if (model.state ==
|
|
ViewState.ErrorLocal) {
|
|
DrAppToastMsg.showErrorToast(
|
|
model.error);
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
"Empty List");
|
|
}
|
|
},
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.diagnosis,
|
|
_selectedDiagnosis != null
|
|
? _selectedDiagnosis['nameEn']
|
|
: null,
|
|
true),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.preOperativeOrders,
|
|
null,
|
|
false),
|
|
enabled: true,
|
|
controller: _preOperativeOrdersController,
|
|
keyboardType: TextInputType.text,
|
|
minLines: 4,
|
|
maxLines: 6,
|
|
)),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
height: screenSize.height * 0.070,
|
|
child: InkWell(
|
|
onTap: model.allergiesList != null &&
|
|
model.allergiesList.length > 0
|
|
? () {
|
|
openListDialogField('nameEn', 'id',
|
|
model.allergiesList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedAllergies =
|
|
selectedValue;
|
|
});
|
|
});
|
|
}
|
|
: () async {
|
|
await model.getAllergies();
|
|
if (model.state == ViewState.Idle &&
|
|
model.allergiesList.length >
|
|
0) {
|
|
openListDialogField('nameEn',
|
|
'id', model.allergiesList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedAllergies =
|
|
selectedValue;
|
|
});
|
|
});
|
|
} else if (model.state ==
|
|
ViewState.ErrorLocal) {
|
|
DrAppToastMsg.showErrorToast(
|
|
model.error);
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
"Empty List");
|
|
}
|
|
},
|
|
child: TextField(
|
|
decoration:
|
|
Helpers.textFieldSelectorDecoration(
|
|
TranslationBase.of(context)
|
|
.allergies,
|
|
_selectedAllergies != null
|
|
? _selectedAllergies['nameEn']
|
|
: null,
|
|
true),
|
|
enabled: false,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: AppButton(
|
|
title: TranslationBase.of(context).next,
|
|
color: HexColor("#B8382B"),
|
|
onPressed: () {
|
|
Navigator.of(context).pushNamed(
|
|
PATIENT_ADMISSION_REQUEST_3,
|
|
arguments: {'patient': patient});
|
|
},
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: 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;
|
|
},
|
|
);
|
|
}
|
|
|
|
/*
|
|
onTap: model.wardList != null &&
|
|
model.wardList.length > 0
|
|
? () {
|
|
openListDialogField('description',
|
|
'description', model.wardList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedWard = selectedValue;
|
|
});
|
|
});
|
|
}
|
|
: () async {
|
|
await model.getWards();
|
|
if (model.state == ViewState.Idle &&
|
|
model.wardList.length > 0) {
|
|
openListDialogField('description',
|
|
'description', model.wardList,
|
|
(selectedValue) {
|
|
setState(() {
|
|
_selectedWard = selectedValue;
|
|
});
|
|
});
|
|
} else if (model.state ==
|
|
ViewState.ErrorLocal) {
|
|
DrAppToastMsg.showErrorToast(
|
|
model.error);
|
|
} else {
|
|
DrAppToastMsg.showErrorToast(
|
|
"Empty List");
|
|
}
|
|
},
|
|
*/
|
|
}
|