From 2fd30ae1be0413e3bb01588d26049af6364f7773 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 18 Apr 2021 17:23:47 +0300 Subject: [PATCH] improve exam step --- .../post_physical_exam_request_model.dart | 1 - .../assessment/update_assessment_page.dart | 1 + .../objective/add_examination_page.dart | 148 ++++++++++ ...ation.dart => add_examination_widget.dart} | 253 +----------------- ...m-card.dart => examination_item_card.dart} | 0 .../examinations_list_search_widget.dart | 115 ++++++++ .../objective/update_objective_page.dart | 10 +- .../subjective/allergies/add_allergies.dart | 23 +- .../history/update_history_widget.dart | 1 - 9 files changed, 282 insertions(+), 270 deletions(-) create mode 100644 lib/screens/patients/profile/soap_update/objective/add_examination_page.dart rename lib/screens/patients/profile/soap_update/objective/{add-examination.dart => add_examination_widget.dart} (54%) rename lib/screens/patients/profile/soap_update/objective/{examination-item-card.dart => examination_item_card.dart} (100%) create mode 100644 lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart diff --git a/lib/models/SOAP/post_physical_exam_request_model.dart b/lib/models/SOAP/post_physical_exam_request_model.dart index d1b64837..52836232 100644 --- a/lib/models/SOAP/post_physical_exam_request_model.dart +++ b/lib/models/SOAP/post_physical_exam_request_model.dart @@ -1,4 +1,3 @@ - import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; class PostPhysicalExamRequestModel { List listHisProgNotePhysicalExaminationVM; diff --git a/lib/screens/patients/profile/soap_update/assessment/update_assessment_page.dart b/lib/screens/patients/profile/soap_update/assessment/update_assessment_page.dart index ecb57067..7a42fe79 100644 --- a/lib/screens/patients/profile/soap_update/assessment/update_assessment_page.dart +++ b/lib/screens/patients/profile/soap_update/assessment/update_assessment_page.dart @@ -23,6 +23,7 @@ import '../shared_soap_widgets/SOAP_step_header.dart'; import '../shared_soap_widgets/expandable_SOAP_widget.dart'; import 'add_assessment_details.dart'; +// ignore: must_be_immutable class UpdateAssessmentPage extends StatefulWidget { final Function changePageViewIndex; List mySelectedAssessmentList; diff --git a/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart b/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart new file mode 100644 index 00000000..b9f1bd63 --- /dev/null +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart @@ -0,0 +1,148 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.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/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/borderedButton.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +import 'examinations_list_search_widget.dart'; + +class AddExaminationPage extends StatefulWidget { + final List mySelectedExamination; + final Function addSelectedExamination; + final Function(MasterKeyModel) removeExamination; + + AddExaminationPage( + {this.mySelectedExamination, + this.addSelectedExamination, + this.removeExamination}); + + @override + _AddExaminationPageState createState() => _AddExaminationPageState(); +} + +class _AddExaminationPageState extends State { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) async { + if (model.physicalExaminationList.length == 0) { + await model.getMasterLookup(MasterKeysService.PhysicalExamination); + } + }, + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: false, + backgroundColor: Color.fromRGBO(248, 248, 248, 1), + body: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + padding: + EdgeInsets.only(left: 16, top: 70, right: 16, bottom: 16), + color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: AppText( + "${TranslationBase.of(context).addExamination}", + fontSize: SizeConfig.textMultiplier * 3.3, + color: Colors.black, + fontWeight: FontWeight.w700, + ), + ), + InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Icon( + Icons.clear, + size: 40, + ), + ) + ], + ), + ), + Expanded( + child: SingleChildScrollView( + child: Column( + children: [ + Container( + margin: EdgeInsets.all(16.0), + padding: EdgeInsets.all(0.0), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.circular(12), + border: Border.fromBorderSide(BorderSide( + color: Colors.grey.shade400, + width: 0.4, + )), + ), + child: Column( + children: [ + ExaminationsListSearchWidget( + masterList: model.physicalExaminationList, + isServiceSelected: (master) => + isServiceSelected(master), + removeHistory: (history) { + setState(() { + widget.removeExamination(history); + }); + }, + addHistory: (selectedExamination) { + setState(() { + widget.mySelectedExamination + .add(selectedExamination); + }); + }, + ), + ], + ), + ), + ], + ), + ), + ), + Container( + padding: EdgeInsets.all(16), + color: Colors.white, + child: BorderedButton( + "${TranslationBase.of(context).addExamination}", + backgroundColor: HexColor("#359846"), + textColor: Colors.white, + vPadding: 12, + radius: 12, + fontWeight: FontWeight.w600, + fontSize: SizeConfig.textMultiplier * 2.5, + fontFamily: 'Poppins', + handler: () { + widget.addSelectedExamination(); + }, + ), + ) + ], + ), + ), + ); + } + + isServiceSelected(MasterKeyModel masterKey) { + Iterable exam = widget.mySelectedExamination.where( + (element) => + masterKey.id == element.selectedExamination.id && + masterKey.typeId == element.selectedExamination.typeId); + if (exam.length > 0) { + return true; + } + return false; + } +} diff --git a/lib/screens/patients/profile/soap_update/objective/add-examination.dart b/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart similarity index 54% rename from lib/screens/patients/profile/soap_update/objective/add-examination.dart rename to lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart index 3a9dcd24..82cef2e9 100644 --- a/lib/screens/patients/profile/soap_update/objective/add-examination.dart +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart @@ -1,252 +1,17 @@ +// ignore: must_be_immutable import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; -import 'package:doctor_app_flutter/core/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_examination.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/app-textfield-custom.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/borderedButton.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:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; -class AddExaminationPage extends StatefulWidget { - final List mySelectedExamination; - final Function addSelectedExamination; - final Function(MasterKeyModel) removeExamination; - - AddExaminationPage( - {this.mySelectedExamination, - this.addSelectedExamination, - this.removeExamination}); - - @override - _AddExaminationPageState createState() => _AddExaminationPageState(); -} - -class _AddExaminationPageState extends State { - @override - Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) async { - if (model.physicalExaminationList.length == 0) { - await model.getMasterLookup(MasterKeysService.PhysicalExamination); - } - }, - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: false, - backgroundColor: Color.fromRGBO(248, 248, 248, 1), - body: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - padding: - EdgeInsets.only(left: 16, top: 70, right: 16, bottom: 16), - color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: AppText( - "${TranslationBase.of(context).addExamination}", - fontSize: SizeConfig.textMultiplier * 3.3, - color: Colors.black, - fontWeight: FontWeight.w700, - ), - ), - InkWell( - onTap: () { - Navigator.of(context).pop(); - }, - child: Icon( - Icons.clear, - size: 40, - ), - ) - ], - ), - ), - Expanded( - child: SingleChildScrollView( - child: Column( - children: [ - Container( - margin: EdgeInsets.all(16.0), - padding: EdgeInsets.all(0.0), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: Colors.white, - borderRadius: BorderRadius.circular(12), - border: Border.fromBorderSide(BorderSide( - color: Colors.grey.shade400, - width: 0.4, - )), - ), - child: Column( - children: [ - ExaminationsListSearchWidget( - masterList: model.physicalExaminationList, - isServiceSelected: (master) => - isServiceSelected(master), - removeHistory: (history) { - setState(() { - widget.removeExamination(history); - }); - }, - addHistory: (selectedExamination) { - setState(() { - widget.mySelectedExamination - .add(selectedExamination); - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - Container( - padding: EdgeInsets.all(16), - color: Colors.white, - child: BorderedButton( - "${TranslationBase.of(context).addExamination}", - backgroundColor: HexColor("#359846"), - textColor: Colors.white, - vPadding: 12, - radius: 12, - fontWeight: FontWeight.w600, - fontSize: SizeConfig.textMultiplier * 2.5, - fontFamily: 'Poppins', - handler: () { - widget.addSelectedExamination(); - }, - ), - ) - ], - ), - ), - ); - } - - isServiceSelected(MasterKeyModel masterKey) { - Iterable exam = widget.mySelectedExamination.where( - (element) => - masterKey.id == element.selectedExamination.id && - masterKey.typeId == element.selectedExamination.typeId); - if (exam.length > 0) { - return true; - } - return false; - } -} - -class ExaminationsListSearchWidget extends StatefulWidget { - final Function(MasterKeyModel) removeHistory; - final Function(MySelectedExamination) addHistory; - final bool Function(MasterKeyModel) isServiceSelected; - final List masterList; - - ExaminationsListSearchWidget( - {this.removeHistory, - this.addHistory, - this.isServiceSelected, - this.masterList}); - - @override - _ExaminationsListSearchWidgetState createState() => - _ExaminationsListSearchWidgetState(); -} - -class _ExaminationsListSearchWidgetState - extends State { - int expandedIndex = -1; - List items = List(); - TextEditingController filteredSearchController = TextEditingController(); - - @override - void initState() { - items.addAll(widget.masterList); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - AppTextFieldCustom( - height: MediaQuery.of(context).size.height * 0.080, - hintText: TranslationBase.of(context).searchExamination, - isDropDown: true, - hasBorder: false, - controller: filteredSearchController, - onChanged: (value) { - filterSearchResults(value); - }, - suffixIcon: Icon( - Icons.search, - color: Colors.black, - ), - ), - DividerWithSpacesAround( - height: 2, - ), - ...items.mapIndexed((index, item) { - return AddExaminationWidget( - item: item, - addHistory: widget.addHistory, - removeHistory: widget.removeHistory, - isServiceSelected: widget.isServiceSelected, - isExpand: index == expandedIndex, - expandClick: () { - setState(() { - if (expandedIndex == index) { - expandedIndex = -1; - } else { - expandedIndex = index; - } - }); - }, - ); - }).toList(), - ], - ); - } - - void filterSearchResults(String query) { - List dummySearchList = List(); - dummySearchList.addAll(widget.masterList); - if (query.isNotEmpty) { - List dummyListData = List(); - dummySearchList.forEach((item) { - if (item.nameAr.toLowerCase().contains(query.toLowerCase()) || - item.nameEn.toLowerCase().contains(query.toLowerCase())) { - dummyListData.add(item); - } - }); - setState(() { - items.clear(); - items.addAll(dummyListData); - }); - return; - } else { - setState(() { - items.clear(); - items.addAll(widget.masterList); - }); - } - } -} - +// ignore: must_be_immutable class AddExaminationWidget extends StatefulWidget { MasterKeyModel item; final Function(MasterKeyModel) removeHistory; @@ -275,10 +40,10 @@ class _AddExaminationWidgetState extends State { @override void initState() { - examination.selectedExamination = widget.item; super.initState(); } + @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -479,7 +244,7 @@ class _AddExaminationWidgetState extends State { minLines: 2, maxLines: 4, inputType: TextInputType.multiline, - onChanged: (value){ + onChanged: (value) { examination.remark = value; }, ), @@ -492,13 +257,3 @@ class _AddExaminationWidgetState extends State { ); } } - -extension FicListExtension on List { - /// Maps each element of the list. - /// The [map] function gets both the original [item] and its [index]. - Iterable mapIndexed(E Function(int index, T item) map) sync* { - for (var index = 0; index < length; index++) { - yield map(index, this[index]); - } - } -} diff --git a/lib/screens/patients/profile/soap_update/objective/examination-item-card.dart b/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart similarity index 100% rename from lib/screens/patients/profile/soap_update/objective/examination-item-card.dart rename to lib/screens/patients/profile/soap_update/objective/examination_item_card.dart diff --git a/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart b/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart new file mode 100644 index 00000000..941b60ca --- /dev/null +++ b/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart @@ -0,0 +1,115 @@ +import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/app-textfield-custom.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:flutter/material.dart'; + +import 'add_examination_widget.dart'; + +class ExaminationsListSearchWidget extends StatefulWidget { + final Function(MasterKeyModel) removeHistory; + final Function(MySelectedExamination) addHistory; + final bool Function(MasterKeyModel) isServiceSelected; + final List masterList; + + ExaminationsListSearchWidget( + {this.removeHistory, + this.addHistory, + this.isServiceSelected, + this.masterList}); + + @override + _ExaminationsListSearchWidgetState createState() => + _ExaminationsListSearchWidgetState(); +} + +class _ExaminationsListSearchWidgetState + extends State { + int expandedIndex = -1; + List items = List(); + TextEditingController filteredSearchController = TextEditingController(); + + @override + void initState() { + items.addAll(widget.masterList); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + AppTextFieldCustom( + height: MediaQuery.of(context).size.height * 0.080, + hintText: TranslationBase.of(context).searchExamination, + isDropDown: true, + hasBorder: false, + controller: filteredSearchController, + onChanged: (value) { + filterSearchResults(value); + }, + suffixIcon: Icon( + Icons.search, + color: Colors.black, + ), + ), + DividerWithSpacesAround( + height: 2, + ), + ...items.mapIndexed((index, item) { + return AddExaminationWidget( + item: item, + addHistory: widget.addHistory, + removeHistory: widget.removeHistory, + isServiceSelected: widget.isServiceSelected, + isExpand: index == expandedIndex, + expandClick: () { + setState(() { + if (expandedIndex == index) { + expandedIndex = -1; + } else { + expandedIndex = index; + } + }); + }, + ); + }).toList(), + ], + ); + } + + void filterSearchResults(String query) { + List dummySearchList = List(); + dummySearchList.addAll(widget.masterList); + if (query.isNotEmpty) { + List dummyListData = List(); + dummySearchList.forEach((item) { + if (item.nameAr.toLowerCase().contains(query.toLowerCase()) || + item.nameEn.toLowerCase().contains(query.toLowerCase())) { + dummyListData.add(item); + } + }); + setState(() { + items.clear(); + items.addAll(dummyListData); + }); + return; + } else { + setState(() { + items.clear(); + items.addAll(widget.masterList); + }); + } + } +} + +extension FicListExtension on List { + /// Maps each element of the list. + /// The [map] function gets both the original [item] and its [index]. + Iterable mapIndexed(E Function(int index, T item) map) sync* { + for (var index = 0; index < length; index++) { + yield map(index, this[index]); + } + } +} diff --git a/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart b/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart index 8c69084a..abb62808 100644 --- a/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart +++ b/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart @@ -18,18 +18,17 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; import '../shared_soap_widgets/SOAP_open_items.dart'; import '../shared_soap_widgets/SOAP_step_header.dart'; import '../shared_soap_widgets/expandable_SOAP_widget.dart'; -import 'add-examination.dart'; -import 'examination-item-card.dart'; +import 'add_examination_page.dart'; +import 'examination_item_card.dart'; class UpdateObjectivePage extends StatefulWidget { final Function changePageViewIndex; final Function changeLoadingState; - final int currentIndex; + final int currentIndex; final List mySelectedExamination; final PatiantInformtion patientInfo; @@ -62,9 +61,6 @@ class _UpdateObjectivePageState extends State { @override Widget build(BuildContext context) { - final screenSize = MediaQuery.of(context).size; - ProjectViewModel projectViewModel = Provider.of(context); - return BaseView( onModelReady: (model) async { widget.mySelectedExamination.clear(); diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart index 437cc928..c1cbcd28 100644 --- a/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/add_allergies.dart @@ -12,7 +12,6 @@ import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_all import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -import 'package:provider/provider.dart'; import '../../shared_soap_widgets/bottom_sheet_title.dart'; @@ -72,8 +71,6 @@ class _AddAllergiesState extends State { @override Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - final screenSize = MediaQuery.of(context).size; return FractionallySizedBox( heightFactor: 1, child: BaseView( @@ -119,8 +116,8 @@ class _AddAllergiesState extends State { }, addAllergy: (MySelectedAllergy mySelectedAllergy) { - AddAllergyLocally(mySelectedAllergy); - }, + addAllergyLocally(mySelectedAllergy); + }, addSelectedAllergy: () => widget .addAllergiesFun(myAllergiesListLocal), isServiceSelected: (master) => @@ -208,17 +205,19 @@ class _AddAllergiesState extends State { return null; } - AddAllergyLocally(MySelectedAllergy mySelectedAllergy) { + addAllergyLocally(MySelectedAllergy mySelectedAllergy) { if (mySelectedAllergy.selectedAllergy == null) { - helpers.showErrorToast(TranslationBase.of(context).requiredMsg); + helpers.showErrorToast(TranslationBase + .of(context) + .requiredMsg); } else { setState(() { List allergy = - // ignore: missing_return - myAllergiesListLocal - .where((element) => - mySelectedAllergy.selectedAllergy.id == - element.selectedAllergy.id) + // ignore: missing_return + myAllergiesListLocal + .where((element) => + mySelectedAllergy.selectedAllergy.id == + element.selectedAllergy.id) .toList(); if (allergy.isEmpty) { diff --git a/lib/screens/patients/profile/soap_update/subjective/history/update_history_widget.dart b/lib/screens/patients/profile/soap_update/subjective/history/update_history_widget.dart index ad8f779e..41df16ed 100644 --- a/lib/screens/patients/profile/soap_update/subjective/history/update_history_widget.dart +++ b/lib/screens/patients/profile/soap_update/subjective/history/update_history_widget.dart @@ -23,7 +23,6 @@ class UpdateHistoryWidget extends StatefulWidget { class _UpdateHistoryWidgetState extends State with TickerProviderStateMixin { PageController _controller; - int _currentIndex = 0; changePageViewIndex(pageIndex) { _controller.jumpToPage(pageIndex);