Merge branch 'allergyies' into 'development'

add medication almost done

See merge request Cloud_Solution/doctor_app_flutter!466
merge-requests/467/merge
Mohammad Aljammal 5 years ago
commit 6f11c365d3

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -1,5 +1,4 @@
import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:autocomplete_textfield/autocomplete_textfield.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart';
import 'package:doctor_app_flutter/core/model/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/model/get_medication_response_model.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
@ -10,12 +9,14 @@ 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/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart';
import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart';
import 'package:doctor_app_flutter/widgets/shared/app-textfield-custom.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_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_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart'; import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -120,17 +121,20 @@ class _AddMedicationState extends State<AddMedication> {
String hintText, String selectedText, bool isDropDown, String hintText, String selectedText, bool isDropDown,
{IconData icon}) { {IconData icon}) {
return InputDecoration( return InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey, width: 1.0), borderSide: BorderSide(color: Colors.grey, width: 0.00),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey, width: 1.0), borderSide: BorderSide(color: Colors.grey, width: 0.00),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
disabledBorder: OutlineInputBorder( disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey, width: 1.0), borderSide: BorderSide(color: Colors.grey, width: 0.00),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
hintText: selectedText != null ? selectedText : hintText, hintText: selectedText != null ? selectedText : hintText,
@ -152,7 +156,6 @@ class _AddMedicationState extends State<AddMedication> {
.of(context) .of(context)
.size; .size;
return FractionallySizedBox( return FractionallySizedBox(
heightFactor: 0.7,
child: BaseView<SOAPViewModel>( child: BaseView<SOAPViewModel>(
onModelReady: (model) async { onModelReady: (model) async {
if (model.medicationStrengthList.length == 0) { if (model.medicationStrengthList.length == 0) {
@ -172,388 +175,402 @@ class _AddMedicationState extends State<AddMedication> {
}, },
builder: (_, model, w) => builder: (_, model, w) =>
AppScaffold( AppScaffold(
baseViewModel: model, baseViewModel: model,
isShowAppBar: false, isShowAppBar: false,
body: SingleChildScrollView( body: Center(
child: Center( child: Container(
child: FractionallySizedBox( child: Column(
widthFactor: 0.9, crossAxisAlignment: CrossAxisAlignment.start,
child: Column( children: [
crossAxisAlignment: CrossAxisAlignment.start, Container(
padding:
EdgeInsets.only(left: 0, right: 5, bottom: 5, top: 5),
decoration: BoxDecoration(
color: Colors.white,
),
height: 115,
child: Container(
padding: EdgeInsets.only(left: 10, right: 10),
margin: EdgeInsets.only(top: 40),
child: Column(
children: [ children: [
Row(
SizedBox( mainAxisAlignment: MainAxisAlignment.spaceBetween,
height: 16, children: [
), RichText(
AppText( text: TextSpan(
TranslationBase style: TextStyle(
.of(context) fontSize: 20, color: Colors.black),
.addMedication, children: <TextSpan>[
fontWeight: FontWeight.bold, new TextSpan(
fontSize: 16, text: TranslationBase.of(context)
), .addMedication,
SizedBox( style: TextStyle(
height: 16, color: Color(0xFF2B353E),
), fontWeight: FontWeight.bold,
Container( fontFamily: 'Poppins',
height: screenSize.height * 0.070, fontSize: 20)),
child: InkWell( ],
onTap: model.allMedicationList != null ),
? () {
setState(() {
_selectedMedication = null;
});
}
: null,
child: _selectedMedication == null
? AutoCompleteTextField<
GetMedicationResponseModel>(
decoration: textFieldSelectorDecoration(
TranslationBase
.of(context)
.searchMedicineNameHere,
_selectedMedication != null
? _selectedMedication.genericName
: null,
true,
icon: EvaIcons.search),
itemSubmitted: (item) =>
setState(
() => _selectedMedication = item),
key: key,
suggestions: model.allMedicationList,
itemBuilder: (context, suggestion) =>
new Padding(
child: Texts(
suggestion.description + '/' +
suggestion.genericName),
padding: EdgeInsets.all(8.0)),
itemSorter: (a, b) => 1,
itemFilter: (suggestion, input) =>
suggestion.genericName
.toLowerCase()
.startsWith(input.toLowerCase()) ||
suggestion.description
.toLowerCase()
.startsWith(input.toLowerCase()) ||
suggestion.keywords
.toLowerCase()
.startsWith(input.toLowerCase()),
)
: TextField(
minLines: 2,
maxLines: 2,
decoration: textFieldSelectorDecoration(
TranslationBase
.of(context)
.searchMedicineNameHere,
_selectedMedication != null
? _selectedMedication.description +
(' (${_selectedMedication
.genericName} )')
: null,
true,
icon: EvaIcons.search),
enabled: false,
), ),
), InkWell(
), onTap: () {
if(isFormSubmitted && _selectedMedication == null) Navigator.pop(context);
CustomValidationError(),
SizedBox(
height: 5,
),
TextFields(
onTapTextFields: model.medicationDoseTimeList !=
null
? () {
MasterKeyDailog dialog = MasterKeyDailog(
list: model.medicationDoseTimeList,
okText: TranslationBase
.of(context)
.ok,
okFunction: (selectedValue) {
setState(() {
_selectedMedicationDose =
selectedValue;
doseController.text =
projectViewModel.isArabic
? _selectedMedicationDose
.nameAr
: _selectedMedicationDose
.nameEn;
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
hasLabelText: doseController.text !=
'' ? true : false,
showLabelText: true,
hintText: TranslationBase
.of(context)
.doseTime,
//TODO add translation
fontSize: 13.5,
readOnly: true,
// hintColor: Colors.black,
fontWeight: FontWeight.w600,
maxLines: 2,
minLines: 1,
controller: doseController,
validator: (value) {
if (value == null)
return TranslationBase
.of(context)
.emptyMessage;
else
return null;
}),
SizedBox(
height: 5,
),
if(isFormSubmitted &&
_selectedMedicationDose == null)
CustomValidationError(), SizedBox(
height: 5,
),
TextFields(
onTapTextFields: model
.medicationStrengthList != null
? () {
MasterKeyDailog dialog = MasterKeyDailog(
list: model.medicationStrengthList,
okText: TranslationBase
.of(context)
.ok,
okFunction: (selectedValue) {
setState(() {
_selectedMedicationStrength =
selectedValue;
strengthController.text =
projectViewModel.isArabic
? _selectedMedicationStrength
.nameAr
: _selectedMedicationStrength
.nameEn;
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
}, },
); child: Icon(FontAwesomeIcons.times,
} size: 30, color: Color(0xFF2B353E)))
: null, ],
hasLabelText: strengthController.text !=
'' ? true : false,
showLabelText: true,
hintText: TranslationBase
.of(context)
.strength,
fontSize: 13.5,
readOnly: true,
// hintColor: Colors.black,
fontWeight: FontWeight.w600,
maxLines: 2,
minLines: 1,
controller: strengthController,
validator: (value) {
if (value == null)
return TranslationBase
.of(context)
.emptyMessage;
else
return null;
}), SizedBox(
height: 5,
), ),
if(isFormSubmitted && ],
_selectedMedicationStrength == null) ),
CustomValidationError(), ),
),
SizedBox(
height: 10,
),
SizedBox(
height: 16,
),
Expanded(
child: Center(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
children: [
SizedBox(
height: 16,
),
SizedBox(
height: 16,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: model.allMedicationList != null
? () {
setState(() {
_selectedMedication = null;
});
}
: null,
child: _selectedMedication == null
? AutoCompleteTextField<
GetMedicationResponseModel>(
decoration:
textFieldSelectorDecoration(
SizedBox( TranslationBase.of(context)
height: 5, .searchMedicineNameHere,
), _selectedMedication != null
? _selectedMedication
.genericName
: null,
true,
icon: EvaIcons.search),
itemSubmitted: (item) => setState(
() =>
_selectedMedication = item),
key: key,
suggestions:
model.allMedicationList,
itemBuilder: (context,
suggestion) =>
new Padding(
child: Texts(suggestion
.description +
'/' +
suggestion.genericName),
padding:
EdgeInsets.all(8.0)),
itemSorter: (a, b) => 1,
itemFilter: (suggestion, input) =>
suggestion.genericName
.toLowerCase()
.startsWith(
input.toLowerCase()) ||
suggestion.description
.toLowerCase()
.startsWith(
input.toLowerCase()) ||
suggestion.keywords
.toLowerCase()
.startsWith(
input.toLowerCase()),
)
: AppTextFieldCustom(
hintText: _selectedMedication != null
? _selectedMedication
.description +
(' (${_selectedMedication.genericName} )')
: TranslationBase.of(context)
.searchMedicineNameHere,
minLines: 2,
maxLines: 2,
enabled: false,
),
),
),
if (isFormSubmitted &&
_selectedMedication == null)
CustomValidationError(),
SizedBox(
height: 5,
),
AppTextFieldCustom(
enabled: false,
onClick: model.medicationDoseTimeList != null
? () {
MasterKeyDailog dialog =
MasterKeyDailog(
list: model.medicationDoseTimeList,
okText:
TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_selectedMedicationDose =
selectedValue;
TextFields( doseController
onTapTextFields: model .text = projectViewModel
.medicationRouteList != null .isArabic
? () { ? _selectedMedicationDose
MasterKeyDailog dialog = MasterKeyDailog( .nameAr
list: model.medicationRouteList, : _selectedMedicationDose
okText: TranslationBase .nameEn;
.of(context) });
.ok, },
okFunction: (selectedValue) { );
setState(() { showDialog(
_selectedMedicationRoute = barrierDismissible: false,
selectedValue; context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
hintText:
TranslationBase.of(context).doseTime,
//TODO add translation
maxLines: 2,
minLines: 2,
isDropDown: true,
controller: doseController,
),
SizedBox(
height: 5,
),
if (isFormSubmitted &&
_selectedMedicationDose == null)
CustomValidationError(),
SizedBox(
height: 5,
),
AppTextFieldCustom(
enabled: false,
isDropDown: true,
onClick: model.medicationStrengthList != null
? () {
MasterKeyDailog dialog =
MasterKeyDailog(
list: model.medicationStrengthList,
okText:
TranslationBase.of(context).ok,
okFunction: (selectedValue) {
setState(() {
_selectedMedicationStrength =
selectedValue;
routeController.text = strengthController
projectViewModel.isArabic .text = projectViewModel
? _selectedMedicationRoute .isArabic
.nameAr ? _selectedMedicationStrength
: _selectedMedicationRoute .nameAr
.nameEn; : _selectedMedicationStrength
}); .nameEn;
}, });
); },
showDialog( );
barrierDismissible: false, showDialog(
context: context, barrierDismissible: false,
builder: (BuildContext context) { context: context,
return dialog; builder: (BuildContext context) {
}, return dialog;
); },
} );
: null, }
hasLabelText: routeController.text != : null,
'' ? true : false, hintText:
showLabelText: true, TranslationBase.of(context).strength,
hintText: TranslationBase // hintColor: Colors.black,
.of(context) // fontWeight: FontWeight.w600,
.route, maxLines: 2,
fontSize: 13.5, minLines: 2,
readOnly: true, controller: strengthController,
// hintColor: Colors.black, ),
fontWeight: FontWeight.w600, SizedBox(
maxLines: 2, height: 5,
minLines: 1, ),
controller: routeController, if (isFormSubmitted &&
validator: (value) { _selectedMedicationStrength == null)
if (value == null) CustomValidationError(),
return TranslationBase SizedBox(
.of(context) height: 5,
.emptyMessage; ),
else AppTextFieldCustom(
return null; enabled: false,
}), isDropDown: true,
SizedBox( onClick: model.medicationRouteList != null
height: 5, ? () {
), MasterKeyDailog dialog =
if(isFormSubmitted && MasterKeyDailog(
_selectedMedicationRoute == null) list: model.medicationRouteList,
CustomValidationError(), okText:
SizedBox( TranslationBase.of(context).ok,
height: 5, okFunction: (selectedValue) {
), setState(() {
TextFields( _selectedMedicationRoute =
onTapTextFields: model selectedValue;
.medicationFrequencyList != null
? () {
MasterKeyDailog dialog = MasterKeyDailog(
list: model.medicationFrequencyList,
okText: TranslationBase
.of(context)
.ok,
okFunction: (selectedValue) {
setState(() {
_selectedMedicationFrequency =
selectedValue;
frequencyController.text = routeController
projectViewModel.isArabic .text = projectViewModel
? _selectedMedicationFrequency .isArabic
.nameAr ? _selectedMedicationRoute
: _selectedMedicationFrequency .nameAr
.nameEn; : _selectedMedicationRoute
}); .nameEn;
}, });
); },
showDialog( );
barrierDismissible: false, showDialog(
context: context, barrierDismissible: false,
builder: (BuildContext context) { context: context,
return dialog; builder: (BuildContext context) {
}, return dialog;
); },
} );
: null, }
hasLabelText: frequencyController.text != : null,
'' ? true : false, hintText: TranslationBase.of(context).route,
showLabelText: true, maxLines: 2,
hintText: TranslationBase minLines: 2,
.of(context) controller: routeController,
.frequency, ),
//TODO add translation SizedBox(
fontSize: 13.5, height: 5,
readOnly: true, ),
// hintColor: Colors.black, if (isFormSubmitted &&
fontWeight: FontWeight.w600, _selectedMedicationRoute == null)
maxLines: 2, CustomValidationError(),
minLines: 1, SizedBox(
controller: frequencyController, height: 5,
validator: (value) { ),
if (value == null) AppTextFieldCustom(
return TranslationBase onClick: model.medicationFrequencyList != null
.of(context) ? () {
.emptyMessage; MasterKeyDailog dialog =
else MasterKeyDailog(
return null; list: model.medicationFrequencyList,
}), okText:
SizedBox( TranslationBase.of(context).ok,
height: 5, okFunction: (selectedValue) {
), setState(() {
if(isFormSubmitted && _selectedMedicationFrequency =
_selectedMedicationFrequency == null) selectedValue;
CustomValidationError(),
SizedBox(
height: 30,
),
AppButton(
title: TranslationBase
.of(context)
.add
.toUpperCase(),
onPressed: () {
setState(() {
isFormSubmitted = true;
});
if (_selectedMedication != null &&
_selectedMedicationDose !=
null &&
_selectedMedicationStrength != null &&
_selectedMedicationRoute != null &&
_selectedMedicationFrequency != null) {
widget.medicationController.text =
widget.medicationController.text +
'${_selectedMedication
.description } (${TranslationBase
.of(context)
.doseTime} ) ${doseController
.text} (${TranslationBase
.of(context)
.strength}) ${strengthController
.text} (${TranslationBase
.of(context)
.route }) ${routeController
.text} (${TranslationBase
.of(context)
.frequency }) ${frequencyController
.text} \n \n';
Navigator.of(context).pop();
}
},
),
]
frequencyController
.text = projectViewModel
.isArabic
? _selectedMedicationFrequency
.nameAr
: _selectedMedicationFrequency
.nameEn;
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
: null,
hintText:
TranslationBase.of(context).frequency,
//TODO add translation
enabled: false,
// hintColor: Colors.black,
maxLines: 2,
minLines: 2,
isDropDown: true,
controller: frequencyController,
),
SizedBox(
height: 5,
),
if (isFormSubmitted &&
_selectedMedicationFrequency == null)
CustomValidationError(),
SizedBox(
height: 30,
),
],
)),
),
),
]),
),
),
bottomSheet: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
border: Border.all(color: HexColor('#707070'), width: 0.30),
),
height: MediaQuery.of(context).size.height * 0.1,
width: double.infinity,
child: Column(
children: [
SizedBox(
height: 10,
),
Container(
child: FractionallySizedBox(
widthFactor: .80,
child: Center(
child: AppButton(
title: TranslationBase.of(context).addMedication.toUpperCase(),
color: Color(0xFF359846),
onPressed: () {
setState(() {
isFormSubmitted = true;
});
if (_selectedMedication != null &&
_selectedMedicationDose != null &&
_selectedMedicationStrength != null &&
_selectedMedicationRoute != null &&
_selectedMedicationFrequency != null) {
widget.medicationController.text = widget
.medicationController.text +
'${_selectedMedication.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n';
Navigator.of(context).pop();
}
},
), ),
), ),
), ),
),), ),
SizedBox(
height: 5,
),
],
),
),
),
), ),
); );
} }

@ -640,7 +640,8 @@ class _AddAssessmentDetailsState extends State<AddAssessmentDetails> {
{IconData icon}) { {IconData icon}) {
return InputDecoration( return InputDecoration(
fillColor: Colors.white, fillColor: Colors.white,
contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
contentPadding: EdgeInsets.symmetric(vertical: 15, horizontal: 10),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0Xffffffff), width: 1.0), borderSide: BorderSide(color: Color(0Xffffffff), width: 1.0),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
@ -763,6 +764,7 @@ class _AddAssessmentDetailsState extends State<AddAssessmentDetails> {
.mySelectedAssessment.selectedICD == .mySelectedAssessment.selectedICD ==
null null
? AutoCompleteTextField<MasterKeyModel>( ? AutoCompleteTextField<MasterKeyModel>(
decoration: textFieldSelectorDecoration( decoration: textFieldSelectorDecoration(
TranslationBase.of(context) TranslationBase.of(context)
.nameOrICD, .nameOrICD,

Loading…
Cancel
Save