From f819e6353e4a938409036011964f71442bcc593a Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 22 Feb 2021 11:39:44 +0200 Subject: [PATCH 1/4] fix DA-350 --- lib/client/base_app_client.dart | 2 + lib/core/service/base/lookup-service.dart | 10 + lib/core/viewModel/SOAP_view_model.dart | 19 + .../subjective/update_medication_widget.dart | 633 ++++++++++++++++-- .../subjective/update_subjective_page.dart | 2 + 5 files changed, 613 insertions(+), 53 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 604e6f30..4a6ee675 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -83,6 +83,8 @@ class BaseAppClient { print("URL : $url"); print("Body : ${json.encode(body)}"); + var ee ={json.encode(body)}; + if (await Helpers.checkConnection()) { final response = await http.post(url, body: json.encode(body), diff --git a/lib/core/service/base/lookup-service.dart b/lib/core/service/base/lookup-service.dart index 998949d7..dd6310e8 100644 --- a/lib/core/service/base/lookup-service.dart +++ b/lib/core/service/base/lookup-service.dart @@ -18,6 +18,12 @@ class LookupService extends BaseService { List medicationFrequencyList = []; List medicationDoseTimeList = []; List medicationIndicationsList = []; + // TODO make the person who create the list dynamic to change it. + List medicationStrengthListWithModel = []; + List medicationFrequencyListWithModel = []; + List medicationDoseTimeListWithModel = []; + List medicationRouteListWithModel = []; + List patientAssessmentList = []; List get historyFamilyList => _historyFamilyList; @@ -154,6 +160,7 @@ class LookupService extends BaseService { case MasterKeysService.MedicationStrength: medicationStrengthList.clear(); entryList.forEach((v) { + medicationStrengthListWithModel.add(MasterKeyModel.fromJson(v)); medicationStrengthList.add(v); }); break; @@ -166,18 +173,21 @@ class LookupService extends BaseService { case MasterKeysService.MedicationRoute: medicationRouteList.clear(); entryList.forEach((v) { + medicationRouteListWithModel.add(MasterKeyModel.fromJson(v)); medicationRouteList.add(v); }); break; case MasterKeysService.MedicationFrequency: medicationFrequencyList.clear(); entryList.forEach((v) { + medicationFrequencyListWithModel.add(MasterKeyModel.fromJson(v)); medicationFrequencyList.add(v); }); break; case MasterKeysService.MedicationDoseTime: medicationDoseTimeList.clear(); entryList.forEach((v) { + medicationDoseTimeListWithModel.add(MasterKeyModel.fromJson(v)); medicationDoseTimeList.add(v); }); break; diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 076f379c..600a83a5 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -1,6 +1,8 @@ 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/model/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/service/SOAP_service.dart'; +import 'package:doctor_app_flutter/core/service/prescription_service.dart'; import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; @@ -30,6 +32,7 @@ import 'base_view_model.dart'; class SOAPViewModel extends BaseViewModel { SOAPService _SOAPService = locator(); + PrescriptionService _prescriptionService = locator(); List get allergiesList => _SOAPService.allergiesList; @@ -82,6 +85,13 @@ class SOAPViewModel extends BaseViewModel { int get episodeID => _SOAPService.episodeID; + get medicationStrengthList => _SOAPService.medicationStrengthListWithModel; + get medicationDoseTimeList => _SOAPService.medicationDoseTimeListWithModel; + get medicationRouteList => _SOAPService.medicationRouteListWithModel; + get medicationFrequencyList => _SOAPService.medicationFrequencyListWithModel; + List get allMedicationList => + _prescriptionService.allMedicationList; + Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { setState(ViewState.Busy); await _SOAPService.getAllergies(getAllergiesRequestModel); @@ -320,6 +330,15 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future getMedicationList() async { + setState(ViewState.Busy); + await _prescriptionService.getMedicationList(); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } // ignore: missing_return MasterKeyModel getOneMasterKey( {@required MasterKeysService masterKeys, dynamic id, int typeId}) { diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart index 6584d415..81f49ffa 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart @@ -1,30 +1,49 @@ - +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/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.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/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.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/master_key_dailog.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../custom_validation_error.dart'; + +class UpdateMedicationWidget extends StatefulWidget { + final List myAllergiesList; + + UpdateMedicationWidget({Key key, this.myAllergiesList}); -class UpdateMedication extends StatefulWidget { @override - _UpdateMedicationState createState() => _UpdateMedicationState(); + _UpdateMedicationWidgetState createState() => _UpdateMedicationWidgetState(); } -class _UpdateMedicationState extends State { +class _UpdateMedicationWidgetState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Column( children: [ Container( - margin: - EdgeInsets.only(left: 10, right: 10, top: 15), + margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: TextFields( - hintText: "Current Medications", + hintText: TranslationBase.of(context).addMedication, fontSize: 13.5, onTapTextFields: () { - openMedicationsList(context); + openAllergiesList(context); }, readOnly: true, // hintColor: Colors.black, @@ -34,7 +53,8 @@ class _UpdateMedicationState extends State { // controller: messageController, validator: (value) { if (value == null) - return TranslationBase.of(context) + return TranslationBase + .of(context) .emptyMessage; else return null; @@ -47,61 +67,568 @@ class _UpdateMedicationState extends State { margin: EdgeInsets.only(left: 15, right: 15, top: 15), child: Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts('Abdomen Pain', - variant: "bodyText", - bold: true, - color: Colors.black), - Icon( - FontAwesomeIcons.trash, - color: Colors.grey, - size: 20, - ) - ], - ), - SizedBox( - height: 20, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts('Back Pain', - variant: "bodyText", - bold: true, - color: Colors.black), - Icon( - FontAwesomeIcons.trash, - color: Colors.grey, - size: 20, - ) - ], - ), - ], - ), + children: widget.myAllergiesList.map((selectedAllergy) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Texts( + projectViewModel.isArabic + ? selectedAllergy.selectedAllergy.nameAr + : selectedAllergy.selectedAllergy.nameEn + .toUpperCase(), + variant: "bodyText", + textDecoration: selectedAllergy.isChecked + ? null + : TextDecoration.lineThrough, + bold: true, + color: Colors.black), + width: MediaQuery + .of(context) + .size + .width * 0.5, + ), + Texts( + projectViewModel.isArabic + ? selectedAllergy.selectedAllergySeverity + .nameAr + : selectedAllergy.selectedAllergySeverity + .nameEn + .toUpperCase(), + variant: "bodyText", + textDecoration: selectedAllergy.isChecked + ? null + : TextDecoration.lineThrough, + bold: true, + color: AppGlobal.appPrimaryColor), + if (selectedAllergy.isChecked) + InkWell( + child: Icon( + FontAwesomeIcons.trash, + color: Colors.grey, + size: 20, + ), + onTap: () => removeAllergy(selectedAllergy), + ) + ], + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Row( + children: [ + AppText( + selectedAllergy.remark != null && + selectedAllergy.remark != '' + ? TranslationBase + .of(context) + .remarks + " : " + : '', + fontWeight: FontWeight.bold, + fontSize: 13, + ), + Container( + width: MediaQuery + .of(context) + .size + .width * 0.55, + child: AppText( + selectedAllergy.remark ?? '', + fontSize: 10, + color: Colors.grey, + ), + ), + ], + ), + ), + DividerWithSpacesAround() + ], + ), + SizedBox( + height: 10, + ), + ], + ); + }).toList()), ) ], ); } - openMedicationsList(BuildContext context) { + + removeAllergy(MySelectedAllergy mySelectedAllergy) { + List allergy = + // ignore: missing_return + widget.myAllergiesList.where((element) => + mySelectedAllergy.selectedAllergySeverity.id == + element.selectedAllergySeverity.id && + mySelectedAllergy.selectedAllergy.id == element.selectedAllergy.id + ).toList(); + + if (allergy.length > 0) { + setState(() { + allergy[0].isChecked = false; + }); + } + + + print(allergy); + } + + openAllergiesList(BuildContext context) { showModalBottomSheet( backgroundColor: Colors.white, isScrollControlled: true, context: context, builder: (context) { - return FractionallySizedBox( - heightFactor: 0.7, - child: Container( - child: Center( - child: Texts("dfdfd"), - )), - ); + return AddAllergies( + addAllergiesFun: (MySelectedAllergy mySelectedAllergy) { + if (mySelectedAllergy.selectedAllergySeverity == null || + mySelectedAllergy.selectedAllergy == null) { + helpers.showErrorToast(TranslationBase + .of(context) + .requiredMsg); + } else { + setState(() { + List allergy = + // ignore: missing_return + widget.myAllergiesList + .where((element) => + mySelectedAllergy.selectedAllergy.id == + element.selectedAllergy.id) + .toList(); + + if (allergy.isEmpty) { + widget.myAllergiesList.add(mySelectedAllergy); + Navigator.of(context).pop(); + } else { + allergy.first.selectedAllergy = + mySelectedAllergy.selectedAllergy; + allergy.first.selectedAllergySeverity = + mySelectedAllergy.selectedAllergySeverity; + allergy.first.remark = mySelectedAllergy.remark; + allergy.first.isChecked = mySelectedAllergy.isChecked; + Navigator.of(context).pop(); + + // helpers.showErrorToast(TranslationBase + // .of(context) + // .itemExist); + } + }); + } + },); }); } } +class AddAllergies extends StatefulWidget { + final Function addAllergiesFun; + + const AddAllergies({Key key, this.addAllergiesFun}) : super(key: key); + + @override + _AddAllergiesState createState() => _AddAllergiesState(); +} + +class _AddAllergiesState extends State { + List allergiesList; + List allergySeverityList; + MasterKeyModel _selectedMedicationStrengthSeverity; + MasterKeyModel _selectedAllergy; + TextEditingController remarkController = TextEditingController(); + TextEditingController severityController = TextEditingController(); + TextEditingController allergyController = TextEditingController(); + + GlobalKey key = new GlobalKey>(); + bool isFormSubmitted = false; + + InputDecoration textFieldSelectorDecoration(String hintText, + String selectedText, bool isDropDown, + {IconData icon}) { + return InputDecoration( + contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown ? Icon(icon ?? Icons.arrow_drop_down) : null, + hintStyle: TextStyle( + fontSize: 10, + color: Theme + .of(context) + .hintColor, + fontWeight: FontWeight.w700 + ), + ); + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + final screenSize = MediaQuery + .of(context) + .size; + return FractionallySizedBox( + heightFactor: 0.7, + child: BaseView( + onModelReady: (model) async { + if (model.medicationStrengthList.length == 0) { + await model.getMasterLookup(MasterKeysService.MedicationStrength,); + } + if (model.medicationFrequencyList.length == 0) { + await model.getMasterLookup(MasterKeysService.MedicationFrequency); + } + if (model.medicationDoseTimeList.length == 0) { + await model.getMasterLookup(MasterKeysService.MedicationDoseTime); + } + if (model.medicationRouteList.length == 0) { + await model.getMasterLookup(MasterKeysService.MedicationRoute); + } + if (model.allMedicationList.length == 0) + await model.getMedicationList(); + }, + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + isShowAppBar: false, + body: SingleChildScrollView( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + + SizedBox( + height: 16, + ), + AppText( + TranslationBase + .of(context) + .addAllergies, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + SizedBox( + height: 16, + ), + Container( + height: screenSize.height * 0.070, + child: InkWell( + onTap: model.allergiesList != null + ? () { + setState(() { + _selectedAllergy = null; + allergyController.text = null; + }); + } + : null, + child: _selectedAllergy == null + ? AutoCompleteTextField( + decoration: textFieldSelectorDecoration( + TranslationBase + .of(context) + .selectAllergy, + _selectedAllergy != null + ? _selectedAllergy.nameEn + : null, true, + icon: EvaIcons.search), + itemSubmitted: (item) => + setState(() { + _selectedAllergy = item; + allergyController.text = + projectViewModel.isArabic + ? _selectedAllergy + .nameAr + : _selectedAllergy + .nameEn; + }), + key: key, + suggestions: model.allergiesList, + itemBuilder: (context, suggestion) => + new Padding( + child: Texts( + projectViewModel.isArabic + ? suggestion + .nameAr + : suggestion.nameEn), + padding: EdgeInsets.all(2.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.nameAr.toLowerCase().startsWith( + input.toLowerCase()) || + suggestion.nameEn.toLowerCase() + .startsWith(input.toLowerCase()), + ) + : + TextFields( + onTapTextFields: model.allergiesList != + null + ? () { + setState(() { + _selectedAllergy = null; + allergyController.text = null; + }); + } + : null, + hasLabelText: allergyController.text != + '' ? true : false, + showLabelText: true, + hintText: TranslationBase + .of(context) + .selectAllergy, + fontSize: 13.5, + readOnly: true, + fontWeight: FontWeight.w600, + maxLines: 2, + minLines: 1, + controller: allergyController, + suffixIcon: EvaIcons.search, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }) + ), + ), + if(isFormSubmitted && _selectedAllergy == null) + CustomValidationError(), + SizedBox( + height: 10, + ), + TextFields( + onTapTextFields: model + .medicationStrengthList != null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: model.medicationStrengthList, + okText: TranslationBase + .of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationStrengthSeverity = + selectedValue; + + severityController.text = + projectViewModel.isArabic + ? _selectedMedicationStrengthSeverity + .nameAr + : _selectedMedicationStrengthSeverity + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hasLabelText: severityController.text != + '' ? true : false, + showLabelText: true, + hintText: "Strength", + //TODO add translation + fontSize: 13.5, + readOnly: true, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 2, + minLines: 1, + controller: severityController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + SizedBox( + height: 5, + ), + if(isFormSubmitted && + _selectedMedicationStrengthSeverity == null) + CustomValidationError(), TextFields( + onTapTextFields: model.medicationDoseTimeList != + null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: model.medicationDoseTimeList, + okText: TranslationBase + .of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationStrengthSeverity = + selectedValue; + + severityController.text = + projectViewModel.isArabic + ? _selectedMedicationStrengthSeverity + .nameAr + : _selectedMedicationStrengthSeverity + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hasLabelText: severityController.text != + '' ? true : false, + showLabelText: true, + hintText: "Dose Time", + //TODO add translation + fontSize: 13.5, + readOnly: true, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 2, + minLines: 1, + controller: severityController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), SizedBox( + height: 5, + ), + if(isFormSubmitted && + _selectedMedicationStrengthSeverity == null) + CustomValidationError(), + + SizedBox( + height: 10, + ), + + SizedBox( + height: 10, + ), + TextFields( + onTapTextFields: model + .medicationStrengthList != null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: model.medicationStrengthList, + okText: TranslationBase + .of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationStrengthSeverity = + selectedValue; + + severityController.text = + projectViewModel.isArabic + ? _selectedMedicationStrengthSeverity + .nameAr + : _selectedMedicationStrengthSeverity + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hasLabelText: severityController.text != + '' ? true : false, + showLabelText: true, + hintText: "Strength", + //TODO add translation + fontSize: 13.5, + readOnly: true, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 2, + minLines: 1, + controller: severityController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), + SizedBox( + height: 5, + ), + if(isFormSubmitted && + _selectedMedicationStrengthSeverity == null) + CustomValidationError(), + AppButton( + title: TranslationBase + .of(context) + .add + .toUpperCase(), + onPressed: () { + setState(() { + isFormSubmitted = true; + }); + if (_selectedAllergy != null && + _selectedMedicationStrengthSeverity != + null) { + MySelectedAllergy mySelectedAllergy = new MySelectedAllergy( + remark: remarkController.text, + selectedAllergy: _selectedAllergy, + isChecked: true, + selectedAllergySeverity: _selectedMedicationStrengthSeverity,); + widget.addAllergiesFun(mySelectedAllergy); + } + }, + ), + ] + + ), + ), + ), + )), + ), + ); + } +} + + + + + + diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart index 95c4063e..fb7b4dc6 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -19,6 +19,7 @@ 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/profile/soap_update/subjective/update_allergies_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_history_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_medication_widget.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/app_buttons_widget.dart'; @@ -353,6 +354,7 @@ class _UpdateSubjectivePageState extends State { SizedBox( height: 10, ), + UpdateMedicationWidget(myAllergiesList: widget.myAllergiesList,), SizedBox( height: 10, ), From f3220be735e5953370a891636ed8775e684d8288 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 22 Feb 2021 17:41:18 +0200 Subject: [PATCH 2/4] fix DA-350 --- ios/Podfile.lock | 2 +- lib/screens/dashboard_screen.dart | 1 + lib/util/translations_delegate_base.dart | 1 + .../subjective/update_medication_widget.dart | 519 ++++++++---------- .../subjective/update_subjective_page.dart | 13 +- 5 files changed, 234 insertions(+), 302 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 46d7599e..9c86879d 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -292,4 +292,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 649616dc336b3659ac6b2b25159d8e488e042b69 -COCOAPODS: 1.10.1 +COCOAPODS: 1.10.0.rc.1 diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 30dc2700..9f28c010 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -136,6 +136,7 @@ class _DashboardScreenState extends State { Stack(children: [ Column( children: [ + if(false) ProfileWelcomeWidget( InkWell( onTap: () async { diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 499cade9..09a3c3be 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1106,6 +1106,7 @@ class TranslationBase { String get admissionRequestSuccessMsg => localizedValues['admissionRequestSuccessMsg'][locale.languageCode]; String get infoStatus => localizedValues['infoStatus'][locale.languageCode]; String get doctorResponse => localizedValues['doctorResponse'][locale.languageCode]; + } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart index 81f49ffa..f32bfe6e 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_medication_widget.dart @@ -1,6 +1,7 @@ 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/model/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; @@ -13,18 +14,19 @@ 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/master_key_dailog.dart'; -import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import '../custom_validation_error.dart'; class UpdateMedicationWidget extends StatefulWidget { - final List myAllergiesList; + final TextEditingController medicationController; - UpdateMedicationWidget({Key key, this.myAllergiesList}); + UpdateMedicationWidget({ + Key key, + this.medicationController, + }); @override _UpdateMedicationWidgetState createState() => _UpdateMedicationWidgetState(); @@ -43,7 +45,7 @@ class _UpdateMedicationWidgetState extends State { hintText: TranslationBase.of(context).addMedication, fontSize: 13.5, onTapTextFields: () { - openAllergiesList(context); + openMedicationList(context); }, readOnly: true, // hintColor: Colors.black, @@ -62,195 +64,57 @@ class _UpdateMedicationWidgetState extends State { ), SizedBox( height: 20, - ), - Container( - margin: - EdgeInsets.only(left: 15, right: 15, top: 15), - child: Column( - children: widget.myAllergiesList.map((selectedAllergy) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Texts( - projectViewModel.isArabic - ? selectedAllergy.selectedAllergy.nameAr - : selectedAllergy.selectedAllergy.nameEn - .toUpperCase(), - variant: "bodyText", - textDecoration: selectedAllergy.isChecked - ? null - : TextDecoration.lineThrough, - bold: true, - color: Colors.black), - width: MediaQuery - .of(context) - .size - .width * 0.5, - ), - Texts( - projectViewModel.isArabic - ? selectedAllergy.selectedAllergySeverity - .nameAr - : selectedAllergy.selectedAllergySeverity - .nameEn - .toUpperCase(), - variant: "bodyText", - textDecoration: selectedAllergy.isChecked - ? null - : TextDecoration.lineThrough, - bold: true, - color: AppGlobal.appPrimaryColor), - if (selectedAllergy.isChecked) - InkWell( - child: Icon( - FontAwesomeIcons.trash, - color: Colors.grey, - size: 20, - ), - onTap: () => removeAllergy(selectedAllergy), - ) - ], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Row( - children: [ - AppText( - selectedAllergy.remark != null && - selectedAllergy.remark != '' - ? TranslationBase - .of(context) - .remarks + " : " - : '', - fontWeight: FontWeight.bold, - fontSize: 13, - ), - Container( - width: MediaQuery - .of(context) - .size - .width * 0.55, - child: AppText( - selectedAllergy.remark ?? '', - fontSize: 10, - color: Colors.grey, - ), - ), - ], - ), - ), - DividerWithSpacesAround() - ], - ), - SizedBox( - height: 10, - ), - ], - ); - }).toList()), ) ], ); } - removeAllergy(MySelectedAllergy mySelectedAllergy) { - List allergy = - // ignore: missing_return - widget.myAllergiesList.where((element) => - mySelectedAllergy.selectedAllergySeverity.id == - element.selectedAllergySeverity.id && - mySelectedAllergy.selectedAllergy.id == element.selectedAllergy.id - ).toList(); - - if (allergy.length > 0) { - setState(() { - allergy[0].isChecked = false; - }); - } - - print(allergy); - } - - openAllergiesList(BuildContext context) { + openMedicationList(BuildContext context) { showModalBottomSheet( backgroundColor: Colors.white, isScrollControlled: true, context: context, builder: (context) { - return AddAllergies( - addAllergiesFun: (MySelectedAllergy mySelectedAllergy) { - if (mySelectedAllergy.selectedAllergySeverity == null || - mySelectedAllergy.selectedAllergy == null) { - helpers.showErrorToast(TranslationBase - .of(context) - .requiredMsg); - } else { - setState(() { - List allergy = - // ignore: missing_return - widget.myAllergiesList - .where((element) => - mySelectedAllergy.selectedAllergy.id == - element.selectedAllergy.id) - .toList(); - - if (allergy.isEmpty) { - widget.myAllergiesList.add(mySelectedAllergy); - Navigator.of(context).pop(); - } else { - allergy.first.selectedAllergy = - mySelectedAllergy.selectedAllergy; - allergy.first.selectedAllergySeverity = - mySelectedAllergy.selectedAllergySeverity; - allergy.first.remark = mySelectedAllergy.remark; - allergy.first.isChecked = mySelectedAllergy.isChecked; - Navigator.of(context).pop(); - - // helpers.showErrorToast(TranslationBase - // .of(context) - // .itemExist); - } - }); - } - },); + return AddMedication( + addMedicationFun: (MySelectedAllergy mySelectedAllergy) {}, + medicationController: widget.medicationController, + ); }); } - } -class AddAllergies extends StatefulWidget { - final Function addAllergiesFun; +// ignore: must_be_immutable +class AddMedication extends StatefulWidget { + final Function addMedicationFun; + TextEditingController medicationController; - const AddAllergies({Key key, this.addAllergiesFun}) : super(key: key); + AddMedication({Key key, this.addMedicationFun, this.medicationController}) + : super(key: key); @override - _AddAllergiesState createState() => _AddAllergiesState(); + _AddMedicationState createState() => _AddMedicationState(); } -class _AddAllergiesState extends State { - List allergiesList; - List allergySeverityList; - MasterKeyModel _selectedMedicationStrengthSeverity; - MasterKeyModel _selectedAllergy; - TextEditingController remarkController = TextEditingController(); - TextEditingController severityController = TextEditingController(); - TextEditingController allergyController = TextEditingController(); +class _AddMedicationState extends State { + MasterKeyModel _selectedMedicationDose; + MasterKeyModel _selectedMedicationStrength; + MasterKeyModel _selectedMedicationRoute; + MasterKeyModel _selectedMedicationFrequency; - GlobalKey key = new GlobalKey>(); + MasterKeyModel _selectedAllergy; + TextEditingController doseController = TextEditingController(); + TextEditingController strengthController = TextEditingController(); + TextEditingController routeController = TextEditingController(); + TextEditingController frequencyController = TextEditingController(); + GetMedicationResponseModel _selectedMedication; + + GlobalKey key = + new GlobalKey>(); bool isFormSubmitted = false; - InputDecoration textFieldSelectorDecoration(String hintText, - String selectedText, bool isDropDown, + InputDecoration textFieldSelectorDecoration( + String hintText, String selectedText, bool isDropDown, {IconData icon}) { return InputDecoration( contentPadding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), @@ -321,7 +185,7 @@ class _AddAllergiesState extends State { AppText( TranslationBase .of(context) - .addAllergies, + .addMedication, fontWeight: FontWeight.bold, fontSize: 16, ), @@ -331,109 +195,90 @@ class _AddAllergiesState extends State { Container( height: screenSize.height * 0.070, child: InkWell( - onTap: model.allergiesList != null - ? () { - setState(() { - _selectedAllergy = null; - allergyController.text = null; - }); - } - : null, - child: _selectedAllergy == null - ? AutoCompleteTextField( - decoration: textFieldSelectorDecoration( - TranslationBase - .of(context) - .selectAllergy, - _selectedAllergy != null - ? _selectedAllergy.nameEn - : null, true, - icon: EvaIcons.search), - itemSubmitted: (item) => - setState(() { - _selectedAllergy = item; - allergyController.text = - projectViewModel.isArabic - ? _selectedAllergy - .nameAr - : _selectedAllergy - .nameEn; - }), - key: key, - suggestions: model.allergiesList, - itemBuilder: (context, suggestion) => - new Padding( - child: Texts( - projectViewModel.isArabic - ? suggestion - .nameAr - : suggestion.nameEn), - padding: EdgeInsets.all(2.0)), - itemSorter: (a, b) => 1, - itemFilter: (suggestion, input) => - suggestion.nameAr.toLowerCase().startsWith( - input.toLowerCase()) || - suggestion.nameEn.toLowerCase() - .startsWith(input.toLowerCase()), - ) - : - TextFields( - onTapTextFields: model.allergiesList != - null - ? () { - setState(() { - _selectedAllergy = null; - allergyController.text = null; - }); - } + onTap: model.allMedicationList != null + ? () { + setState(() { + _selectedMedication = null; + }); + } + : null, + child: _selectedMedication == null + ? AutoCompleteTextField< + GetMedicationResponseModel>( + decoration: textFieldSelectorDecoration( + TranslationBase + .of(context) + .searchMedicineNameHere, + _selectedMedication != null + ? _selectedMedication.genericName : null, - hasLabelText: allergyController.text != - '' ? true : false, - showLabelText: true, - hintText: TranslationBase + 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) - .selectAllergy, - fontSize: 13.5, - readOnly: true, - fontWeight: FontWeight.w600, - maxLines: 2, - minLines: 1, - controller: allergyController, - suffixIcon: EvaIcons.search, - validator: (value) { - if (value == null) - return TranslationBase - .of(context) - .emptyMessage; - else - return null; - }) + .searchMedicineNameHere, + _selectedMedication != null + ? _selectedMedication.description + + (' (${_selectedMedication + .genericName} )') + : null, + true, + icon: EvaIcons.search), + enabled: false, + ), ), ), - if(isFormSubmitted && _selectedAllergy == null) + if(isFormSubmitted && _selectedMedication == null) CustomValidationError(), SizedBox( - height: 10, + height: 5, ), TextFields( - onTapTextFields: model - .medicationStrengthList != null + onTapTextFields: model.medicationDoseTimeList != + null ? () { MasterKeyDailog dialog = MasterKeyDailog( - list: model.medicationStrengthList, + list: model.medicationDoseTimeList, okText: TranslationBase .of(context) .ok, okFunction: (selectedValue) { setState(() { - _selectedMedicationStrengthSeverity = + _selectedMedicationDose = selectedValue; - severityController.text = + doseController.text = projectViewModel.isArabic - ? _selectedMedicationStrengthSeverity + ? _selectedMedicationDose .nameAr - : _selectedMedicationStrengthSeverity + : _selectedMedicationDose .nameEn; }); }, @@ -447,10 +292,12 @@ class _AddAllergiesState extends State { ); } : null, - hasLabelText: severityController.text != + hasLabelText: doseController.text != '' ? true : false, showLabelText: true, - hintText: "Strength", + hintText: TranslationBase + .of(context) + .doseTime, //TODO add translation fontSize: 13.5, readOnly: true, @@ -458,7 +305,7 @@ class _AddAllergiesState extends State { fontWeight: FontWeight.w600, maxLines: 2, minLines: 1, - controller: severityController, + controller: doseController, validator: (value) { if (value == null) return TranslationBase @@ -471,26 +318,29 @@ class _AddAllergiesState extends State { height: 5, ), if(isFormSubmitted && - _selectedMedicationStrengthSeverity == null) - CustomValidationError(), TextFields( - onTapTextFields: model.medicationDoseTimeList != - null + _selectedMedicationDose == null) + CustomValidationError(), SizedBox( + height: 5, + ), + TextFields( + onTapTextFields: model + .medicationStrengthList != null ? () { MasterKeyDailog dialog = MasterKeyDailog( - list: model.medicationDoseTimeList, + list: model.medicationStrengthList, okText: TranslationBase .of(context) .ok, okFunction: (selectedValue) { setState(() { - _selectedMedicationStrengthSeverity = + _selectedMedicationStrength = selectedValue; - severityController.text = + strengthController.text = projectViewModel.isArabic - ? _selectedMedicationStrengthSeverity + ? _selectedMedicationStrength .nameAr - : _selectedMedicationStrengthSeverity + : _selectedMedicationStrength .nameEn; }); }, @@ -504,18 +354,19 @@ class _AddAllergiesState extends State { ); } : null, - hasLabelText: severityController.text != + hasLabelText: strengthController.text != '' ? true : false, showLabelText: true, - hintText: "Dose Time", - //TODO add translation + hintText: TranslationBase + .of(context) + .strength, fontSize: 13.5, readOnly: true, // hintColor: Colors.black, fontWeight: FontWeight.w600, maxLines: 2, minLines: 1, - controller: severityController, + controller: strengthController, validator: (value) { if (value == null) return TranslationBase @@ -527,35 +378,94 @@ class _AddAllergiesState extends State { height: 5, ), if(isFormSubmitted && - _selectedMedicationStrengthSeverity == null) + _selectedMedicationStrength == null) CustomValidationError(), SizedBox( - height: 10, + height: 5, ), + TextFields( + onTapTextFields: model + .medicationRouteList != null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: model.medicationRouteList, + okText: TranslationBase + .of(context) + .ok, + okFunction: (selectedValue) { + setState(() { + _selectedMedicationRoute = + selectedValue; + + routeController.text = + projectViewModel.isArabic + ? _selectedMedicationRoute + .nameAr + : _selectedMedicationRoute + .nameEn; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hasLabelText: routeController.text != + '' ? true : false, + showLabelText: true, + hintText: TranslationBase + .of(context) + .route, + fontSize: 13.5, + readOnly: true, + // hintColor: Colors.black, + fontWeight: FontWeight.w600, + maxLines: 2, + minLines: 1, + controller: routeController, + validator: (value) { + if (value == null) + return TranslationBase + .of(context) + .emptyMessage; + else + return null; + }), SizedBox( - height: 10, + height: 5, + ), + if(isFormSubmitted && + _selectedMedicationRoute == null) + CustomValidationError(), + SizedBox( + height: 5, ), TextFields( onTapTextFields: model - .medicationStrengthList != null + .medicationFrequencyList != null ? () { MasterKeyDailog dialog = MasterKeyDailog( - list: model.medicationStrengthList, + list: model.medicationFrequencyList, okText: TranslationBase .of(context) .ok, okFunction: (selectedValue) { setState(() { - _selectedMedicationStrengthSeverity = + _selectedMedicationFrequency = selectedValue; - severityController.text = + frequencyController.text = projectViewModel.isArabic - ? _selectedMedicationStrengthSeverity + ? _selectedMedicationFrequency .nameAr - : _selectedMedicationStrengthSeverity + : _selectedMedicationFrequency .nameEn; }); }, @@ -569,10 +479,12 @@ class _AddAllergiesState extends State { ); } : null, - hasLabelText: severityController.text != + hasLabelText: frequencyController.text != '' ? true : false, showLabelText: true, - hintText: "Strength", + hintText: TranslationBase + .of(context) + .frequency, //TODO add translation fontSize: 13.5, readOnly: true, @@ -580,7 +492,7 @@ class _AddAllergiesState extends State { fontWeight: FontWeight.w600, maxLines: 2, minLines: 1, - controller: severityController, + controller: frequencyController, validator: (value) { if (value == null) return TranslationBase @@ -593,8 +505,11 @@ class _AddAllergiesState extends State { height: 5, ), if(isFormSubmitted && - _selectedMedicationStrengthSeverity == null) + _selectedMedicationFrequency == null) CustomValidationError(), + SizedBox( + height: 30, + ), AppButton( title: TranslationBase .of(context) @@ -604,15 +519,29 @@ class _AddAllergiesState extends State { setState(() { isFormSubmitted = true; }); - if (_selectedAllergy != null && - _selectedMedicationStrengthSeverity != - null) { - MySelectedAllergy mySelectedAllergy = new MySelectedAllergy( - remark: remarkController.text, - selectedAllergy: _selectedAllergy, - isChecked: true, - selectedAllergySeverity: _selectedMedicationStrengthSeverity,); - widget.addAllergiesFun(mySelectedAllergy); + 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(); } }, ), @@ -621,7 +550,7 @@ class _AddAllergiesState extends State { ), ), ), - )), + ),), ), ); } diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart index fb7b4dc6..3bc89a7f 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -209,7 +209,7 @@ class _UpdateSubjectivePageState extends State { complaintsController.text = helpers.parseHtmlString( model.patientChiefComplaintList[0].chiefComplaint); illnessController.text = model.patientChiefComplaintList[0].hopi; - medicationController.text = model.patientChiefComplaintList[0].currentMedication; + medicationController.text = model.patientChiefComplaintList[0].currentMedication + '\n \n'; } await getHistory(model); @@ -326,6 +326,10 @@ class _UpdateSubjectivePageState extends State { SizedBox( height: 10, ), + UpdateMedicationWidget(medicationController: medicationController,), + SizedBox( + height: 10, + ), Container( margin: EdgeInsets.only(left: 10, right: 10, top: 15), child: TextFields( @@ -340,7 +344,7 @@ class _UpdateSubjectivePageState extends State { // hintColor: Colors.black, fontWeight: FontWeight.w600, maxLines: 23, - minLines: 1, + minLines: 10, controller: medicationController, validator: (value) { if (value == null || value == "") @@ -354,10 +358,7 @@ class _UpdateSubjectivePageState extends State { SizedBox( height: 10, ), - UpdateMedicationWidget(myAllergiesList: widget.myAllergiesList,), - SizedBox( - height: 10, - ), + ]), ), isExpand: isChiefExpand, From 219ab8d4acca8a4acee0ce0cb4f3a9a7df8ac7cb Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 23 Feb 2021 09:57:36 +0200 Subject: [PATCH 3/4] fix DA-391 --- lib/screens/patients/patient_search_screen.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 994048a7..34e68779 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -340,6 +340,7 @@ class _PatientSearchScreenState extends State { SizedBox( height: 10, ), + if(_selectedType!='7') Container( decoration: BoxDecoration( borderRadius: From 8238e9569acebc813e8e303bbc440f8804bca284 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 23 Feb 2021 09:59:09 +0200 Subject: [PATCH 4/4] fix DA-391: return back my comment code in dashboard --- lib/screens/dashboard_screen.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 98422059..d2369e9d 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -140,7 +140,6 @@ class _DashboardScreenState extends State { Stack(children: [ Column( children: [ - if(false) ProfileWelcomeWidget( Container( width: MediaQuery.of(context).size.width * .6,