From d5bde6228a53969d3a7f3f93ecb04234fc7047b2 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 31 Dec 2020 23:29:31 +0200 Subject: [PATCH 1/2] add search in update assessment page --- .../soap_update/update_assessment_page.dart | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/lib/widgets/patients/profile/soap_update/update_assessment_page.dart b/lib/widgets/patients/profile/soap_update/update_assessment_page.dart index 556949e8..61c7f20b 100644 --- a/lib/widgets/patients/profile/soap_update/update_assessment_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_assessment_page.dart @@ -1,3 +1,4 @@ +import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; @@ -377,6 +378,7 @@ class _AddAssessmentDetailsState extends State { TextEditingController remarkController = TextEditingController(); TextEditingController appointmentIdController = TextEditingController( text: "234567"); + GlobalKey key = new GlobalKey>(); @override Widget build(BuildContext context) { @@ -385,7 +387,7 @@ class _AddAssessmentDetailsState extends State { .of(context) .size; InputDecoration textFieldSelectorDecoration(String hintText, - String selectedText, bool isDropDown) { + String selectedText, bool isDropDown,{IconData icon}) { //TODO: make one Input InputDecoration for all return InputDecoration( focusedBorder: OutlineInputBorder( @@ -401,7 +403,7 @@ class _AddAssessmentDetailsState extends State { borderRadius: BorderRadius.circular(8), ), hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + suffixIcon: isDropDown ? Icon(icon??Icons.arrow_drop_down) : null, hintStyle: TextStyle( fontSize: 14, color: Colors.grey.shade600, @@ -418,9 +420,9 @@ class _AddAssessmentDetailsState extends State { if (model.listOfDiagnosisType.length == 0) { await model.getMasterLookup(MasterKeysService.DiagnosisType); } - // if (model.listOfICD10.length == 0) { - // await model.getMasterLookup(MasterKeysService.ICD10); - // } + if (model.listOfICD10.length == 0) { + await model.getMasterLookup(MasterKeysService.ICD10); + } }, builder: (_, model, w) => AppScaffold( @@ -472,43 +474,28 @@ class _AddAssessmentDetailsState extends State { child: InkWell( onTap: model.listOfDiagnosisType != null ? () { - MasterKeyDailog dialog = MasterKeyDailog( - isICD: true, - list: model.listOfDiagnosisType, - selectedValue: widget - .mySelectedAssessment - .selectedICD, - okText: TranslationBase - .of(context) - .ok, - okFunction: - (MasterKeyModel selectedValue) { - setState(() { - widget.mySelectedAssessment - .selectedICD = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); + setState(() { + widget.mySelectedAssessment.selectedICD = null; + }); } : null, - child: TextField( + child: widget.mySelectedAssessment.selectedICD == null ? AutoCompleteTextField( + decoration: textFieldSelectorDecoration("Name or ICD", widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.nameEn : null, true,icon: EvaIcons.search), + itemSubmitted: (item) => setState(() => widget.mySelectedAssessment.selectedICD = item), + key: key, + suggestions: model.listOfICD10, + itemBuilder: (context, suggestion) => new Padding( + child:Texts( suggestion.description +" / "+ suggestion.code.toString()), + padding: EdgeInsets.all(8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.description.toLowerCase().startsWith(input.toLowerCase()) ||suggestion.description.toLowerCase().startsWith(input.toLowerCase()) + ||suggestion.code.toLowerCase().startsWith(input.toLowerCase()) + , + ): TextField( decoration: textFieldSelectorDecoration( - "Name / ICD", - widget.mySelectedAssessment - .selectedICD != - null - ? widget.mySelectedAssessment - .selectedICD.nameEn - : null, - true), + widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.code :"Name or ICD", + widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.nameEn : null, true,icon: EvaIcons.search), enabled: false, ), ), From 1af5f1040fbeca3b36b6f4895e061af9270871d2 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 31 Dec 2020 23:45:55 +0200 Subject: [PATCH 2/2] add search in soap update --- .../SOAP/subjective/add_allergies_widget.dart | 3 +- .../subjective/update_allergies_widget.dart | 53 ++- .../subjective/update_history_widget.dart | 317 +++--------------- .../soap_update/update_objective_page.dart | 110 ++---- 4 files changed, 102 insertions(+), 381 deletions(-) diff --git a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart index 0a4ce08e..43748f3d 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart @@ -242,7 +242,8 @@ class _AddAllergiesState extends State { ), SizedBox( height: 10, - ), Container( + ), + Container( height: screenSize.height * 0.070, child: InkWell( onTap: model.allergySeverityList != null diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart index d7bbd0af..fa6b8acb 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart @@ -1,6 +1,8 @@ +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'; @@ -14,6 +16,7 @@ import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.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'; class UpdateAllergiesWidget extends StatefulWidget { final List myAllergiesList; @@ -144,10 +147,11 @@ class _AddAllergiesState extends State { MasterKeyModel _selectedAllergySeverity; MasterKeyModel _selectedAllergy; TextEditingController remarkController = TextEditingController(); + GlobalKey key = new GlobalKey>(); InputDecoration textFieldSelectorDecoration(String hintText, - String selectedText, bool isDropDown) { + String selectedText, bool isDropDown,{IconData icon}) { return InputDecoration( focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), @@ -162,7 +166,7 @@ class _AddAllergiesState extends State { borderRadius: BorderRadius.circular(8), ), hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, + suffixIcon: isDropDown ? Icon(icon ?? Icons.arrow_drop_down) : null, hintStyle: TextStyle( fontSize: 14, color: Colors.grey.shade600, @@ -172,6 +176,7 @@ class _AddAllergiesState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); final screenSize = MediaQuery .of(context) .size; @@ -214,40 +219,32 @@ class _AddAllergiesState extends State { child: InkWell( onTap: model.allergiesList != null ? () { - MasterKeyDailog dialog = MasterKeyDailog( - list: model.allergiesList, - okText: TranslationBase - .of(context) - .ok, - okFunction: (MasterKeyModel selectedValue) { - setState(() { - _selectedAllergy = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); + setState(() { + _selectedAllergy = null; + }); } : null, - child: TextField( - decoration: textFieldSelectorDecoration( - "Select Allergy", - _selectedAllergy != null - ? _selectedAllergy.nameEn - : null, - true), + child: _selectedAllergy==null? AutoCompleteTextField( + decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search), + itemSubmitted: (item) => setState(() => _selectedAllergy = item), + key: key, + suggestions: model.allergiesList, + itemBuilder: (context, suggestion) => new Padding( + child:Texts( projectViewModel.isArabic? suggestion.nameAr: suggestion.nameEn), + padding: EdgeInsets.all(8.0)), + itemSorter: (a, b) => 1, + itemFilter: (suggestion, input) => + suggestion.nameAr.toLowerCase().startsWith(input.toLowerCase()) ||suggestion.nameEn.toLowerCase().startsWith(input.toLowerCase()), + ):TextField( + decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search), enabled: false, ), ), ), SizedBox( height: 10, - ), Container( + ), + Container( height: screenSize.height * 0.070, child: InkWell( onTap: model.allergySeverityList != null diff --git a/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart b/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart index d8f2b888..5e033127 100644 --- a/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart +++ b/lib/widgets/patients/profile/soap_update/subjective/update_history_widget.dart @@ -10,6 +10,7 @@ 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/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; @@ -280,273 +281,59 @@ class _AddHistoryDialogState extends State { }, scrollDirection: Axis.horizontal, children: [ - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.historyFamilyList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - (bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - widget.addSelectedHistories(); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyFamilyList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.mergeHistorySurgicalWithHistorySportList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - widget.addSelectedHistories(); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.mergeHistorySurgicalWithHistorySportList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), - Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model.historyMedicalList - .map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - historyInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - historyInfo - )) { - widget - .removeHistory( - historyInfo - ); - } - else { - widget - .myHistoryList - .add( - historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - historyInfo.nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES" - .toUpperCase(), - onPressed: () { - setState(() { - widget.addSelectedHistories(); - }); - }, - ), - ], - ), + MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyMedicalList, + removeHistory: (history){ + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history){ + setState(() { + widget.myHistoryList.add(history); + }); + }, + addSelectedHistories: (){ + widget.addSelectedHistories(); + }, + isServiceSelected: (master) =>isServiceSelected(master), ), ], ), diff --git a/lib/widgets/patients/profile/soap_update/update_objective_page.dart b/lib/widgets/patients/profile/soap_update/update_objective_page.dart index d7123678..b43db98d 100644 --- a/lib/widgets/patients/profile/soap_update/update_objective_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_objective_page.dart @@ -17,6 +17,7 @@ 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/divider_with_spaces_around.dart'; import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.dart'; +import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; @@ -497,96 +498,31 @@ class _AddExaminationDailogState extends State { ), NetworkBaseView( baseViewModel: model, - child: Container( - height: - MediaQuery - .of(context) - .size - .height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius - .circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: model - .physicalExaminationList - .map((examinationInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: isServiceSelected( - examinationInfo), - activeColor: - Colors.red[800], - onChanged: - ( - bool newValue) { - setState(() { - if (isServiceSelected( - examinationInfo - )) { - widget - .removeExamination( - examinationInfo - ); - } - else { - MySelectedExamination mySelectedExamination = new MySelectedExamination( - selectedExamination: examinationInfo - ); - widget - .mySelectedExamination - .add( - mySelectedExamination); - } - }); - }), - Expanded( - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts( - examinationInfo - .nameEn, - variant: "bodyText", - bold: true, - color: - Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ), - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED Examinations" - .toUpperCase(), - onPressed: () { + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.physicalExaminationList, + removeHistory: (history){ + setState(() { + widget.removeExamination(history); + }); + }, + addHistory: (history){ + setState(() { + MySelectedExamination mySelectedExamination = new MySelectedExamination( + selectedExamination: history + ); + widget + .mySelectedExamination + .add( + mySelectedExamination); + }); + }, + addSelectedHistories: (){ widget.addSelectedExamination(); }, + isServiceSelected: (master) =>isServiceSelected(master), ), + ), ]), ))), )),