From 9194d8a44b24a354041d26cca2efa2ae46ee55e0 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Sun, 3 Jan 2021 14:29:47 +0200 Subject: [PATCH] delete Allergy --- lib/models/SOAP/my_selected_allergy.dart | 5 +- .../profile/soap_update/steps_widget.dart | 14 ++-- .../subjective/update_allergies_widget.dart | 80 +++++++++++++------ .../subjective/update_subjective_page.dart | 5 ++ lib/widgets/shared/Text.dart | 7 +- 5 files changed, 78 insertions(+), 33 deletions(-) diff --git a/lib/models/SOAP/my_selected_allergy.dart b/lib/models/SOAP/my_selected_allergy.dart index 9996b65a..e5b45502 100644 --- a/lib/models/SOAP/my_selected_allergy.dart +++ b/lib/models/SOAP/my_selected_allergy.dart @@ -4,9 +4,10 @@ class MySelectedAllergy { MasterKeyModel selectedAllergySeverity; MasterKeyModel selectedAllergy; String remark; + bool isChecked; MySelectedAllergy( - {this.selectedAllergySeverity, this.selectedAllergy, this.remark}); + {this.selectedAllergySeverity, this.selectedAllergy, this.remark, this.isChecked}); MySelectedAllergy.fromJson(Map json) { selectedAllergySeverity = json['selectedAllergySeverity'] != null @@ -16,6 +17,7 @@ class MySelectedAllergy { ? new MasterKeyModel.fromJson(json['selectedAllergy']) : null; remark = json['remark']; + remark = json['isChecked']; } Map toJson() { @@ -27,6 +29,7 @@ class MySelectedAllergy { data['selectedAllergy'] = this.selectedAllergy.toJson(); } data['remark'] = this.remark; + data['isChecked'] = this.remark; return data; } } diff --git a/lib/widgets/patients/profile/soap_update/steps_widget.dart b/lib/widgets/patients/profile/soap_update/steps_widget.dart index 56f3435e..b7e9e837 100644 --- a/lib/widgets/patients/profile/soap_update/steps_widget.dart +++ b/lib/widgets/patients/profile/soap_update/steps_widget.dart @@ -34,7 +34,7 @@ class StepsWidget extends StatelessWidget { top: index == 0 ? 15 : 30, left: 0, child: InkWell( - //onTap: () => changeCurrentTab(0), + onTap: () => changeCurrentTab(0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -84,7 +84,7 @@ class StepsWidget extends StatelessWidget { top: index == 1 ? 15 : 30, left: MediaQuery.of(context).size.width * 0.28, child: InkWell( - //onTap: () => index >= 1 ? changeCurrentTab(1) : null, + onTap: () => index >= 1 ? changeCurrentTab(1) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -187,7 +187,7 @@ class StepsWidget extends StatelessWidget { top: index == 3 ? 15 : 30, right: 0, child: InkWell( - //onTap: () => index >= 3 ? changeCurrentTab(4) : null, + onTap: () => index >= 3 ? changeCurrentTab(4) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -257,7 +257,7 @@ class StepsWidget extends StatelessWidget { top: index == 0 ? 15 : 30, right: 0, child: InkWell( - //onTap: () => changeCurrentTab(0), + onTap: () => changeCurrentTab(0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -307,7 +307,7 @@ class StepsWidget extends StatelessWidget { top: index == 1 ? 15 : 30, right: MediaQuery.of(context).size.width * 0.28, child: InkWell( - //onTap: () => index >= 2 ? changeCurrentTab(1) : null, + onTap: () => index >= 2 ? changeCurrentTab(1) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -357,7 +357,7 @@ class StepsWidget extends StatelessWidget { top: index == 2 ? 15 : 30, right: MediaQuery.of(context).size.width * 0.52, child: InkWell( - //onTap: () => index >= 3 ? changeCurrentTab(2) : null, + onTap: () => index >= 3 ? changeCurrentTab(2) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -411,7 +411,7 @@ class StepsWidget extends StatelessWidget { top: index == 3 ? 15 : 30, left: 0, child: InkWell( - //onTap: () => index >= 3 ? changeCurrentTab(4) : null, + onTap: () => index >= 3 ? changeCurrentTab(4) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ 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 5d54dfa5..2d1f66ea 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 @@ -80,10 +80,15 @@ class _UpdateAllergiesWidgetState extends State { Container( child: Expanded( - child: Texts(projectViewModel.isArabic ? selectedAllergy - .selectedAllergy.nameAr : selectedAllergy - .selectedAllergy.nameEn.toUpperCase(), + child: Texts( + projectViewModel.isArabic + ? selectedAllergy.selectedAllergy.nameAr + : selectedAllergy.selectedAllergy.nameEn + .toUpperCase(), variant: "bodyText", + textDecoration: selectedAllergy.isChecked + ? null + : TextDecoration.lineThrough, bold: true, color: Colors.black), ), @@ -95,17 +100,21 @@ class _UpdateAllergiesWidgetState extends State { .selectedAllergySeverity.nameEn .toUpperCase(), variant: "bodyText", + textDecoration: selectedAllergy.isChecked + ? null + : TextDecoration.lineThrough, bold: true, color: AppGlobal.appPrimaryColor), - InkWell( - child: Icon( - FontAwesomeIcons.trash, - color: Colors.grey, - size: 20, - ), - onTap: () => removeAllergy(selectedAllergy), - ) - ], + if(selectedAllergy.isChecked) + InkWell( + child: Icon( + FontAwesomeIcons.trash, + color: Colors.grey, + size: 20, + ), + onTap: () => removeAllergy(selectedAllergy), + ) + ], ), SizedBox( height: 10, @@ -119,13 +128,22 @@ class _UpdateAllergiesWidgetState extends State { } removeAllergy(MySelectedAllergy mySelectedAllergy) { - Iterable allergy = - widget.myAllergiesList.where((element) => mySelectedAllergy == element); + 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) + if (allergy.length > 0) { setState(() { - widget.myAllergiesList.remove(allergy.first); + allergy[0].isChecked = false; }); + } + + + print(allergy); } openAllergiesList(BuildContext context) { @@ -137,14 +155,29 @@ class _UpdateAllergiesWidgetState extends State { return AddAllergies( addAllergiesFun: (MySelectedAllergy mySelectedAllergy) { setState(() { - if (!widget.myAllergiesList.contains(mySelectedAllergy)) { + 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 { - helpers.showErrorToast(TranslationBase - .of(context) - .itemExist); + allergy.first.selectedAllergy = + mySelectedAllergy.selectedAllergy; + allergy.first.selectedAllergySeverity = + mySelectedAllergy.selectedAllergySeverity; + allergy.first.remark = mySelectedAllergy.remark; + allergy.first.isChecked = mySelectedAllergy.isChecked; + + // helpers.showErrorToast(TranslationBase + // .of(context) + // .itemExist); } + + Navigator.of(context).pop(); }); },); }); @@ -353,9 +386,10 @@ class _AddAllergiesState extends State { title: "Add".toUpperCase(), onPressed: () { MySelectedAllergy mySelectedAllergy = new MySelectedAllergy( - remark: remarkController.text, - selectedAllergy: _selectedAllergy, - selectedAllergySeverity: _selectedAllergySeverity); + remark: remarkController.text, + selectedAllergy: _selectedAllergy, + isChecked: true, + selectedAllergySeverity: _selectedAllergySeverity,); 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 98d1b7d0..ddab4734 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 @@ -131,6 +131,10 @@ class _UpdateSubjectivePageState extends State { return BaseView( onModelReady: (model) async { + widget.myAllergiesList.clear(); + widget.myHistoryList.clear(); + + GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP( patientMRN: widget.patientInfo.patientMRN, episodeId: widget.patientInfo.episodeNo, @@ -165,6 +169,7 @@ class _UpdateSubjectivePageState extends State { ); MySelectedAllergy mySelectedAllergy = MySelectedAllergy( selectedAllergy: selectedAllergy, + isChecked: element.isChecked, selectedAllergySeverity: selectedAllergySeverity); if (selectedAllergy != null && selectedAllergySeverity != null) widget.myAllergiesList.add(mySelectedAllergy); diff --git a/lib/widgets/shared/Text.dart b/lib/widgets/shared/Text.dart index 9f6dfdf1..f2e663bf 100644 --- a/lib/widgets/shared/Text.dart +++ b/lib/widgets/shared/Text.dart @@ -16,11 +16,12 @@ class Texts extends StatefulWidget { final bool readMore; final String style; final bool allowExpand; + final TextDecoration textDecoration; Texts(this.text, {Key key, this.variant, this.color, this.bold, this.regular, this.medium, this.allowExpand = true, this.italic:false, this.textAlign, this.maxLength=60, - this.maxLines, this.readMore=false, this.style + this.maxLines, this.readMore=false, this.style, this.textDecoration }) : super(key: key); @override @@ -192,6 +193,7 @@ class _TextsState extends State { fontSize: _getFontSize(), letterSpacing: widget.variant=="overline" ? 1.5 : null, fontWeight: _getFontWeight(), + decoration: widget.textDecoration//TextDecoration.lineThrough ) ), if (widget.readMore && text.length > widget.maxLength && hidden) @@ -228,7 +230,8 @@ class _TextsState extends State { style: _getFontStyle().copyWith( color: HexColor('#FF0000'), fontWeight: FontWeight.w800, - fontFamily: "WorkSans" + fontFamily: "WorkSans", + ) ), ),