bottom_sheet_title design fix

merge-requests/917/head
hussam al-habibeh 4 years ago
parent b265210565
commit 2b763e954a

@ -36,9 +36,7 @@ class AddPatientSickLeaveScreen extends StatefulWidget {
final SickLeaveViewModel previousModel; final SickLeaveViewModel previousModel;
AddPatientSickLeaveScreen( AddPatientSickLeaveScreen(
{this.appointmentNo, {this.appointmentNo, this.patientMRN, this.patient, this.previousModel});
this.patientMRN,
this.patient, this.previousModel});
@override @override
_AddPatientSickLeaveScreenState createState() => _AddPatientSickLeaveScreenState createState() =>
@ -59,9 +57,9 @@ class _AddPatientSickLeaveScreenState extends State<AddPatientSickLeaveScreen> {
void _presentDatePicker() { void _presentDatePicker() {
showDatePicker( showDatePicker(
context: context, context: context,
initialDate: currentDate??DateTime.now(), initialDate: currentDate ?? DateTime.now(),
firstDate: DateTime(DateTime.now().year-1), firstDate: DateTime(DateTime.now().year - 1),
lastDate: DateTime(DateTime.now().year+1), lastDate: DateTime(DateTime.now().year + 1),
).then((pickedDate) { ).then((pickedDate) {
if (pickedDate == null) { if (pickedDate == null) {
return; return;
@ -70,7 +68,9 @@ class _AddPatientSickLeaveScreenState extends State<AddPatientSickLeaveScreen> {
final df = new DateFormat('yyyy-MM-dd'); final df = new DateFormat('yyyy-MM-dd');
addSickLeave.startDate = df.format(pickedDate); addSickLeave.startDate = df.format(pickedDate);
currentDate = pickedDate; currentDate = pickedDate;
_toDateController.text = AppDateUtils.getDayMonthYearDateFormatted(pickedDate,isMonthShort: true ); _toDateController.text = AppDateUtils.getDayMonthYearDateFormatted(
pickedDate,
isMonthShort: true);
}); });
}); });
} }
@ -91,256 +91,251 @@ class _AddPatientSickLeaveScreenState extends State<AddPatientSickLeaveScreen> {
widget.appointmentNo, widget.patientMRN); widget.appointmentNo, widget.patientMRN);
}, },
builder: (_, model, w) => GestureDetector( builder: (_, model, w) => GestureDetector(
onTap: () { onTap: () {
FocusScope.of(context).requestFocus(new FocusNode()); FocusScope.of(context).requestFocus(new FocusNode());
}, },
child: AppScaffold( child: AppScaffold(
baseViewModel: model, baseViewModel: model,
appBar: BottomSheetTitle( appBar: BottomSheetTitle(
title: TranslationBase.of(context).addSickLeave, title: TranslationBase.of(context).addSickLeave,
), ),
isShowAppBar: true, isShowAppBar: true,
body: Center( body: Center(
child: Container( child: Container(
margin: EdgeInsets.only(top: 10), margin: EdgeInsets.only(top: 10),
child: FractionallySizedBox( child: FractionallySizedBox(
widthFactor: 0.9, widthFactor: 0.9,
child: ListView( child: ListView(
children: [
SizedBox(
height: 30,
),
AppTextFieldCustom(
height: Helpers.getTextFieldHeight(),
hintText: TranslationBase.of(context).sickLeave +
' ' +
TranslationBase.of(context).days,
maxLines: 1,
minLines: 1,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
inputType:TextInputType.number,
controller: _numberOfDayController,
onChanged: (value) {
if(value.isNotEmpty)
setState(() {
addSickLeave.noOfDays = value;
});
},
validationError: isFormSubmitted &&
(addSickLeave.noOfDays == null)
? TranslationBase.of(context)
.pleaseEnterNoOfDays
: null,
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: Helpers.getTextFieldHeight(),
onClick: () {
Helpers.hideKeyboard(context);
_presentDatePicker();
},
hintText: TranslationBase.of(context)
.sickLeaveDate,
enabled: false,
maxLines: 1,
minLines: 1,
isTextFieldHasSuffix: true,
suffixIcon: IconButton(
icon: Icon(Icons.calendar_today)),
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
controller: _toDateController,
onChanged: (value) {
setState(() {
addSickLeave.startDate = value;
});
},
validationError: isFormSubmitted &&
(addSickLeave.startDate == null)
? TranslationBase.of(context)
.pleaseEnterDate
: null,
),
SizedBox(
height: 5,
),
AppTextFieldCustom(
height: Helpers.getTextFieldHeight(),
hintText: TranslationBase.of(context).clinic,
enabled: false,
maxLines: 1,
minLines: 1,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
controller: _clinicController,
onChanged: (value) {},
),
SizedBox(
height: 10,
),
model.sickLeaveStatistics.recommendedSickLeaveDays!=
null
? Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(
width: 10, height: 30,
), ),
Icon( AppTextFieldCustom(
DoctorApp.warning, height: Helpers.getTextFieldHeight(),
size: 20, hintText: TranslationBase.of(context).sickLeave +
color: IN_PROGRESS_COLOR, ' ' +
TranslationBase.of(context).days,
maxLines: 1,
minLines: 1,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
inputType: TextInputType.number,
controller: _numberOfDayController,
onChanged: (value) {
if (value.isNotEmpty)
setState(() {
addSickLeave.noOfDays = value;
});
},
validationError: isFormSubmitted &&
(addSickLeave.noOfDays == null)
? TranslationBase.of(context)
.pleaseEnterNoOfDays
: null,
), ),
SizedBox( SizedBox(
width: 10, height: 10,
), ),
Expanded( AppTextFieldCustom(
child: AppText( height: Helpers.getTextFieldHeight(),
model.sickLeaveStatistics.recommendedSickLeaveDays, onClick: () {
textAlign: TextAlign.start, Helpers.hideKeyboard(context);
fontSize: 12, _presentDatePicker();
color: IN_PROGRESS_COLOR, },
), hintText:
TranslationBase.of(context).sickLeaveDate,
enabled: false,
maxLines: 1,
minLines: 1,
isTextFieldHasSuffix: true,
suffixIcon:
IconButton(icon: Icon(Icons.calendar_today)),
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
controller: _toDateController,
onChanged: (value) {
setState(() {
addSickLeave.startDate = value;
});
},
validationError: isFormSubmitted &&
(addSickLeave.startDate == null)
? TranslationBase.of(context).pleaseEnterDate
: null,
),
SizedBox(
height: 5,
),
AppTextFieldCustom(
height: Helpers.getTextFieldHeight(),
hintText: TranslationBase.of(context).clinic,
enabled: false,
maxLines: 1,
minLines: 1,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
controller: _clinicController,
onChanged: (value) {},
),
SizedBox(
height: 10,
),
model.sickLeaveStatistics
.recommendedSickLeaveDays !=
null
? Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
SizedBox(
width: 10,
),
Icon(
DoctorApp.warning,
size: 20,
color: IN_PROGRESS_COLOR,
),
SizedBox(
width: 10,
),
Expanded(
child: AppText(
model.sickLeaveStatistics
.recommendedSickLeaveDays,
textAlign: TextAlign.start,
fontSize: 12,
color: IN_PROGRESS_COLOR,
),
),
],
)
: SizedBox(
height: 10,
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: Helpers.getTextFieldHeight(),
hintText: TranslationBase.of(context).doctor,
enabled: false,
maxLines: 1,
minLines: 1,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
controller: _doctorController,
onChanged: (value) {},
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: Helpers.getTextFieldHeight(),
hintText: TranslationBase.of(context).remarks,
maxLines: 30,
minLines: 5,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
controller: _remarkController,
onChanged: (value) {
setState(() {
addSickLeave.remarks = value;
});
},
),
SizedBox(
height: SizeConfig.heightMultiplier *
(SizeConfig.isHeightVeryShort ? 12 : 10) +
20,
), ),
], ],
)
: SizedBox(
height: 10,
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: Helpers.getTextFieldHeight(),
hintText: TranslationBase.of(context).doctor,
enabled: false,
maxLines: 1,
minLines: 1,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
controller: _doctorController,
onChanged: (value) {},
),
SizedBox(
height: 10,
),
AppTextFieldCustom(
height: Helpers.getTextFieldHeight(),
hintText: TranslationBase.of(context).remarks,
maxLines: 30,
minLines: 5,
dropDownColor: Colors.white,
isTextFieldHasSuffix: true,
controller: _remarkController,
onChanged: (value) {
setState(() {
addSickLeave.remarks = value;
});
},
), ),
),
SizedBox(
height: SizeConfig.heightMultiplier *
(SizeConfig.isHeightVeryShort ? 12 : 10) +20,
),
],
), ),
), ),
), bottomSheet: model.state == ViewState.Busy ||
), model.state == ViewState.Busy
bottomSheet: model.state == ViewState.Busy || ? Container(
model.state == ViewState.Busy height: 0,
? Container( )
height: 0, : Container(
) decoration: BoxDecoration(
: Container( color: Colors.white,
decoration: BoxDecoration( borderRadius: BorderRadius.all(
color: Colors.white, Radius.circular(0.0),
borderRadius: BorderRadius.all( ),
Radius.circular(0.0), border: Border.all(
), color: HexColor('#707070'), width: 0),
border: Border.all( ),
color: HexColor('#707070'), width: 0), height: SizeConfig.heightMultiplier *
), (SizeConfig.isHeightVeryShort ? 12 : 10),
height: SizeConfig.heightMultiplier * width: double.infinity,
(SizeConfig.isHeightVeryShort ? 12 : 10), child: Column(
width: double.infinity, children: [
child: Column( SizedBox(
children: [ height: 10,
SizedBox( ),
height: 10, FractionallySizedBox(
), widthFactor: 0.9,
FractionallySizedBox( child: AppButton(
widthFactor: 0.9, title: TranslationBase.of(context)
child: AppButton( .addSickLeaverequest,
title: TranslationBase.of(context) color: AppGlobal.appGreenColor,
.addSickLeaverequest, onPressed: () async {
color: AppGlobal.appGreenColor, submitForm(model);
onPressed: () async { }),
submitForm(model); ),
}), SizedBox(
), height: 5,
SizedBox( ),
height: 5, ],
), ),
], )),
), ));
)),
));
} }
submitForm(SickLeaveViewModel model) async { submitForm(SickLeaveViewModel model) async {
{ {
try { try {
setState(() { setState(() {
isFormSubmitted = true; isFormSubmitted = true;
}); });
if (addSickLeave.noOfDays == null || if (addSickLeave.noOfDays == null || addSickLeave.startDate == null) {
addSickLeave.startDate == null ) { return;
return; } else {
GifLoaderDialogUtils.showMyDialog(context);
addSickLeave.patientMRN = widget.patient.patientMRN.toString();
addSickLeave.appointmentNo = widget.patient.appointmentNo.toString();
await model.addSickLeave(addSickLeave);
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
} else { } else {
GifLoaderDialogUtils.showMyDialog(context); await widget.previousModel
addSickLeave.patientMRN = widget.patient.patientMRN.toString(); .getSickLeaveForPatient(widget.patient, isLocalBusy: true);
addSickLeave.appointmentNo = DrAppToastMsg.showSuccesToast(
widget.patient.appointmentNo.toString(); TranslationBase.of(context).replySuccessfully);
await model.addSickLeave(addSickLeave); Navigator.of(context).pop();
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
} else {
await widget.previousModel
.getSickLeaveForPatient(widget.patient, isLocalBusy: true);
DrAppToastMsg.showSuccesToast(
TranslationBase.of(context).replySuccessfully);
Navigator.of(context).pop();
}
GifLoaderDialogUtils.hideDialog(context);
} }
} catch (err) {
print(err);
}
GifLoaderDialogUtils.hideDialog(context);
}
} catch (err) {
print(err);
}
} }
} }
} }

@ -2,13 +2,14 @@ import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget { class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget {
BottomSheetTitle({ BottomSheetTitle({
Key key, this.title, Key key,
this.title,
}) : super(key: key); }) : super(key: key);
final String title; final String title;
double headerHeight = SizeConfig.heightMultiplier*15; double headerHeight = SizeConfig.heightMultiplier * 15;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
@ -20,29 +21,25 @@ class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget {
height: headerHeight, height: headerHeight,
child: Center( child: Center(
child: Container( child: Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(left: 10, right: 10),
left: 10, right: 10), margin: EdgeInsets.only(top: headerHeight * 0.5),
margin: EdgeInsets.only(top: headerHeight *0.5),
child: Column( child: Column(
children: [ children: [
Row( Row(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.spaceBetween,
MainAxisAlignment.spaceBetween,
children: [ children: [
RichText( RichText(
text: TextSpan( text: TextSpan(
style: TextStyle( style: TextStyle(fontSize: 20, color: Colors.black),
fontSize:20,
color: Colors.black),
children: <TextSpan>[ children: <TextSpan>[
new TextSpan( new TextSpan(
text: title, text: title,
style: TextStyle( style: TextStyle(
color: Color(0xFF2B353E), color: Color(0xFF2B353E),
fontWeight: FontWeight.bold, fontWeight: FontWeight.w700,
fontFamily: 'Poppins', fontFamily: 'Poppins',
fontSize: SizeConfig.getTextMultiplierBasedOnWidth()*6)), letterSpacing: -1.44,
fontSize: 24.0)),
], ],
), ),
), ),
@ -51,7 +48,7 @@ class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget {
Navigator.pop(context); Navigator.pop(context);
}, },
child: Icon(DoctorApp.close_1, child: Icon(DoctorApp.close_1,
size:SizeConfig.getTextMultiplierBasedOnWidth()*5, size: SizeConfig.getTextMultiplierBasedOnWidth() * 5,
color: Color(0xFF2B353E))) color: Color(0xFF2B353E)))
], ],
), ),
@ -63,5 +60,5 @@ class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget {
} }
@override @override
Size get preferredSize => Size(double.maxFinite,headerHeight); Size get preferredSize => Size(double.maxFinite, headerHeight);
} }

@ -37,7 +37,8 @@ import 'package:provider/provider.dart';
import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_recognition_error.dart';
import 'package:speech_to_text/speech_to_text.dart' as stt; import 'package:speech_to_text/speech_to_text.dart' as stt;
addPrescriptionForm(context, PrescriptionViewModel model, PatiantInformtion patient, prescription) { addPrescriptionForm(context, PrescriptionViewModel model,
PatiantInformtion patient, prescription) {
showModalBottomSheet( showModalBottomSheet(
isScrollControlled: true, isScrollControlled: true,
context: context, context: context,
@ -62,7 +63,8 @@ postPrescription(
String icdCode, String icdCode,
PatiantInformtion patient, PatiantInformtion patient,
String patientType}) async { String patientType}) async {
PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel(); PostPrescriptionReqModel postProcedureReqModel =
new PostPrescriptionReqModel();
List<PrescriptionRequestModel> prescriptionList = List(); List<PrescriptionRequestModel> prescriptionList = List();
postProcedureReqModel.appointmentNo = patient.appointmentNo; postProcedureReqModel.appointmentNo = patient.appointmentNo;
@ -126,7 +128,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
DateTime selectedDate; DateTime selectedDate;
int strengthChar; int strengthChar;
GetMedicationResponseModel _selectedMedication; GetMedicationResponseModel _selectedMedication;
GlobalKey key = new GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>(); GlobalKey key =
new GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
TextEditingController drugIdController = TextEditingController(); TextEditingController drugIdController = TextEditingController();
TextEditingController doseController = TextEditingController(); TextEditingController doseController = TextEditingController();
@ -170,7 +173,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
onVoiceText() async { onVoiceText() async {
new SpeechToText(context: context).showAlertDialog(context); new SpeechToText(context: context).showAlertDialog(context);
var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode;
bool available = await speech.initialize(onStatus: statusListener, onError: errorListener); bool available = await speech.initialize(
onStatus: statusListener, onError: errorListener);
if (available) { if (available) {
speech.listen( speech.listen(
onResult: resultListener, onResult: resultListener,
@ -213,7 +217,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
} }
Future<void> initSpeechState() async { Future<void> initSpeechState() async {
bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); bool hasSpeech = await speech.initialize(
onError: errorListener, onStatus: statusListener);
print(hasSpeech); print(hasSpeech);
if (!mounted) return; if (!mounted) return;
} }
@ -259,13 +264,15 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
initialChildSize: 0.98, initialChildSize: 0.98,
maxChildSize: 0.98, maxChildSize: 0.98,
minChildSize: 0.9, minChildSize: 0.9,
builder: (BuildContext context, ScrollController scrollController) { builder:
(BuildContext context, ScrollController scrollController) {
return SingleChildScrollView( return SingleChildScrollView(
child: Container( child: Container(
height: MediaQuery.of(context).size.height * 1.65, height: MediaQuery.of(context).size.height * 1.65,
color: Color(0xffF8F8F8), color: Color(0xffF8F8F8),
child: Padding( child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0), padding: EdgeInsets.symmetric(
horizontal: 12.0, vertical: 10.0),
child: Column( child: Column(
children: [ children: [
Column( Column(
@ -287,8 +294,11 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
widthFactor: 0.9, widthFactor: 0.9,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color: HexColor("#CCCCCC"))),
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: AppTextFormField( child: AppTextFormField(
onTap: () { onTap: () {
@ -296,7 +306,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
visbiltySearch = true; visbiltySearch = true;
}, },
borderColor: Colors.white, borderColor: Colors.white,
hintText: TranslationBase.of(context).searchMedicineNameHere, hintText: TranslationBase.of(context)
.searchMedicineNameHere,
controller: myController, controller: myController,
onSaved: (value) {}, onSaved: (value) {},
onFieldSubmitted: (value) { onFieldSubmitted: (value) {
@ -322,9 +333,12 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
children: <Widget>[ children: <Widget>[
// TODO change it secondary button and add loading // TODO change it secondary button and add loading
AppButton( AppButton(
title: TranslationBase.of(context).search, title: TranslationBase.of(
context)
.search,
onPressed: () async { onPressed: () async {
await searchMedicine(context, model); await searchMedicine(
context, model);
}, },
), ),
], ],
@ -333,23 +347,44 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
), ),
if (myController.text != '') if (myController.text != '')
Container( Container(
height: MediaQuery.of(context).size.height * 0.5, height: MediaQuery.of(context)
.size
.height *
0.5,
child: ListView.builder( child: ListView.builder(
padding: const EdgeInsets.only(top: 20), padding: const EdgeInsets.only(
top: 20),
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
itemCount: model.allMedicationList == null itemCount:
? 0 model.allMedicationList ==
: model.allMedicationList.length, null
itemBuilder: (BuildContext context, int index) { ? 0
: model
.allMedicationList
.length,
itemBuilder:
(BuildContext context,
int index) {
return InkWell( return InkWell(
child: MedicineItemWidget( child: MedicineItemWidget(
label: model.allMedicationList[index].description), label: model
.allMedicationList[
index]
.description),
onTap: () { onTap: () {
model.getItem(itemID: model.allMedicationList[index].itemId); model.getItem(
visbiltyPrescriptionForm = true; itemID: model
.allMedicationList[
index]
.itemId);
visbiltyPrescriptionForm =
true;
visbiltySearch = false; visbiltySearch = false;
_selectedMedication = model.allMedicationList[index]; _selectedMedication =
uom = _selectedMedication.uom; model.allMedicationList[
index];
uom = _selectedMedication
.uom;
}, },
); );
}, },
@ -368,53 +403,68 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
child: Column( child: Column(
children: [ children: [
AppText( AppText(
_selectedMedication?.description ?? "", _selectedMedication?.description ??
"",
bold: true, bold: true,
), ),
Container( Container(
child: Row( child: Row(
children: [ children: [
AppText( AppText(
TranslationBase.of(context).orderType, TranslationBase.of(context)
.orderType,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
Radio( Radio(
activeColor: Color(0xFFB9382C), activeColor:
Color(0xFFB9382C),
value: 1, value: 1,
groupValue: selectedType, groupValue: selectedType,
onChanged: (value) { onChanged: (value) {
setSelectedType(value); setSelectedType(value);
}, },
), ),
Text(TranslationBase.of(context).regular), Text(TranslationBase.of(context)
.regular),
], ],
), ),
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
Container( Container(
width: double.infinity, width: double.infinity,
child: Row( child: Row(
children: [ children: [
Container( Container(
width: MediaQuery.of(context).size.width * 0.35, width: MediaQuery.of(context)
.size
.width *
0.35,
child: AppTextFieldCustom( child: AppTextFieldCustom(
height: 40, //height: 40,
validationError: strengthError, validationError:
strengthError,
hintText: 'Strength', hintText: 'Strength',
isTextFieldHasSuffix: false, isTextFieldHasSuffix: false,
enabled: true, enabled: true,
controller: strengthController, controller:
strengthController,
onChanged: (String value) { onChanged: (String value) {
setState(() { setState(() {
strengthChar = value.length; strengthChar =
value.length;
}); });
if (strengthChar >= 5) { if (strengthChar >= 5) {
DrAppToastMsg.showErrorToast( DrAppToastMsg
TranslationBase.of(context).only5DigitsAllowedForStrength, .showErrorToast(
TranslationBase.of(
context)
.only5DigitsAllowedForStrength,
); );
} }
}, },
inputType: TextInputType.numberWithOptions( inputType: TextInputType
.numberWithOptions(
decimal: true, decimal: true,
), ),
), ),
@ -423,15 +473,23 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
width: 5.0, width: 5.0,
), ),
PrescriptionTextFiled( PrescriptionTextFiled(
width: MediaQuery.of(context).size.width * 0.517, width: MediaQuery.of(context)
element: model.itemMedicineListUnit.length == 1 .size
? model.itemMedicineListUnit[0] .width *
0.510,
element: model
.itemMedicineListUnit
.length ==
1
? model
.itemMedicineListUnit[0]
: units, : units,
elementError: unitError, elementError: unitError,
keyName: 'description', keyName: 'description',
keyId: 'parameterCode', keyId: 'parameterCode',
hintText: 'Select', hintText: 'Unit',
elementList: model.itemMedicineListUnit, elementList: model
.itemMedicineListUnit,
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() {
units = selectedValue; units = selectedValue;
@ -442,10 +500,14 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
], ],
), ),
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
PrescriptionTextFiled( PrescriptionTextFiled(
elementList: model.itemMedicineListRoute, elementList:
element: model.itemMedicineListRoute.length == 1 model.itemMedicineListRoute,
element: model.itemMedicineListRoute
.length ==
1
? model.itemMedicineListRoute[0] ? model.itemMedicineListRoute[0]
: route, : route,
elementError: routeError, elementError: routeError,
@ -457,40 +519,58 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
route['isDefault'] = true; route['isDefault'] = true;
}); });
}, },
hintText: TranslationBase.of(context).route, hintText:
TranslationBase.of(context)
.route,
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
PrescriptionTextFiled( PrescriptionTextFiled(
hintText: TranslationBase.of(context).frequency, hintText:
TranslationBase.of(context)
.frequency,
elementError: frequencyError, elementError: frequencyError,
element: frequency, element: frequency,
elementList: model.itemMedicineList, elementList:
model.itemMedicineList,
keyId: 'parameterCode', keyId: 'parameterCode',
keyName: 'description', keyName: 'description',
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() {
frequency = selectedValue; frequency = selectedValue;
frequency['isDefault'] = true; frequency['isDefault'] = true;
if (_selectedMedication != null && if (_selectedMedication !=
null &&
duration != null && duration != null &&
frequency != null && frequency != null &&
strengthController.text != null) { strengthController.text !=
null) {
model.getBoxQuantity( model.getBoxQuantity(
freq: frequency['parameterCode'], freq: frequency[
duration: duration['id'], 'parameterCode'],
itemCode: _selectedMedication.itemId, duration:
strength: double.parse(strengthController.text)); duration['id'],
itemCode:
_selectedMedication
.itemId,
strength: double.parse(
strengthController
.text));
return; return;
} }
}); });
}), }),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
PrescriptionTextFiled( PrescriptionTextFiled(
hintText: TranslationBase.of(context).doseTime, hintText:
TranslationBase.of(context)
.doseTime,
elementError: doseTimeError, elementError: doseTimeError,
element: doseTime, element: doseTime,
elementList: model.medicationDoseTimeList, elementList:
model.medicationDoseTimeList,
keyId: 'id', keyId: 'id',
keyName: 'nameEn', keyName: 'nameEn',
okFunction: (selectedValue) { okFunction: (selectedValue) {
@ -498,8 +578,10 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
doseTime = selectedValue; doseTime = selectedValue;
}); });
}), }),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
if (model.patientAssessmentList.isNotEmpty) height: spaceBetweenTextFileds),
if (model
.patientAssessmentList.isNotEmpty)
Container( Container(
height: screenSize.height * 0.070, height: screenSize.height * 0.070,
width: double.infinity, width: double.infinity,
@ -507,25 +589,49 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
child: Row( child: Row(
children: [ children: [
Container( Container(
width: MediaQuery.of(context).size.width * 0.29, width:
MediaQuery.of(context)
.size
.width *
0.29,
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration:
model.patientAssessmentList[0].icdCode10ID.toString(), textFieldSelectorDecoration(
indication != null ? indication['name'] : null, model
false), .patientAssessmentList[
0]
.icdCode10ID
.toString(),
indication != null
? indication[
'name']
: null,
false),
enabled: true, enabled: true,
readOnly: true, readOnly: true,
), ),
), ),
Container( Container(
width: MediaQuery.of(context).size.width * 0.59, width:
MediaQuery.of(context)
.size
.width *
0.57,
color: Colors.white, color: Colors.white,
child: TextField( child: TextField(
maxLines: 5, maxLines: 5,
decoration: textFieldSelectorDecoration( decoration:
model.patientAssessmentList[0].asciiDesc.toString(), textFieldSelectorDecoration(
indication != null ? indication['name'] : null, model
false), .patientAssessmentList[
0]
.asciiDesc
.toString(),
indication != null
? indication[
'name']
: null,
false),
enabled: true, enabled: true,
readOnly: true, readOnly: true,
), ),
@ -533,47 +639,63 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
], ],
), ),
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
Container( Container(
height: screenSize.height * 0.070, height: screenSize.height * 0.070,
color: Colors.white, color: Colors.white,
child: InkWell( child: InkWell(
onTap: () => selectDate(context, widget.model), onTap: () => selectDate(
context, widget.model),
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration:
TranslationBase.of(context).date, textFieldSelectorDecoration(
selectedDate != null TranslationBase.of(
? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" context)
: null, .date,
true, selectedDate != null
suffixIcon: Icon( ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
Icons.calendar_today, : null,
color: Colors.black, true,
)), suffixIcon: Icon(
Icons.calendar_today,
color: Colors.black,
)),
enabled: false, enabled: false,
), ),
), ),
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
PrescriptionTextFiled( PrescriptionTextFiled(
element: duration, element: duration,
elementError: durationError, elementError: durationError,
hintText: TranslationBase.of(context).duration, hintText:
elementList: model.medicationDurationList, TranslationBase.of(context)
.duration,
elementList:
model.medicationDurationList,
keyName: 'nameEn', keyName: 'nameEn',
keyId: 'id', keyId: 'id',
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() {
duration = selectedValue; duration = selectedValue;
if (_selectedMedication != null && if (_selectedMedication !=
null &&
duration != null && duration != null &&
frequency != null && frequency != null &&
strengthController.text != null) { strengthController.text !=
null) {
model.getBoxQuantity( model.getBoxQuantity(
freq: frequency['parameterCode'], freq: frequency[
'parameterCode'],
duration: duration['id'], duration: duration['id'],
itemCode: _selectedMedication.itemId, itemCode:
strength: double.parse(strengthController.text), _selectedMedication
.itemId,
strength: double.parse(
strengthController
.text),
); );
box = model.boxQuintity; box = model.boxQuintity;
@ -582,38 +704,53 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
}); });
}, },
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
Container( Container(
color: Colors.white, color: Colors.white,
child: AppTextFieldCustom( child: AppTextFieldCustom(
hintText: "UOM", hintText: "UOM",
isTextFieldHasSuffix: false, isTextFieldHasSuffix: false,
dropDownText: uom != null ? uom : null, dropDownText:
uom != null ? uom : null,
enabled: false, enabled: false,
), ),
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
Container( Container(
color: Colors.white, color: Colors.white,
child: AppTextFieldCustom( child: AppTextFieldCustom(
hintText: TranslationBase.of(context).boxQuantity, hintText:
TranslationBase.of(context)
.boxQuantity,
isTextFieldHasSuffix: false, isTextFieldHasSuffix: false,
dropDownText: box != null ? model.boxQuintity.toString() : null, dropDownText: box != null
? model.boxQuintity.toString()
: null,
enabled: false, enabled: false,
), ),
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))), Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color:
HexColor("#CCCCCC"))),
child: Stack( child: Stack(
children: [ children: [
TextFields( TextFields(
maxLines: 6, maxLines: 6,
minLines: 4, minLines: 4,
hintText: TranslationBase.of(context).instruction, hintText: TranslationBase.of(
controller: instructionController, context)
.instruction,
controller:
instructionController,
//keyboardType: TextInputType.number, //keyboardType: TextInputType.number,
), ),
Positioned( Positioned(
@ -626,51 +763,77 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
size: 35, size: 35,
), ),
onPressed: () { onPressed: () {
initSpeechState().then((value) => {onVoiceText()}); initSpeechState().then(
(value) =>
{onVoiceText()});
}, },
), ),
), ),
], ],
), ),
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(
height: spaceBetweenTextFileds),
Container( Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), margin: EdgeInsets.all(
SizeConfig.widthMultiplier * 5),
child: Wrap( child: Wrap(
alignment: WrapAlignment.center, alignment: WrapAlignment.center,
children: <Widget>[ children: <Widget>[
AppButton( AppButton(
color: Color(0xff359846), color: Color(0xff359846),
title: TranslationBase.of(context).addMedication, title: TranslationBase.of(
context)
.addMedication,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
onPressed: () async { onPressed: () async {
await locator<AnalyticsService>().logEvent( await locator<
eventCategory: "Add Prescription Form", AnalyticsService>()
eventAction: "Add Prescription", .logEvent(
eventCategory:
"Add Prescription Form",
eventAction:
"Add Prescription",
); );
if (duration != null && if (duration != null &&
doseTime != null && doseTime != null &&
frequency != null && frequency != null &&
selectedDate != null && selectedDate != null &&
strengthController.text != "") { strengthController
if (_selectedMedication.isNarcotic == true) { .text !=
DrAppToastMsg.showErrorToast(TranslationBase.of(context) "") {
.narcoticMedicineCanOnlyBePrescribedFromVida); if (_selectedMedication
.isNarcotic ==
true) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(
context)
.narcoticMedicineCanOnlyBePrescribedFromVida);
Navigator.pop(context); Navigator.pop(context);
return; return;
} }
if (double.parse(strengthController.text) > 1000.0) { if (double.parse(
DrAppToastMsg.showErrorToast( strengthController
"1000 is the MAX for the strength"); .text) >
1000.0) {
DrAppToastMsg
.showErrorToast(
"1000 is the MAX for the strength");
return; return;
} }
if (double.parse(strengthController.text) < 0.0) { if (double.parse(
DrAppToastMsg.showErrorToast("strength can't be zero"); strengthController
.text) <
0.0) {
DrAppToastMsg
.showErrorToast(
"strength can't be zero");
return; return;
} }
if (formKey.currentState.validate()) { if (formKey.currentState
.validate()) {
Navigator.pop(context); Navigator.pop(context);
openDrugToDrug(model); openDrugToDrug(model);
{ {
@ -759,32 +922,52 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
} else { } else {
setState(() { setState(() {
if (duration == null) { if (duration == null) {
durationError = TranslationBase.of(context).fieldRequired; durationError =
TranslationBase.of(
context)
.fieldRequired;
} else { } else {
durationError = null; durationError = null;
} }
if (doseTime == null) { if (doseTime == null) {
doseTimeError = TranslationBase.of(context).fieldRequired; doseTimeError =
TranslationBase.of(
context)
.fieldRequired;
} else { } else {
doseTimeError = null; doseTimeError = null;
} }
if (route == null) { if (route == null) {
routeError = TranslationBase.of(context).fieldRequired; routeError =
TranslationBase.of(
context)
.fieldRequired;
} else { } else {
routeError = null; routeError = null;
} }
if (frequency == null) { if (frequency == null) {
frequencyError = TranslationBase.of(context).fieldRequired; frequencyError =
TranslationBase.of(
context)
.fieldRequired;
} else { } else {
frequencyError = null; frequencyError = null;
} }
if (units == null) { if (units == null) {
unitError = TranslationBase.of(context).fieldRequired; unitError =
TranslationBase.of(
context)
.fieldRequired;
} else { } else {
unitError = null; unitError = null;
} }
if (strengthController.text == "") { if (strengthController
strengthError = TranslationBase.of(context).fieldRequired; .text ==
"") {
strengthError =
TranslationBase.of(
context)
.fieldRequired;
} else { } else {
strengthError = null; strengthError = null;
} }
@ -834,7 +1017,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
} }
} }
InputDecoration textFieldSelectorDecoration(String hintText, String selectedText, bool isDropDown, InputDecoration textFieldSelectorDecoration(
String hintText, String selectedText, bool isDropDown,
{Icon suffixIcon}) { {Icon suffixIcon}) {
return InputDecoration( return InputDecoration(
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
@ -885,7 +1069,9 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
child: Column( child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceBetween, // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
DrugToDrug(widget.patient, getPriscriptionforDrug(widget.prescriptionList, model), DrugToDrug(
widget.patient,
getPriscriptionforDrug(widget.prescriptionList, model),
model.patientAssessmentList), model.patientAssessmentList),
Container( Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3),
@ -896,23 +1082,28 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
postPrescription( postPrescription(
icdCode: model.patientAssessmentList.isNotEmpty icdCode: model.patientAssessmentList.isNotEmpty
? model.patientAssessmentList[0].icdCode10ID.isEmpty ? model.patientAssessmentList[0].icdCode10ID
.isEmpty
? "test" ? "test"
: model.patientAssessmentList[0].icdCode10ID.toString() : model.patientAssessmentList[0].icdCode10ID
.toString()
: "test", : "test",
dose: strengthController.text, dose: strengthController.text,
doseUnit: model.itemMedicineListUnit.length == 1 doseUnit: model.itemMedicineListUnit.length == 1
? model.itemMedicineListUnit[0]['parameterCode'].toString() ? model.itemMedicineListUnit[0]['parameterCode']
.toString()
: units['parameterCode'].toString(), : units['parameterCode'].toString(),
patient: widget.patient, patient: widget.patient,
doseTimeIn: doseTime['id'].toString(), doseTimeIn: doseTime['id'].toString(),
model: widget.model, model: widget.model,
duration: duration['id'].toString(), duration: duration['id'].toString(),
frequency: model.itemMedicineList.length == 1 frequency: model.itemMedicineList.length == 1
? model.itemMedicineList[0]['parameterCode'].toString() ? model.itemMedicineList[0]['parameterCode']
.toString()
: frequency['parameterCode'].toString(), : frequency['parameterCode'].toString(),
route: model.itemMedicineListRoute.length == 1 route: model.itemMedicineListRoute.length == 1
? model.itemMedicineListRoute[0]['parameterCode'].toString() ? model.itemMedicineListRoute[0]['parameterCode']
.toString()
: route['parameterCode'].toString(), : route['parameterCode'].toString(),
drugId: _selectedMedication.itemId.toString(), drugId: _selectedMedication.itemId.toString(),
strength: strengthController.text, strength: strengthController.text,
@ -931,7 +1122,8 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
}); });
} }
getPriscriptionforDrug(List<PrescriptionModel> prescriptionList, MedicineViewModel model) { getPriscriptionforDrug(
List<PrescriptionModel> prescriptionList, MedicineViewModel model) {
var prescriptionDetails = []; var prescriptionDetails = [];
if (prescriptionList.length > 0) { if (prescriptionList.length > 0) {
prescriptionList[0].entityList.forEach((element) { prescriptionList[0].entityList.forEach((element) {

@ -664,7 +664,7 @@ packages:
name: js name: js
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.2" version: "0.6.3-nullsafety.1"
json_annotation: json_annotation:
dependency: transitive dependency: transitive
description: description:
@ -706,7 +706,7 @@ packages:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0-nullsafety.4"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -1040,7 +1040,7 @@ packages:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0-nullsafety.1" version: "1.10.0-nullsafety.2"
sticky_headers: sticky_headers:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1245,5 +1245,5 @@ packages:
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
sdks: sdks:
dart: ">=2.10.2 <2.11.0" dart: ">=2.10.2 <=2.11.0-213.1.beta"
flutter: ">=1.22.2 <2.0.0" flutter: ">=1.22.2 <2.0.0"

Loading…
Cancel
Save