From ced8e7976fba0709218df82f37ebf5de58e4c1ab Mon Sep 17 00:00:00 2001 From: "taha.alam" Date: Mon, 23 Dec 2024 11:20:52 +0300 Subject: [PATCH] WD: remarks made non_mandatory if condition is normal --- .../model/SOAP/physical_exam/Category.dart | 1 + .../add_details_to_examination_vida_plus.dart | 71 ++++++++++++------- .../objective/widget/examination_items.dart | 2 + 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/lib/core/model/SOAP/physical_exam/Category.dart b/lib/core/model/SOAP/physical_exam/Category.dart index 975af7c4..26542d27 100644 --- a/lib/core/model/SOAP/physical_exam/Category.dart +++ b/lib/core/model/SOAP/physical_exam/Category.dart @@ -39,6 +39,7 @@ class Category { bool isSelected = false; TextEditingController remarksController = TextEditingController(); int selectedCondition = -1; + String selectedConditionName = ""; String? pomrId; int? paitientId; int? userID; diff --git a/lib/screens/patients/profile/soap_update_vida_plus/objective/add_details_to_examination_vida_plus.dart b/lib/screens/patients/profile/soap_update_vida_plus/objective/add_details_to_examination_vida_plus.dart index 6abbdb52..86d0bf15 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/objective/add_details_to_examination_vida_plus.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/objective/add_details_to_examination_vida_plus.dart @@ -18,6 +18,7 @@ import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dar import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../../../../core/model/SOAP/physical_exam/Category.dart'; import '../../../../../core/viewModel/project_view_model.dart'; class AddDetailsToExaminationVidaPlus extends StatefulWidget { @@ -25,9 +26,7 @@ class AddDetailsToExaminationVidaPlus extends StatefulWidget { final PatiantInformtion patientInfo; const AddDetailsToExaminationVidaPlus( - {super.key, - this.mySelectedExamination, - required this.patientInfo}); + {super.key, this.mySelectedExamination, required this.patientInfo}); @override State createState() => @@ -44,10 +43,11 @@ class _AddDetailsToExaminationVidaPlusState ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) async { - WidgetsBinding.instance.addPostFrameCallback((_) async { - widget.mySelectedExamination?.forEach((value) => - model.getSpecialityDetails( - value.name ?? '', value.id, widget.patientInfo));}); + WidgetsBinding.instance.addPostFrameCallback((_) async { + widget.mySelectedExamination?.forEach((value) => + model.getSpecialityDetails( + value.name ?? '', value.id, widget.patientInfo)); + }); }, builder: (_, model, w) => AppScaffold( isShowAppBar: true, @@ -68,9 +68,10 @@ class _AddDetailsToExaminationVidaPlusState headerTitle: title, onTap: () { setState(() { - if(currentlyExpanded == title) { + if (currentlyExpanded == title) { currentlyExpanded = ''; - }else currentlyExpanded = title; + } else + currentlyExpanded = title; }); }, child: ExaminationItems( @@ -115,26 +116,48 @@ class _AddDetailsToExaminationVidaPlusState fontColor: Colors.white, fontWeight: FontWeight.w600, onPressed: () async { - var listOfSelectedCategory = model.getListOfSelectedCategory(); - if(listOfSelectedCategory.isEmpty){ - DrAppToastMsg.showErrorToast(TranslationBase.of(context).kindlySelectCategory); + var listOfSelectedCategory = + model.getListOfSelectedCategory(); + + + if (listOfSelectedCategory.isEmpty) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .kindlySelectCategory); return; } - if(listOfSelectedCategory.any((value) => value.remarksController.text.isEmpty)){ + /* if (listOfSelectedCategory.any((value) { + return value.remarksController.text.isEmpty && value.conditionsList?.firstWhere((item){ + return item.conditionName == value.selectedCondition; + }).conditionCode?.toLowerCase() == TranslationBase.of(context).normal.toLowerCase(); + })) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .remarksCanNotBeEmpty); + return; + }*/ + if(listOfSelectedCategory.any((value) { + print('the value is ${value.selectedConditionName}'); + return value.remarksController.text.isEmpty == true && value.selectedConditionName.isNotEmpty &&value.selectedConditionName != TranslationBase.of(context).normal.toLowerCase(); })) { DrAppToastMsg.showErrorToast(TranslationBase.of(context).remarksCanNotBeEmpty); return; } - var result = await model.postPhysicalExamination(widget.patientInfo,listOfSelectedCategory); - if(result){ - model.getPhysicalExamination(widget.patientInfo); - Navigator.popUntil(context, ((route) { - if (route.settings.name == UPDATE_EPISODE_VIDA_PLUS) { - return true; - } else { - return false; - } - })); - } + var result = + await model.postPhysicalExamination( + widget.patientInfo, + listOfSelectedCategory); + if (result) { + model.getPhysicalExamination( + widget.patientInfo); + Navigator.popUntil(context, ((route) { + if (route.settings.name == + UPDATE_EPISODE_VIDA_PLUS) { + return true; + } else { + return false; + } + })); + } }, ), ), diff --git a/lib/screens/patients/profile/soap_update_vida_plus/objective/widget/examination_items.dart b/lib/screens/patients/profile/soap_update_vida_plus/objective/widget/examination_items.dart index 088b3845..126e84e1 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/objective/widget/examination_items.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/objective/widget/examination_items.dart @@ -97,6 +97,8 @@ class _ExaminationItemsState extends State { itemBuilder: (context, currentIndex) => InkWell( onTap: () { setState(() { + value + .selectedConditionName = value.conditionsList?[currentIndex].conditionCode?? ''; value .selectedCondition = int.parse(value