From 638ae40035b90b0c9d85e6ceb408e3ae4c66213b Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 8 Jul 2021 13:06:32 +0300 Subject: [PATCH 01/13] first step for fix first step from fixes soap --- lib/config/config.dart | 4 +- lib/models/SOAP/my_selected_allergy.dart | 6 ++- lib/models/SOAP/my_selected_examination.dart | 11 ++++- lib/models/SOAP/my_selected_history.dart | 5 ++- .../assessment/update_assessment_page.dart | 2 +- .../objective/update_objective_page.dart | 22 +++------- .../soap_update/plan/update_plan_page.dart | 6 ++- .../allergies/update_allergies_widget.dart | 11 +++-- .../history/update_history_widget.dart | 17 +++++-- .../subjective/update_subjective_page.dart | 44 ++++++++++--------- .../soap_update/update_soap_index.dart | 2 - 11 files changed, 74 insertions(+), 56 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 6b209e4e..1f51c81c 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/models/SOAP/my_selected_allergy.dart b/lib/models/SOAP/my_selected_allergy.dart index c4e52af7..66234db3 100644 --- a/lib/models/SOAP/my_selected_allergy.dart +++ b/lib/models/SOAP/my_selected_allergy.dart @@ -6,6 +6,7 @@ class MySelectedAllergy { String remark; bool isChecked; bool isExpanded; + bool isLocal; int createdBy; MySelectedAllergy( @@ -13,7 +14,8 @@ class MySelectedAllergy { this.selectedAllergy, this.remark, this.isChecked, - this.isExpanded = true, + this.isExpanded = true, + this.isLocal = true, this.createdBy}); MySelectedAllergy.fromJson(Map json) { @@ -26,6 +28,7 @@ class MySelectedAllergy { remark = json['remark']; isChecked = json['isChecked']; isExpanded = json['isExpanded']; + isLocal = json['isLocal']; createdBy = json['createdBy']; } @@ -41,6 +44,7 @@ class MySelectedAllergy { data['isChecked'] = this.isChecked; data['isExpanded'] = this.isExpanded; data['createdBy'] = this.createdBy; + data['isLocal'] = this.isLocal; return data; } } diff --git a/lib/models/SOAP/my_selected_examination.dart b/lib/models/SOAP/my_selected_examination.dart index 393af944..c791b7cb 100644 --- a/lib/models/SOAP/my_selected_examination.dart +++ b/lib/models/SOAP/my_selected_examination.dart @@ -8,6 +8,8 @@ class MySelectedExamination { bool notExamined; bool isNew; int createdBy; + String createdOn; + String editedOn; MySelectedExamination( {this.selectedExamination, @@ -16,7 +18,9 @@ class MySelectedExamination { this.isAbnormal = false, this.notExamined = true, this.isNew = true, - this.createdBy}); + this.createdBy, this.createdOn, + + this.editedOn,}); MySelectedExamination.fromJson(Map json) { selectedExamination = json['selectedExamination'] != null @@ -28,6 +32,8 @@ class MySelectedExamination { notExamined = json['notExamined']; isNew = json['isNew']; createdBy = json['createdBy']; + createdOn = json['createdOn']; + editedOn = json['editedOn']; } Map toJson() { @@ -42,6 +48,9 @@ class MySelectedExamination { data['notExamined'] = this.notExamined; data['isNew'] = this.isNew; data['createdBy'] = this.createdBy; + data['createdOn'] = this.createdOn; + data['editedOn'] = this.editedOn; + return data; } } diff --git a/lib/models/SOAP/my_selected_history.dart b/lib/models/SOAP/my_selected_history.dart index 11e366c2..91f66910 100644 --- a/lib/models/SOAP/my_selected_history.dart +++ b/lib/models/SOAP/my_selected_history.dart @@ -4,9 +4,10 @@ class MySelectedHistory { MasterKeyModel selectedHistory; String remark; bool isChecked; + bool isLocal; MySelectedHistory( - { this.selectedHistory, this.remark, this.isChecked}); + { this.selectedHistory, this.remark, this.isChecked, this.isLocal = true}); MySelectedHistory.fromJson(Map json) { @@ -15,6 +16,7 @@ class MySelectedHistory { : null; remark = json['remark']; remark = json['isChecked']; + isLocal = json['isLocal']; } Map toJson() { @@ -25,6 +27,7 @@ class MySelectedHistory { } data['remark'] = this.remark; data['isChecked'] = this.remark; + data['isLocal'] = this.isLocal; return data; } } 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 fab69c44..a2177eb7 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 @@ -55,7 +55,7 @@ class _UpdateAssessmentPageState extends State { episodeID: widget.patientInfo.episodeNo.toString(), editedBy: '', doctorID: '', - appointmentNo: int.parse(widget.patientInfo.appointmentNo)); + appointmentNo: int.parse(widget.patientInfo.appointmentNo.toString())); await model.getPatientAssessment(getAssessmentReqModel); if (model.patientAssessmentList.isNotEmpty) { if (model.listOfDiagnosisCondition.length == 0) { 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 4d36f49f..12004934 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 @@ -83,9 +83,11 @@ class _UpdateObjectivePageState extends State { remark: element.remarks, isNormal: element.isNormal, createdBy: element.createdBy, + createdOn:element.createdOn , + editedOn: element.editedOn, notExamined: element.notExamined, isNew: element.isNew, - isAbnormal: element.isAbnormal); + isAbnormal: element.isAbnormal,); widget.mySelectedExamination.add(tempEam); }); } @@ -213,7 +215,8 @@ class _UpdateObjectivePageState extends State { appointmentNo: widget.patientInfo.appointmentNo, remarks: exam.remark ?? '', createdBy: exam.createdBy ?? doctorProfile.doctorID, - createdOn: DateTime.now().toIso8601String(), + createdOn: exam.createdOn?? + DateTime.now().toIso8601String(), editedBy: doctorProfile.doctorID, editedOn: DateTime.now().toIso8601String(), examId: exam.selectedExamination.id, @@ -276,21 +279,6 @@ class _UpdateObjectivePageState extends State { removeExamination: (masterKey) => removeExamination(masterKey)), ), ); - /*showModalBottomSheet( - backgroundColor: Colors.white, - isScrollControlled: true, - context: context, - builder: (context) { - return AddExaminationDailog( - mySelectedExamination: widget.mySelectedExamination, - addSelectedExamination: () { - setState(() { - Navigator.of(context).pop(); - }); - }, - removeExamination: (masterKey) => removeExamination(masterKey), - ); - });*/ } } diff --git a/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart b/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart index 1960ef72..d9d61835 100644 --- a/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart +++ b/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart @@ -74,7 +74,7 @@ class _UpdatePlanPageState extends State { return BaseView( onModelReady: (model) async { GetGetProgressNoteReqModel getGetProgressNoteReqModel = GetGetProgressNoteReqModel( - appointmentNo: int.parse(widget.patientInfo.appointmentNo), + appointmentNo: int.parse(widget.patientInfo.appointmentNo.toString()), patientMRN: widget.patientInfo.patientMRN, episodeID: widget.patientInfo.episodeNo.toString(), editedBy: '', @@ -88,6 +88,8 @@ class _UpdatePlanPageState extends State { widget.patientProgressNote.createdOn = model.patientProgressNoteList[0].createdOn; widget.patientProgressNote.editedOn = model.patientProgressNoteList[0].editedOn; widget.patientProgressNote.editedByName = model.patientProgressNoteList[0].editedByName; + widget.patientProgressNote.appointmentNo = model.patientProgressNoteList[0].appointmentNo; + setState(() { isAddProgress = false; }); @@ -158,7 +160,7 @@ class _UpdatePlanPageState extends State { fontSize: 12, ), AppText( - widget.patientProgressNote.appointmentNo ?? '', + widget.patientProgressNote.appointmentNo.toString() ?? '', fontWeight: FontWeight.w600, ), ], diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart index 6f7439e6..1083ed48 100644 --- a/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart @@ -153,13 +153,15 @@ class _UpdateAllergiesWidgetState extends State { ).toList(); if (allergy.length > 0) { + if(allergy.first.isLocal) { + setState(() { + widget.myAllergiesList.remove(allergy.first); + }); + } setState(() { allergy[0].isChecked = false; }); } - - - print(allergy); } openAllergiesList(BuildContext context, Function changeParentState) { @@ -180,7 +182,8 @@ class _UpdateAllergiesWidgetState extends State { }); if (isAllDataFilled) { mySelectedAllergy.forEach((element) { - if (!widget.myAllergiesList.contains(element.selectedAllergySeverity.id)) { + if ((widget.myAllergiesList.singleWhere((it) => it.selectedAllergy.id == element.selectedAllergy.id, + orElse: () => null)) == null) { widget.myAllergiesList.add(element); } }); 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 f114702d..3b431a69 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 @@ -123,10 +123,19 @@ class _UpdateHistoryWidgetState extends State ).toList(); - if (history.length > 0) - setState(() { - history[0].isChecked = false; - }); + if (history.length > 0) { + if(history.first.isLocal) { + setState(() { + widget.myHistoryList.remove(history.first); + }); + } else { + setState(() { + history[0].isChecked = false; + }); + } + + } + } openHistoryList(BuildContext context) { diff --git a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart index 1b6cd274..12db7266 100644 --- a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -30,16 +30,12 @@ import 'history/update_history_widget.dart'; class UpdateSubjectivePage extends StatefulWidget { final Function changePageViewIndex; final Function changeLoadingState; - final List myAllergiesList; - final List myHistoryList; final PatiantInformtion patientInfo; final int currentIndex; UpdateSubjectivePage( {Key key, this.changePageViewIndex, - this.myAllergiesList, - this.myHistoryList, this.patientInfo, this.changeLoadingState, this.currentIndex}); @@ -59,6 +55,8 @@ class _UpdateSubjectivePageState extends State { String medicationControllerError = ''; String illnessControllerError = ''; final formKey = GlobalKey(); + List myAllergiesList=List(); + List myHistoryList=List(); getHistory(SOAPViewModel model) async { widget.changeLoadingState(true); @@ -93,9 +91,9 @@ class _UpdateSubjectivePageState extends State { ); if (history != null) { MySelectedHistory mySelectedHistory = - MySelectedHistory(selectedHistory: history, isChecked: element.isChecked, remark: element.remarks); + MySelectedHistory(selectedHistory: history, isChecked: element.isChecked, remark: element.remarks,isLocal: false); - widget.myHistoryList.add(mySelectedHistory); + myHistoryList.add(mySelectedHistory); } } if (element.historyType == MasterKeysService.HistoryMedical.getMasterKeyService()) { @@ -105,9 +103,9 @@ class _UpdateSubjectivePageState extends State { ); if (history != null) { MySelectedHistory mySelectedHistory = - MySelectedHistory(selectedHistory: history, isChecked: element.isChecked, remark: element.remarks); + MySelectedHistory(selectedHistory: history, isChecked: element.isChecked, remark: element.remarks,isLocal: false); - widget.myHistoryList.add(mySelectedHistory); + myHistoryList.add(mySelectedHistory); } } if (element.historyType == MasterKeysService.HistorySports.getMasterKeyService()) { @@ -117,9 +115,9 @@ class _UpdateSubjectivePageState extends State { ); if (history != null) { MySelectedHistory mySelectedHistory = - MySelectedHistory(selectedHistory: history, isChecked: element.isChecked, remark: element.remarks); + MySelectedHistory(selectedHistory: history, isChecked: element.isChecked, remark: element.remarks,isLocal: false); - widget.myHistoryList.add(mySelectedHistory); + myHistoryList.add(mySelectedHistory); } } if (element.historyType == MasterKeysService.HistorySurgical.getMasterKeyService()) { @@ -129,9 +127,9 @@ class _UpdateSubjectivePageState extends State { ); if (history != null) { MySelectedHistory mySelectedHistory = - MySelectedHistory(selectedHistory: history, isChecked: element.isChecked, remark: element.remarks); + MySelectedHistory(selectedHistory: history, isChecked: element.isChecked, remark: element.remarks,isLocal: false); - widget.myHistoryList.add(mySelectedHistory); + myHistoryList.add(mySelectedHistory); } } }); @@ -169,8 +167,9 @@ class _UpdateSubjectivePageState extends State { isChecked: element.isChecked, createdBy: element.createdBy, remark: element.remarks, + isLocal : false, selectedAllergySeverity: selectedAllergySeverity); - if (selectedAllergy != null && selectedAllergySeverity != null) widget.myAllergiesList.add(mySelectedAllergy); + if (selectedAllergy != null && selectedAllergySeverity != null) myAllergiesList.add(mySelectedAllergy); }); } } @@ -179,8 +178,8 @@ class _UpdateSubjectivePageState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) async { - widget.myAllergiesList.clear(); - widget.myHistoryList.clear(); + myAllergiesList.clear(); + myHistoryList.clear(); GetChiefComplaintReqModel getChiefComplaintReqModel = GetChiefComplaintReqModel( patientMRN: widget.patientInfo.patientMRN, @@ -246,7 +245,7 @@ class _UpdateSubjectivePageState extends State { }); }, child: Column( - children: [UpdateHistoryWidget(myHistoryList: widget.myHistoryList)], + children: [UpdateHistoryWidget(myHistoryList: myHistoryList)], ), isExpanded: isHistoryExpand, ), @@ -264,7 +263,7 @@ class _UpdateSubjectivePageState extends State { child: Column( children: [ UpdateAllergiesWidget( - myAllergiesList: widget.myAllergiesList, + myAllergiesList: myAllergiesList, ), SizedBox( height: 30, @@ -304,10 +303,10 @@ class _UpdateSubjectivePageState extends State { title: TranslationBase.of(context).next, fontWeight: FontWeight.w600, color: Colors.red[700], - loading: model.state == ViewState.BusyLocal, + // loading: model.state == ViewState.BusyLocal, onPressed: () async { addSubjectiveInfo( - model: model, myAllergiesList: widget.myAllergiesList, myHistoryList: widget.myHistoryList); + model: model, myAllergiesList: myAllergiesList, myHistoryList: myHistoryList); }, ), ), @@ -325,6 +324,7 @@ class _UpdateSubjectivePageState extends State { addSubjectiveInfo( {SOAPViewModel model, List myAllergiesList, List myHistoryList}) async { + widget.changeLoadingState(true); formKey.currentState.save(); formKey.currentState.validate(); @@ -370,6 +370,8 @@ class _UpdateSubjectivePageState extends State { medicationControllerError = TranslationBase.of(context).emptyMessage; } }); + + widget.changeLoadingState(false); Helpers.showErrorToast(TranslationBase.of(context).chiefComplaintErrorMsg); } } @@ -380,7 +382,7 @@ class _UpdateSubjectivePageState extends State { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - widget.myAllergiesList.forEach((allergy) { + myAllergiesList.forEach((allergy) { if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == null) postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add(ListHisProgNotePatientAllergyDiseaseVM( @@ -419,7 +421,7 @@ class _UpdateSubjectivePageState extends State { postHistories({List myHistoryList, SOAPViewModel model}) async { PostHistoriesRequestModel postHistoriesRequestModel = new PostHistoriesRequestModel(doctorID: ''); - widget.myHistoryList.forEach((history) { + myHistoryList.forEach((history) { if (postHistoriesRequestModel.listMedicalHistoryVM == null) postHistoriesRequestModel.listMedicalHistoryVM = []; postHistoriesRequestModel.listMedicalHistoryVM.add(ListMedicalHistoryVM( patientMRN: widget.patientInfo.patientMRN, diff --git a/lib/screens/patients/profile/soap_update/update_soap_index.dart b/lib/screens/patients/profile/soap_update/update_soap_index.dart index 60597b11..fd4e8791 100644 --- a/lib/screens/patients/profile/soap_update/update_soap_index.dart +++ b/lib/screens/patients/profile/soap_update/update_soap_index.dart @@ -105,8 +105,6 @@ class _UpdateSoapIndexState extends State UpdateSubjectivePage( changePageViewIndex: changePageViewIndex, currentIndex: _currentIndex, - myAllergiesList: myAllergiesList, - myHistoryList: myHistoryList, patientInfo: patient, changeLoadingState: changeLoadingState), UpdateObjectivePage( From 993a266d4ffab748f3c89105922e4de7ffbfc789 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 8 Jul 2021 14:17:20 +0300 Subject: [PATCH 02/13] fix first step from fixes soap --- .../allergies/update_allergies_widget.dart | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart index 1083ed48..cb7d7d00 100644 --- a/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart @@ -37,7 +37,7 @@ class _UpdateAllergiesWidgetState extends State { SOAPOpenItems(label: "${TranslationBase.of(context).addAllergies}",onTap: () { - openAllergiesList(context, changeAllState); + openAllergiesList(context, changeAllState, removeAllergy); },), SizedBox( height: 20, @@ -164,7 +164,7 @@ class _UpdateAllergiesWidgetState extends State { } } - openAllergiesList(BuildContext context, Function changeParentState) { + openAllergiesList(BuildContext context, Function changeParentState, removeAllergy) { showModalBottomSheet( backgroundColor: Colors.white, isScrollControlled: true, @@ -173,6 +173,7 @@ class _UpdateAllergiesWidgetState extends State { builder: (context) { return AddAllergies( myAllergiesList: widget.myAllergiesList, + addAllergiesFun: (List mySelectedAllergy) { bool isAllDataFilled = true; mySelectedAllergy.forEach((element) { @@ -187,6 +188,20 @@ class _UpdateAllergiesWidgetState extends State { widget.myAllergiesList.add(element); } }); + + /// remove items. + List removedList= []; + widget.myAllergiesList.forEach((element) { + if ((mySelectedAllergy.singleWhere((it) => it.selectedAllergy.id == element.selectedAllergy.id, + orElse: () => null)) == null) { + removedList.add(element); + }}); + + removedList.forEach((element) { + removeAllergy(element); + }); + + changeParentState(); Navigator.of(context).pop(); } else { From c69f122713f05ab93645e5a5ea133e0d3791f37f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 8 Jul 2021 16:31:35 +0300 Subject: [PATCH 03/13] prevent passing data and first step from refactor examinations --- lib/models/SOAP/my_selected_examination.dart | 31 +-- .../assessment/update_assessment_page.dart | 18 +- .../objective/add_examination_page.dart | 133 ++++++------ .../objective/add_examination_widget.dart | 191 ++++++++++-------- .../objective/examination_item_card.dart | 20 +- .../examinations_list_search_widget.dart | 16 +- .../objective/update_objective_page.dart | 173 +++++++++------- .../soap_update/plan/update_plan_page.dart | 49 ++--- .../subjective/update_subjective_page.dart | 1 - .../soap_update/update_soap_index.dart | 7 - 10 files changed, 337 insertions(+), 302 deletions(-) diff --git a/lib/models/SOAP/my_selected_examination.dart b/lib/models/SOAP/my_selected_examination.dart index c791b7cb..6a3ecf99 100644 --- a/lib/models/SOAP/my_selected_examination.dart +++ b/lib/models/SOAP/my_selected_examination.dart @@ -1,26 +1,29 @@ import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; class MySelectedExamination { - MasterKeyModel selectedExamination; + MasterKeyModel selectedExamination; String remark; bool isNormal; bool isAbnormal; bool notExamined; bool isNew; + bool isLocal; int createdBy; - String createdOn; - String editedOn; + String createdOn; + String editedOn; - MySelectedExamination( - {this.selectedExamination, - this.remark, - this.isNormal = false, - this.isAbnormal = false, - this.notExamined = true, - this.isNew = true, - this.createdBy, this.createdOn, - - this.editedOn,}); + MySelectedExamination({ + this.selectedExamination, + this.remark, + this.isNormal = false, + this.isAbnormal = false, + this.notExamined = true, + this.isNew = true, + this.isLocal = true, + this.createdBy, + this.createdOn, + this.editedOn, + }); MySelectedExamination.fromJson(Map json) { selectedExamination = json['selectedExamination'] != null @@ -34,6 +37,7 @@ class MySelectedExamination { createdBy = json['createdBy']; createdOn = json['createdOn']; editedOn = json['editedOn']; + isLocal = json['isLocal']; } Map toJson() { @@ -50,6 +54,7 @@ class MySelectedExamination { data['createdBy'] = this.createdBy; data['createdOn'] = this.createdOn; data['editedOn'] = this.editedOn; + data['isLocal'] = this.isLocal; return data; } 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 a2177eb7..1ab96170 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 @@ -26,14 +26,12 @@ import 'add_assessment_details.dart'; // ignore: must_be_immutable class UpdateAssessmentPage extends StatefulWidget { final Function changePageViewIndex; - List mySelectedAssessmentList; final PatiantInformtion patientInfo; final Function changeLoadingState; final int currentIndex; UpdateAssessmentPage( {Key key, this.changePageViewIndex, - this.mySelectedAssessmentList, this.patientInfo, this.changeLoadingState, this.currentIndex}); @@ -43,13 +41,14 @@ class UpdateAssessmentPage extends StatefulWidget { class _UpdateAssessmentPageState extends State { bool isAssessmentExpand = false; + List mySelectedAssessmentList = List(); @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) async { - widget.mySelectedAssessmentList.clear(); + mySelectedAssessmentList.clear(); GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( patientMRN: widget.patientInfo.patientMRN, episodeID: widget.patientInfo.episodeNo.toString(), @@ -96,7 +95,7 @@ class _UpdateAssessmentPageState extends State { createdOn: element.createdOn, icdCode10ID: element.icdCode10ID); - widget.mySelectedAssessmentList.add(temMySelectedAssessment); + mySelectedAssessmentList.add(temMySelectedAssessment); } }); } @@ -147,7 +146,7 @@ class _UpdateAssessmentPageState extends State { height: 20, ), Column( - children: widget.mySelectedAssessmentList + children: mySelectedAssessmentList .map((assessment) { return Container( margin: EdgeInsets.only( @@ -501,14 +500,15 @@ class _UpdateAssessmentPageState extends State { color: Colors.red[700], disabled: model.state == ViewState.BusyLocal, onPressed: () async { - if (widget.mySelectedAssessmentList.isEmpty) { + if (mySelectedAssessmentList.isEmpty) { Helpers.showErrorToast( TranslationBase .of(context) .assessmentErrorMsg); } else { - widget.changePageViewIndex(3); widget.changeLoadingState(true); + widget.changePageViewIndex(3); + } }, ), @@ -542,11 +542,11 @@ class _UpdateAssessmentPageState extends State { mySelectedAssessment: assessment, patientInfo: widget.patientInfo, isUpdate: isUpdate, - mySelectedAssessmentList: widget.mySelectedAssessmentList, + mySelectedAssessmentList: mySelectedAssessmentList, addSelectedAssessment: (MySelectedAssessment mySelectedAssessment, bool isUpdate) async { setState(() { - widget.mySelectedAssessmentList.add(mySelectedAssessment); + mySelectedAssessmentList.add(mySelectedAssessment); }); }); }); 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 index d98e17be..659de693 100644 --- a/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart @@ -31,79 +31,80 @@ 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, + 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: [ - Expanded( - child: AppText( - "${TranslationBase.of(context).addExamination}", - fontSize: SizeConfig.textMultiplier * 3.3, - color: Colors.black, - fontWeight: FontWeight.w700, + 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, + ), + ) + ], ), ), - 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, - )), - ), + Expanded( + child: SingleChildScrollView( 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( + 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( + mySelectedExamination: + widget.mySelectedExamination, + masterList: model.physicalExaminationList, + isServiceSelected: (master) => + isServiceSelected(master), + removeExamination: (history) { + setState(() { + widget.removeExamination(history); }); }, + addExamination: (selectedExamination) { + widget.mySelectedExamination + .add(selectedExamination); + // setState(() {}); + }, ), ], ), diff --git a/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart b/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart index e990be79..5b5bfcb1 100644 --- a/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart @@ -14,19 +14,21 @@ import 'package:provider/provider.dart'; // ignore: must_be_immutable class AddExaminationWidget extends StatefulWidget { MasterKeyModel item; - final Function(MasterKeyModel) removeHistory; - final Function(MySelectedExamination) addHistory; + final Function(MasterKeyModel) removeExamination; + final Function(MySelectedExamination) addExamination; final bool Function(MasterKeyModel) isServiceSelected; bool isExpand; final Function expandClick; + final List mySelectedExamination; AddExaminationWidget({ this.item, - this.removeHistory, - this.addHistory, + this.removeExamination, + this.addExamination, this.isServiceSelected, this.isExpand, this.expandClick, + this.mySelectedExamination, }); @override @@ -40,7 +42,17 @@ class _AddExaminationWidgetState extends State { @override void initState() { - examination.selectedExamination = widget.item; + if (getSelectedExam(widget.item) != null) { + examination = getSelectedExam(widget.item); + status = examination.isNormal + ? 1 + : examination.isAbnormal + ? 2 + : 3; + remarksController.text = examination.remark; + } else { + examination.selectedExamination = widget.item; + } super.initState(); } @@ -70,14 +82,15 @@ class _AddExaminationWidgetState extends State { onChanged: (newValue) { setState(() { if (widget.isServiceSelected(widget.item)) { - widget.removeHistory(widget.item); + if (!examination.isLocal) + widget.removeExamination(widget.item); widget.expandClick(); } else { examination.isNormal = status == 1; examination.isAbnormal = status == 2; examination.notExamined = status == 3; examination.remark = remarksController.text; - widget.addHistory(examination); + widget.addExamination(examination); widget.expandClick(); } }); @@ -113,18 +126,18 @@ class _AddExaminationWidgetState extends State { Row( children: [ Expanded( - child: Row( - children: [ - InkWell( - onTap: () { - setState(() { - status = 1; - }); - examination.isNormal = true; - examination.isAbnormal = false; - examination.notExamined = false; - }, - child: Container( + child: InkWell( + onTap: () { + setState(() { + status = 1; + }); + examination.isNormal = true; + examination.isAbnormal = false; + examination.notExamined = false; + }, + child: Row( + children: [ + Container( padding: EdgeInsets.all(2.0), margin: EdgeInsets.symmetric(horizontal: 6), width: 20, @@ -143,28 +156,28 @@ class _AddExaminationWidgetState extends State { ), ), ), - ), - AppText( - TranslationBase.of(context).normal, - fontWeight: FontWeight.normal, - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 1.6, - ), - ], + AppText( + TranslationBase.of(context).normal, + fontWeight: FontWeight.normal, + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 1.6, + ), + ], + ), )), Expanded( - child: Row( - children: [ - InkWell( - onTap: () { - setState(() { - status = 2; - }); - examination.isNormal = false; - examination.isAbnormal = true; - examination.notExamined = false; - }, - child: Container( + child: InkWell( + onTap: () { + setState(() { + status = 2; + }); + examination.isNormal = false; + examination.isAbnormal = true; + examination.notExamined = false; + }, + child: Row( + children: [ + Container( padding: EdgeInsets.all(2.0), margin: EdgeInsets.symmetric(horizontal: 6), width: 20, @@ -183,57 +196,58 @@ class _AddExaminationWidgetState extends State { ), ), ), - ), - AppText( - TranslationBase.of(context).abnormal, - fontWeight: FontWeight.normal, - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 1.6, - ), - ], + AppText( + TranslationBase.of(context).abnormal, + fontWeight: FontWeight.normal, + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 1.6, + ), + ], + ), )), - Expanded( + if (!examination.isLocal) + Expanded( + child: InkWell( + onTap: () { + setState(() { + status = 3; + }); + examination.isNormal = false; + examination.isAbnormal = false; + examination.notExamined = true; + }, child: Row( - children: [ - InkWell( - onTap: () { - setState(() { - status = 3; - }); - examination.isNormal = false; - examination.isAbnormal = false; - examination.notExamined = true; - }, - child: Container( - padding: EdgeInsets.all(2.0), - margin: EdgeInsets.symmetric(horizontal: 6), - width: 20, - height: 20, - decoration: BoxDecoration( - color: Colors.white, - shape: BoxShape.circle, - border: Border.all(color: Colors.grey, width: 1), - ), - child: Container( + children: [ + Container( + padding: EdgeInsets.all(2.0), + margin: EdgeInsets.symmetric(horizontal: 6), + width: 20, + height: 20, decoration: BoxDecoration( - color: status == 3 - ? HexColor("#D02127") - : Colors.white, + color: Colors.white, shape: BoxShape.circle, + border: Border.all(color: Colors.grey, width: 1), + ), + child: Container( + decoration: BoxDecoration( + color: status == 3 + ? HexColor("#D02127") + : Colors.white, + shape: BoxShape.circle, + ), ), ), - ), - ), - Expanded( - child: AppText( - TranslationBase.of(context).notExamined, - fontWeight: FontWeight.normal, - fontFamily: 'Poppins', - fontSize: SizeConfig.textMultiplier * 1.6, - ), + Expanded( + child: AppText( + TranslationBase.of(context).notExamined, + fontWeight: FontWeight.normal, + fontFamily: 'Poppins', + fontSize: SizeConfig.textMultiplier * 1.6, + ), + ), + ], ), - ], - )), + )), ], ), Container( @@ -256,4 +270,15 @@ class _AddExaminationWidgetState extends State { ), ); } + + MySelectedExamination getSelectedExam(MasterKeyModel masterKey) { + Iterable exam = widget.mySelectedExamination.where( + (element) => + masterKey.id == element.selectedExamination.id && + masterKey.typeId == element.selectedExamination.typeId); + if (exam.length > 0) { + return exam.first; + } + return null; + } } 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 index d40faea5..5116ac6b 100644 --- a/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart +++ b/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart @@ -40,25 +40,6 @@ class ExaminationItemCard extends StatelessWidget { fontSize: SizeConfig.textMultiplier * 1.8, ), )), - Row( - children: [ - AppText( - TranslationBase.of(context).remove, - fontWeight: FontWeight.w600, - fontFamily: 'Poppins', - color: Colors.red.shade800, - fontSize: SizeConfig.textMultiplier * 1.8, - ), - InkWell( - onTap: removeExamination, - child: Icon( - Icons.clear, - size: 20, - color: Colors.red.shade800, - ), - ) - ], - ), ], ), AppText( @@ -79,6 +60,7 @@ class ExaminationItemCard extends StatelessWidget { SizedBox( height: 4, ), + if(examination.remark.isEmpty) AppText( examination.remark, fontWeight: FontWeight.normal, 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 index 36b65d4c..ef6ec056 100644 --- 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 @@ -8,16 +8,17 @@ import 'package:flutter/material.dart'; import 'add_examination_widget.dart'; class ExaminationsListSearchWidget extends StatefulWidget { - final Function(MasterKeyModel) removeHistory; - final Function(MySelectedExamination) addHistory; + final Function(MasterKeyModel) removeExamination; + final Function(MySelectedExamination) addExamination; final bool Function(MasterKeyModel) isServiceSelected; final List masterList; + final List mySelectedExamination; ExaminationsListSearchWidget( - {this.removeHistory, - this.addHistory, + {this.removeExamination, + this.addExamination, this.isServiceSelected, - this.masterList}); + this.masterList, this.mySelectedExamination}); @override _ExaminationsListSearchWidgetState createState() => @@ -61,8 +62,9 @@ class _ExaminationsListSearchWidgetState ...items.mapIndexed((index, item) { return AddExaminationWidget( item: item, - addHistory: widget.addHistory, - removeHistory: widget.removeHistory, + addExamination: widget.addExamination, + removeExamination: widget.removeExamination, + mySelectedExamination: widget.mySelectedExamination, isServiceSelected: widget.isServiceSelected, isExpand: index == expandedIndex, expandClick: () { 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 12004934..bd6cd39d 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 @@ -28,13 +28,11 @@ class UpdateObjectivePage extends StatefulWidget { final Function changePageViewIndex; final Function changeLoadingState; final int currentIndex; - final List mySelectedExamination; final PatiantInformtion patientInfo; UpdateObjectivePage( {Key key, this.changePageViewIndex, - this.mySelectedExamination, this.patientInfo, this.changeLoadingState, this.currentIndex}); @@ -45,8 +43,10 @@ class UpdateObjectivePage extends StatefulWidget { class _UpdateObjectivePageState extends State { bool isSysExaminationExpand = false; + List mySelectedExamination = List(); - BoxDecoration containerBorderDecoration(Color containerColor, Color borderColor) { + BoxDecoration containerBorderDecoration( + Color containerColor, Color borderColor) { return BoxDecoration( color: containerColor, shape: BoxShape.rectangle, @@ -62,11 +62,13 @@ class _UpdateObjectivePageState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) async { - widget.mySelectedExamination.clear(); - GetPhysicalExamReqModel getPhysicalExamReqModel = GetPhysicalExamReqModel( - patientMRN: widget.patientInfo.patientMRN, - episodeID: widget.patientInfo.episodeNo.toString(), - appointmentNo: int.parse(widget.patientInfo.appointmentNo.toString())); + mySelectedExamination.clear(); + GetPhysicalExamReqModel getPhysicalExamReqModel = + GetPhysicalExamReqModel( + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString(), + appointmentNo: + int.parse(widget.patientInfo.appointmentNo.toString())); await model.getPatientPhysicalExam(getPhysicalExamReqModel); if (model.patientPhysicalExamList.isNotEmpty) { @@ -79,16 +81,18 @@ class _UpdateObjectivePageState extends State { id: element.examId, ); MySelectedExamination tempEam = MySelectedExamination( - selectedExamination: examMaster, - remark: element.remarks, - isNormal: element.isNormal, - createdBy: element.createdBy, - createdOn:element.createdOn , + selectedExamination: examMaster, + remark: element.remarks, + isNormal: element.isNormal, + createdBy: element.createdBy, + createdOn: element.createdOn, editedOn: element.editedOn, - notExamined: element.notExamined, - isNew: element.isNew, - isAbnormal: element.isAbnormal,); - widget.mySelectedExamination.add(tempEam); + notExamined: element.notExamined, + isNew: element.isNew, + isLocal: false, + isAbnormal: element.isAbnormal, + ); + mySelectedExamination.add(tempEam); }); } @@ -104,9 +108,12 @@ class _UpdateObjectivePageState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - SOAPStepHeader(currentIndex: widget.currentIndex, changePageViewIndex: widget.changePageViewIndex), + SOAPStepHeader( + currentIndex: widget.currentIndex, + changePageViewIndex: widget.changePageViewIndex), ExpandableSOAPWidget( - headerTitle: TranslationBase.of(context).physicalSystemExamination, + headerTitle: + TranslationBase.of(context).physicalSystemExamination, onTap: () { setState(() { isSysExaminationExpand = !isSysExaminationExpand; @@ -115,15 +122,17 @@ class _UpdateObjectivePageState extends State { child: Column( children: [ SOAPOpenItems( - label: "${TranslationBase.of(context).addExamination}", + label: + "${TranslationBase.of(context).addExamination}", onTap: () { openExaminationList(context); }, ), Column( - children: widget.mySelectedExamination.map((examination) { + children: mySelectedExamination.map((examination) { return ExaminationItemCard(examination, () { - removeExamination(examination.selectedExamination); + removeExamination( + examination.selectedExamination); }); }).toList(), ) @@ -200,41 +209,45 @@ class _UpdateObjectivePageState extends State { } submitUpdateObjectivePage(SOAPViewModel model) async { - if (widget.mySelectedExamination.isNotEmpty) { + if (mySelectedExamination.isNotEmpty) { + widget.changeLoadingState(true); Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - PostPhysicalExamRequestModel postPhysicalExamRequestModel = new PostPhysicalExamRequestModel(); - widget.mySelectedExamination.forEach((exam) { - if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == null) - postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = []; + PostPhysicalExamRequestModel postPhysicalExamRequestModel = + new PostPhysicalExamRequestModel(); + mySelectedExamination.forEach((exam) { + if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == + null) + postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = + []; - postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM.add(ListHisProgNotePhysicalExaminationVM( - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - remarks: exam.remark ?? '', - createdBy: exam.createdBy ?? doctorProfile.doctorID, - createdOn: exam.createdOn?? - DateTime.now().toIso8601String(), - editedBy: doctorProfile.doctorID, - editedOn: DateTime.now().toIso8601String(), - examId: exam.selectedExamination.id, - examType: exam.selectedExamination.typeId, - isAbnormal: exam.isAbnormal, - isNormal: exam.isNormal, - notExamined: exam.notExamined, - examinationType: exam.isNormal - ? 1 - : exam.isAbnormal - ? 2 - : 3, - examinationTypeName: exam.isNormal - ? "Normal" - : exam.isAbnormal - ? 'AbNormal' - : "Not Examined", - isNew: exam.isNew)); + postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM + .add(ListHisProgNotePhysicalExaminationVM( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + remarks: exam.remark ?? '', + createdBy: exam.createdBy ?? doctorProfile.doctorID, + createdOn: exam.createdOn ?? DateTime.now().toIso8601String(), + editedBy: doctorProfile.doctorID, + editedOn: DateTime.now().toIso8601String(), + examId: exam.selectedExamination.id, + examType: exam.selectedExamination.typeId, + isAbnormal: exam.isAbnormal, + isNormal: exam.isNormal, + notExamined: exam.notExamined, + examinationType: exam.isNormal + ? 1 + : exam.isAbnormal + ? 2 + : 3, + examinationTypeName: exam.isNormal + ? "Normal" + : exam.isAbnormal + ? 'AbNormal' + : "Not Examined", + isNew: exam.isNew)); }); if (model.patientPhysicalExamList.isEmpty) { @@ -244,11 +257,14 @@ class _UpdateObjectivePageState extends State { } if (model.state == ViewState.ErrorLocal) { + widget.changeLoadingState(false); Helpers.showErrorToast(model.error); } else { - widget.changeLoadingState(true); + widget.changeLoadingState(false); + // TODO Elham* return this + // widget.changeLoadingState(true); - widget.changePageViewIndex(2); + //widget.changePageViewIndex(2); } } else { Helpers.showErrorToast(TranslationBase.of(context).examinationErrorMsg); @@ -256,12 +272,14 @@ class _UpdateObjectivePageState extends State { } removeExamination(MasterKeyModel masterKey) { - Iterable history = widget.mySelectedExamination.where((element) => - masterKey.id == element.selectedExamination.id && masterKey.typeId == element.selectedExamination.typeId); + Iterable history = mySelectedExamination.where( + (element) => + masterKey.id == element.selectedExamination.id && + masterKey.typeId == element.selectedExamination.typeId); if (history.length > 0) setState(() { - widget.mySelectedExamination.remove(history.first); + mySelectedExamination.remove(history.first); }); } @@ -270,7 +288,7 @@ class _UpdateObjectivePageState extends State { context, FadePage( page: AddExaminationPage( - mySelectedExamination: widget.mySelectedExamination, + mySelectedExamination: mySelectedExamination, addSelectedExamination: () { setState(() { Navigator.of(context).pop(); @@ -287,7 +305,11 @@ class AddExaminationDailog extends StatefulWidget { final Function addSelectedExamination; final Function(MasterKeyModel) removeExamination; - const AddExaminationDailog({Key key, this.mySelectedExamination, this.addSelectedExamination, this.removeExamination}) + const AddExaminationDailog( + {Key key, + this.mySelectedExamination, + this.addSelectedExamination, + this.removeExamination}) : super(key: key); @override @@ -302,7 +324,8 @@ class _AddExaminationDailogState extends State { child: BaseView( onModelReady: (model) async { if (model.physicalExaminationList.length == 0) { - await model.getMasterLookup(MasterKeysService.PhysicalExamination); + await model + .getMasterLookup(MasterKeysService.PhysicalExamination); } }, builder: (_, model, w) => AppScaffold( @@ -312,19 +335,21 @@ class _AddExaminationDailogState extends State { child: Container( child: FractionallySizedBox( widthFactor: 0.9, - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox( - height: 16, - ), - AppText( - TranslationBase.of(context).physicalSystemExamination, - fontWeight: FontWeight.bold, - fontSize: 16, - ), - SizedBox( - height: 16, - ), - ]), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 16, + ), + AppText( + TranslationBase.of(context).physicalSystemExamination, + fontWeight: FontWeight.bold, + fontSize: 16, + ), + SizedBox( + height: 16, + ), + ]), ))), )), ); diff --git a/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart b/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart index d9d61835..114b73d2 100644 --- a/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart +++ b/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart @@ -27,14 +27,12 @@ class UpdatePlanPage extends StatefulWidget { final Function changeLoadingState; final int currentIndex; - GetPatientProgressNoteResModel patientProgressNote; UpdatePlanPage( {Key key, this.changePageViewIndex, this.patientInfo, this.changeLoadingState, - this.patientProgressNote, this.currentIndex}); @override @@ -44,6 +42,7 @@ class UpdatePlanPage extends StatefulWidget { class _UpdatePlanPageState extends State { bool isAddProgress = true; bool isProgressExpanded = true; + GetPatientProgressNoteResModel patientProgressNote =GetPatientProgressNoteResModel(); TextEditingController progressNoteController = TextEditingController(text: null); @@ -62,7 +61,7 @@ class _UpdatePlanPageState extends State { @override void initState() { super.initState(); - if (widget.patientProgressNote.planNote != null) { + if (patientProgressNote.planNote != null) { setState(() { isAddProgress = false; }); @@ -83,12 +82,12 @@ class _UpdatePlanPageState extends State { if (model.patientProgressNoteList.isNotEmpty) { progressNoteController.text = Helpers.parseHtmlString(model.patientProgressNoteList[0].planNote); - widget.patientProgressNote.planNote = progressNoteController.text; - widget.patientProgressNote.createdByName = model.patientProgressNoteList[0].createdByName; - widget.patientProgressNote.createdOn = model.patientProgressNoteList[0].createdOn; - widget.patientProgressNote.editedOn = model.patientProgressNoteList[0].editedOn; - widget.patientProgressNote.editedByName = model.patientProgressNoteList[0].editedByName; - widget.patientProgressNote.appointmentNo = model.patientProgressNoteList[0].appointmentNo; + patientProgressNote.planNote = progressNoteController.text; + patientProgressNote.createdByName = model.patientProgressNoteList[0].createdByName; + patientProgressNote.createdOn = model.patientProgressNoteList[0].createdOn; + patientProgressNote.editedOn = model.patientProgressNoteList[0].editedOn; + patientProgressNote.editedByName = model.patientProgressNoteList[0].editedByName; + patientProgressNote.appointmentNo = model.patientProgressNoteList[0].appointmentNo; setState(() { isAddProgress = false; @@ -133,14 +132,14 @@ class _UpdatePlanPageState extends State { maxLines: 4, inputType: TextInputType.multiline, onChanged: (value) { - widget.patientProgressNote.planNote = value; + patientProgressNote.planNote = value; }, ), ), SizedBox( height: 9, ), - if (widget.patientProgressNote.planNote != null && !isAddProgress) + if (patientProgressNote.planNote != null && !isAddProgress) Container( margin: EdgeInsets.only( left: 5, @@ -160,15 +159,15 @@ class _UpdatePlanPageState extends State { fontSize: 12, ), AppText( - widget.patientProgressNote.appointmentNo.toString() ?? '', + patientProgressNote.appointmentNo.toString() ?? '', fontWeight: FontWeight.w600, ), ], ), AppText( - widget.patientProgressNote.createdOn != null + patientProgressNote.createdOn != null ? AppDateUtils.getDayMonthYearDateFormatted( - DateTime.parse(widget.patientProgressNote.createdOn)) + DateTime.parse(patientProgressNote.createdOn)) : AppDateUtils.getDayMonthYearDateFormatted(DateTime.now()), fontWeight: FontWeight.w600, fontSize: 14, @@ -185,14 +184,14 @@ class _UpdatePlanPageState extends State { 'Condition: ', fontSize: 12, ), - AppText(widget.patientProgressNote.mName ?? '', + AppText(patientProgressNote.mName ?? '', fontWeight: FontWeight.w600), ], ), AppText( - widget.patientProgressNote.createdOn != null + patientProgressNote.createdOn != null ? AppDateUtils.getHour( - DateTime.parse(widget.patientProgressNote.createdOn)) + DateTime.parse(patientProgressNote.createdOn)) : AppDateUtils.getHour(DateTime.now()), fontWeight: FontWeight.w600, fontSize: 14, @@ -287,11 +286,11 @@ class _UpdatePlanPageState extends State { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); setState(() { - widget.patientProgressNote.createdByName = - widget.patientProgressNote.createdByName ?? doctorProfile.doctorName; - widget.patientProgressNote.editedByName = doctorProfile.doctorName; - widget.patientProgressNote.createdOn = DateTime.now().toString(); - widget.patientProgressNote.planNote = progressNoteController.text; + patientProgressNote.createdByName = + patientProgressNote.createdByName ?? doctorProfile.doctorName; + patientProgressNote.editedByName = doctorProfile.doctorName; + patientProgressNote.createdOn = DateTime.now().toString(); + patientProgressNote.planNote = progressNoteController.text; isAddProgress = !isAddProgress; }); submitPlan(model); @@ -320,11 +319,12 @@ class _UpdatePlanPageState extends State { submitPlan(SOAPViewModel model) async { if (progressNoteController.text.isNotEmpty) { + widget.changeLoadingState(true); PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( patientMRN: widget.patientInfo.patientMRN, episodeId: widget.patientInfo.episodeNo, appointmentNo: widget.patientInfo.appointmentNo, - planNote: widget.patientProgressNote.planNote, + planNote: patientProgressNote.planNote, doctorID: '', editedBy: ''); @@ -339,10 +339,13 @@ class _UpdatePlanPageState extends State { } if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); } else { widget.changePageViewIndex(4, isChangeState: false); } + + widget.changeLoadingState(false); } else { Helpers.showErrorToast(TranslationBase.of(context).progressNoteErrorMsg); } diff --git a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart index 12db7266..ade555ba 100644 --- a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -338,7 +338,6 @@ class _UpdateSubjectivePageState extends State { if (model.state == ViewState.ErrorLocal) { Helpers.showErrorToast(model.error); } - if (myHistoryList.length != 0) { await postHistories(model: model, myHistoryList: myHistoryList); if (model.state == ViewState.ErrorLocal) { diff --git a/lib/screens/patients/profile/soap_update/update_soap_index.dart b/lib/screens/patients/profile/soap_update/update_soap_index.dart index fd4e8791..883e19f0 100644 --- a/lib/screens/patients/profile/soap_update/update_soap_index.dart +++ b/lib/screens/patients/profile/soap_update/update_soap_index.dart @@ -31,11 +31,7 @@ class _UpdateSoapIndexState extends State int _currentIndex = 0; List myAllergiesList = List(); List myHistoryList = List(); - List mySelectedExamination = List(); - List mySelectedAssessment = List(); - GetPatientProgressNoteResModel patientProgressNote = - GetPatientProgressNoteResModel(); changePageViewIndex(pageIndex,{isChangeState = true}) { if (pageIndex != _currentIndex && isChangeState) @@ -110,20 +106,17 @@ class _UpdateSoapIndexState extends State UpdateObjectivePage( changePageViewIndex: changePageViewIndex, currentIndex: _currentIndex, - mySelectedExamination: mySelectedExamination, patientInfo: patient, changeLoadingState: changeLoadingState), UpdateAssessmentPage( changePageViewIndex: changePageViewIndex, currentIndex: _currentIndex, - mySelectedAssessmentList: mySelectedAssessment, patientInfo: patient, changeLoadingState: changeLoadingState), UpdatePlanPage( changePageViewIndex: changePageViewIndex, currentIndex: _currentIndex, patientInfo: patient, - patientProgressNote: patientProgressNote, changeLoadingState: changeLoadingState) ], ), From ac6a6e78552cf3d53e3a1a75f231942478f35a46 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 8 Jul 2021 17:31:46 +0300 Subject: [PATCH 04/13] keep show header in bottom sheet while it loading --- .../assessment/add_assessment_details.dart | 7 +- .../objective/add_examination_page.dart | 36 +-- .../objective/add_examination_widget.dart | 2 +- .../objective/examination_item_card.dart | 2 +- .../examinations_list_search_widget.dart | 6 +- .../objective/update_objective_page.dart | 7 +- .../bottom_sheet_title.dart | 5 +- .../subjective/allergies/add_allergies.dart | 174 +++++------ .../history/add_history_dialog.dart | 288 +++++++++--------- .../subjective/medication/add_medication.dart | 11 +- 10 files changed, 263 insertions(+), 275 deletions(-) diff --git a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart index a30842f8..8b9cf7b8 100644 --- a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart +++ b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart @@ -32,6 +32,7 @@ class AddAssessmentDetails extends StatefulWidget { addSelectedAssessment; final PatiantInformtion patientInfo; final bool isUpdate; + AddAssessmentDetails( {Key key, this.mySelectedAssessment, @@ -129,14 +130,14 @@ class _AddAssessmentDetailsState extends State { }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: false, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addAssessmentDetails), backgroundColor: Theme.of(context).scaffoldBackgroundColor, body: SingleChildScrollView( child: Center( child: Column( children: [ - BottomSheetTitle( - title: TranslationBase.of(context).addAssessmentDetails), FractionallySizedBox( widthFactor: 0.9, child: Container( 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 index 659de693..87af6ec2 100644 --- a/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart @@ -4,6 +4,7 @@ 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/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.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'; @@ -38,39 +39,14 @@ class _AddExaminationPageState extends State { }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: false, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: "${TranslationBase.of(context).addExamination}", + ), 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( @@ -100,7 +76,7 @@ class _AddExaminationPageState extends State { widget.removeExamination(history); }); }, - addExamination: (selectedExamination) { + addHistory: (selectedExamination) { widget.mySelectedExamination .add(selectedExamination); // setState(() {}); diff --git a/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart b/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart index 5b5bfcb1..f0dc25cf 100644 --- a/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_widget.dart @@ -82,7 +82,7 @@ class _AddExaminationWidgetState extends State { onChanged: (newValue) { setState(() { if (widget.isServiceSelected(widget.item)) { - if (!examination.isLocal) + if (examination.isLocal) widget.removeExamination(widget.item); widget.expandClick(); } else { 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 index 5116ac6b..84a4c740 100644 --- a/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart +++ b/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart @@ -60,7 +60,7 @@ class ExaminationItemCard extends StatelessWidget { SizedBox( height: 4, ), - if(examination.remark.isEmpty) + if(examination.remark.isNotEmpty) AppText( examination.remark, fontWeight: FontWeight.normal, 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 index ef6ec056..c67102ee 100644 --- 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 @@ -9,14 +9,14 @@ import 'add_examination_widget.dart'; class ExaminationsListSearchWidget extends StatefulWidget { final Function(MasterKeyModel) removeExamination; - final Function(MySelectedExamination) addExamination; + final Function(MySelectedExamination) addHistory; final bool Function(MasterKeyModel) isServiceSelected; final List masterList; final List mySelectedExamination; ExaminationsListSearchWidget( {this.removeExamination, - this.addExamination, + this.addHistory, this.isServiceSelected, this.masterList, this.mySelectedExamination}); @@ -62,7 +62,7 @@ class _ExaminationsListSearchWidgetState ...items.mapIndexed((index, item) { return AddExaminationWidget( item: item, - addExamination: widget.addExamination, + addExamination: widget.addHistory, removeExamination: widget.removeExamination, mySelectedExamination: widget.mySelectedExamination, isServiceSelected: widget.isServiceSelected, 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 bd6cd39d..dbd3b080 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 @@ -260,11 +260,8 @@ class _UpdateObjectivePageState extends State { widget.changeLoadingState(false); Helpers.showErrorToast(model.error); } else { - widget.changeLoadingState(false); - // TODO Elham* return this - // widget.changeLoadingState(true); - - //widget.changePageViewIndex(2); + widget.changeLoadingState(true); + widget.changePageViewIndex(2); } } else { Helpers.showErrorToast(TranslationBase.of(context).examinationErrorMsg); diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart index 8f5ecf93..d8110844 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart @@ -1,7 +1,7 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:flutter/material.dart'; -class BottomSheetTitle extends StatelessWidget { +class BottomSheetTitle extends StatelessWidget with PreferredSizeWidget { const BottomSheetTitle({ Key key, this.title, }) : super(key: key); @@ -57,4 +57,7 @@ class BottomSheetTitle extends StatelessWidget { ), ); } + + @override + Size get preferredSize => Size(double.maxFinite,115); } 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 fc7329e5..083c8743 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 @@ -1,5 +1,6 @@ import 'package:autocomplete_textfield/autocomplete_textfield.dart'; 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/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_allergy.dart'; @@ -83,95 +84,100 @@ class _AddAllergiesState extends State { } }, builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: false, - body: Center( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - BottomSheetTitle( - title: TranslationBase.of(context).addAllergies, + baseViewModel: model, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addAllergies, + ), + body: Center( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + SizedBox( + height: 16, + ), + Expanded( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Center( + child: NetworkBaseView( + baseViewModel: model, + child: MasterKeyCheckboxSearchAllergiesWidget( + model: model, + masterList: model.allergiesList, + removeAllergy: (master) { + setState(() { + removeAllergyFromLocalList(master); + }); + }, + addAllergy: + (MySelectedAllergy mySelectedAllergy) { + addAllergyLocally(mySelectedAllergy); + }, + addSelectedAllergy: () => widget + .addAllergiesFun(myAllergiesListLocal), + isServiceSelected: (master) => + isServiceSelected(master), + getServiceSelectedAllergy: (master) => + getSelectedAllergy(master), + ), + ), + ), + ), ), + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.11, + ), + ]), + ), + ), + bottomSheet: model.state == ViewState.Busy + ? Container( + height: 0, + ) + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + height: MediaQuery.of(context).size.height * 0.1, + width: double.infinity, + child: Column( + children: [ SizedBox( height: 10, ), - SizedBox( - height: 16, - ), - Expanded( - child: Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Center( - child: NetworkBaseView( - baseViewModel: model, - child: MasterKeyCheckboxSearchAllergiesWidget( - model: model, - masterList: model.allergiesList, - removeAllergy: (master) { - setState(() { - removeAllergyFromLocalList(master); - }); - }, - addAllergy: - (MySelectedAllergy mySelectedAllergy) { - addAllergyLocally(mySelectedAllergy); - }, - addSelectedAllergy: () => widget - .addAllergiesFun(myAllergiesListLocal), - isServiceSelected: (master) => - isServiceSelected(master), - getServiceSelectedAllergy: (master) => - getSelectedAllergy(master), - ), - ), + Container( + child: FractionallySizedBox( + widthFactor: .80, + child: Center( + child: AppButton( + title: TranslationBase.of(context).addAllergies, + padding: 10, + color: Color(0xFF359846), + onPressed: () { + widget.addAllergiesFun(myAllergiesListLocal); + }, ), ), ), ), SizedBox( - height: MediaQuery.of(context).size.height * 0.11, + height: 5, ), - ]), - ), - ),bottomSheet: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(0.0), - ), - border: Border.all(color: HexColor('#707070'), width: 0), - ), - height: MediaQuery.of(context).size.height * 0.1, - width: double.infinity, - child: Column( - children: [ - SizedBox( - height: 10, - ), - Container( - child: FractionallySizedBox( - widthFactor: .80, - child: Center( - child: AppButton( - title: - TranslationBase.of(context).addAllergies, - padding: 10, - color: Color(0xFF359846), - onPressed: () { - widget.addAllergiesFun(myAllergiesListLocal); - }, - ), + ], ), ), - ), - SizedBox( - height: 5, - ), - ], - ), - ),), + ), ), ); } @@ -207,17 +213,15 @@ class _AddAllergiesState extends State { 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/add_history_dialog.dart b/lib/screens/patients/profile/soap_update/subjective/history/add_history_dialog.dart index 1da8db17..bd2f8502 100644 --- a/lib/screens/patients/profile/soap_update/subjective/history/add_history_dialog.dart +++ b/lib/screens/patients/profile/soap_update/subjective/history/add_history_dialog.dart @@ -1,4 +1,5 @@ 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/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_history.dart'; @@ -19,10 +20,15 @@ class AddHistoryDialog extends StatefulWidget { final PageController controller; final List myHistoryList; final Function addSelectedHistories; - final Function (MasterKeyModel) removeHistory; + final Function(MasterKeyModel) removeHistory; const AddHistoryDialog( - {Key key, this.changePageViewIndex, this.controller, this.myHistoryList, this.addSelectedHistories, this.removeHistory}) + {Key key, + this.changePageViewIndex, + this.controller, + this.myHistoryList, + this.addSelectedHistories, + this.removeHistory}) : super(key: key); @override @@ -51,96 +57,96 @@ class _AddHistoryDialogState extends State { }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: false, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addHistory), body: Center( child: Container( child: Column( - children: [ - BottomSheetTitle(title:TranslationBase.of(context).addHistory), - SizedBox( - height: 10, - ), - PriorityBar(onTap: (activePriority) async { - widget.changePageViewIndex(activePriority); - }), - SizedBox( - height: 20, - ), - Expanded( - child: FractionallySizedBox( - widthFactor: 0.9, - child: PageView( - physics: NeverScrollableScrollPhysics(), - controller: widget.controller, - onPageChanged: (index) { - setState(() { - }); - }, - scrollDirection: Axis.horizontal, - children: [ - NetworkBaseView( - baseViewModel: model, - child: MasterKeyCheckboxSearchWidget( - model: model, - masterList: model.historyFamilyList, - removeHistory: (history){ - setState(() { - widget.removeHistory(history); - }); - }, - addHistory: (history){ - setState(() { - createAndAddHistory( - history); - }); - }, - addSelectedHistories: (){ - widget.addSelectedHistories(); - }, - isServiceSelected: (master) =>isServiceSelected(master), - ), - ), - NetworkBaseView( - baseViewModel: model, - child: MasterKeyCheckboxSearchWidget( - model: model, - masterList: model.mergeHistorySurgicalWithHistorySportList, - removeHistory: (history){ - setState(() { - widget.removeHistory(history); - }); - }, - addHistory: (history){ - setState(() { - createAndAddHistory( - history); - }); - }, - addSelectedHistories: (){ - widget.addSelectedHistories(); - }, - isServiceSelected: (master) =>isServiceSelected(master), - ), - ), - NetworkBaseView( - baseViewModel: model, - child: MasterKeyCheckboxSearchWidget( - model: model, - masterList: model.historyMedicalList, - removeHistory: (history){ - setState(() { - widget.removeHistory(history); - }); - }, - addHistory: (history){ - setState(() { - createAndAddHistory( - history); - }); - }, - addSelectedHistories: (){ - widget.addSelectedHistories(); - }, + children: [ + SizedBox( + height: 10, + ), + PriorityBar(onTap: (activePriority) async { + widget.changePageViewIndex(activePriority); + }), + SizedBox( + height: 20, + ), + Expanded( + child: FractionallySizedBox( + widthFactor: 0.9, + child: PageView( + physics: NeverScrollableScrollPhysics(), + controller: widget.controller, + onPageChanged: (index) { + setState(() {}); + }, + scrollDirection: Axis.horizontal, + children: [ + NetworkBaseView( + baseViewModel: model, + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyFamilyList, + removeHistory: (history) { + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history) { + setState(() { + createAndAddHistory(history); + }); + }, + addSelectedHistories: () { + widget.addSelectedHistories(); + }, + isServiceSelected: (master) => + isServiceSelected(master), + ), + ), + NetworkBaseView( + baseViewModel: model, + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model + .mergeHistorySurgicalWithHistorySportList, + removeHistory: (history) { + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history) { + setState(() { + createAndAddHistory(history); + }); + }, + addSelectedHistories: () { + widget.addSelectedHistories(); + }, + isServiceSelected: (master) => + isServiceSelected(master), + ), + ), + NetworkBaseView( + baseViewModel: model, + child: MasterKeyCheckboxSearchWidget( + model: model, + masterList: model.historyMedicalList, + removeHistory: (history) { + setState(() { + widget.removeHistory(history); + }); + }, + addHistory: (history) { + setState(() { + createAndAddHistory(history); + }); + }, + addSelectedHistories: () { + widget.addSelectedHistories(); + }, isServiceSelected: (master) => isServiceSelected(master), ), @@ -149,59 +155,63 @@ class _AddHistoryDialogState extends State { ), ), ), - SizedBox(height:MediaQuery.of(context).size.height * 0.11 ,) + SizedBox( + height: MediaQuery.of(context).size.height * 0.11, + ) ], - ) - ), + )), ), - bottomSheet: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(0.0), - ), - border: Border.all(color: HexColor('#707070'), width: 0), - ), - height: MediaQuery.of(context).size.height * 0.1, - width: double.infinity, - child: Column( - children: [ - SizedBox( - height: 10, - ), - Container( - child: FractionallySizedBox( - widthFactor: .80, - child: Center( - child: AppButton( - title: - TranslationBase.of(context).addSelectedHistories, - padding: 10, - color: Color(0xFF359846), - onPressed: () { - widget.addSelectedHistories(); - }, - ), + bottomSheet: model.state == ViewState.Busy + ? Container( + height: 0, + ) + : Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + height: MediaQuery.of(context).size.height * 0.1, + width: double.infinity, + child: Column( + children: [ + SizedBox( + height: 10, + ), + Container( + child: FractionallySizedBox( + widthFactor: .80, + child: Center( + child: AppButton( + title: TranslationBase.of(context) + .addSelectedHistories, + padding: 10, + color: Color(0xFF359846), + onPressed: () { + widget.addSelectedHistories(); + }, + ), + ), + ), + ), + SizedBox( + height: 5, + ), + ], ), ), - SizedBox( - height: 5, - ), - ], - ), - ), ), )); } createAndAddHistory(MasterKeyModel history) { - List myhistory = widget.myHistoryList.where((element) => - history.id == - element.selectedHistory.id && - history.typeId == - element.selectedHistory.typeId - ).toList(); + List myhistory = widget.myHistoryList + .where((element) => + history.id == element.selectedHistory.id && + history.typeId == element.selectedHistory.typeId) + .toList(); if (myhistory.isEmpty) { setState(() { @@ -217,18 +227,14 @@ class _AddHistoryDialogState extends State { } isServiceSelected(MasterKeyModel masterKey) { - Iterable history = - widget - .myHistoryList - .where((element) => - masterKey.id == element.selectedHistory.id && - masterKey.typeId == element.selectedHistory.typeId && - element.isChecked); + Iterable history = widget.myHistoryList.where( + (element) => + masterKey.id == element.selectedHistory.id && + masterKey.typeId == element.selectedHistory.typeId && + element.isChecked); if (history.length > 0) { return true; } return false; } - } - diff --git a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart index 69475926..d7f8f6ed 100644 --- a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart +++ b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart @@ -1,6 +1,7 @@ // ignore: must_be_immutable import 'package:autocomplete_textfield/autocomplete_textfield.dart'; 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/search_drug/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'; @@ -74,15 +75,15 @@ class _AddMedicationState extends State { }, builder: (_, model, w) => AppScaffold( baseViewModel: model, - isShowAppBar: false, + isShowAppBar: true, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).addMedication, + ), body: Center( child: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - BottomSheetTitle( - title: TranslationBase.of(context).addMedication, - ), SizedBox( height: 10, ), @@ -381,7 +382,7 @@ class _AddMedicationState extends State { ]), ), ), - bottomSheet: Container( + bottomSheet:model.state == ViewState.Busy?Container(height: 0,): Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all( From c7c6314a8de087993c15d03518bc5a72ad9fc9f8 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 11 Jul 2021 11:35:54 +0300 Subject: [PATCH 05/13] finish create episode fixes --- lib/config/localized_values.dart | 1 + .../assessment/add_assessment_details.dart | 13 +- .../assessment/update_assessment_page.dart | 3 +- .../soap_update/plan/update_plan_page.dart | 165 ++++++++++++------ .../shared_soap_widgets/steps_widget.dart | 32 ++-- lib/util/translations_delegate_base.dart | 1 + 6 files changed, 138 insertions(+), 77 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 089ff3b5..0a094b9b 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -703,4 +703,5 @@ const Map> localizedValues = { "addPrescription": {"en": "Add prescription", "ar": "إضافة الوصفات"}, "edit": {"en": "Edit", "ar": "تعديل"}, "summeryReply": {"en": "Summary Reply", "ar": "موجز الرد"}, + "finish": {"en": "Finish", "ar": "انهاء"}, }; diff --git a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart index 8b9cf7b8..6f51fa40 100644 --- a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart +++ b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart @@ -18,6 +18,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/buttons/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/auto_complete_text_field.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; @@ -254,6 +255,8 @@ class _AddAssessmentDetailsState extends State { MasterKeyDailog dialog = MasterKeyDailog( list: model.listOfDiagnosisCondition, okText: TranslationBase.of(context).ok, + selectedValue: widget.mySelectedAssessment.selectedDiagnosisCondition, + okFunction: (MasterKeyModel selectedValue) { setState(() { @@ -306,6 +309,7 @@ class _AddAssessmentDetailsState extends State { MasterKeyDailog dialog = MasterKeyDailog( list: model.listOfDiagnosisType, okText: TranslationBase.of(context).ok, + selectedValue: widget.mySelectedAssessment.selectedDiagnosisType, okFunction: (MasterKeyModel selectedValue) { setState(() { @@ -435,6 +439,7 @@ class _AddAssessmentDetailsState extends State { {SOAPViewModel model, MySelectedAssessment mySelectedAssessment, bool isUpdate = false}) async { + GifLoaderDialogUtils.showMyDialog(context); if (isUpdate) { PatchAssessmentReqModel patchAssessmentReqModel = PatchAssessmentReqModel( patientMRN: widget.patientInfo.patientMRN, @@ -465,8 +470,9 @@ class _AddAssessmentDetailsState extends State { await model.postAssessment(postAssessmentRequestModel); } - + GifLoaderDialogUtils.hideDialog(context); if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); } else { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); @@ -474,10 +480,7 @@ class _AddAssessmentDetailsState extends State { DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); mySelectedAssessment.icdCode10ID = mySelectedAssessment.selectedICD.code; mySelectedAssessment.doctorName = doctorProfile.doctorName; - - if (!isUpdate) { - widget.addSelectedAssessment(mySelectedAssessment, isUpdate); - } + widget.addSelectedAssessment(mySelectedAssessment, isUpdate); Navigator.of(context).pop(); } } 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 1ab96170..f8da93f5 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 @@ -347,7 +347,7 @@ class _UpdateAssessmentPageState extends State { height: 6, ), AppText( - (assessment.remark != null || + (assessment.remark != null && assessment.remark != '') ? TranslationBase.of( @@ -546,6 +546,7 @@ class _UpdateAssessmentPageState extends State { addSelectedAssessment: (MySelectedAssessment mySelectedAssessment, bool isUpdate) async { setState(() { + if(!isUpdate) mySelectedAssessmentList.add(mySelectedAssessment); }); }); diff --git a/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart b/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart index 114b73d2..47165896 100644 --- a/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart +++ b/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart @@ -42,11 +42,14 @@ class UpdatePlanPage extends StatefulWidget { class _UpdatePlanPageState extends State { bool isAddProgress = true; bool isProgressExpanded = true; - GetPatientProgressNoteResModel patientProgressNote =GetPatientProgressNoteResModel(); + GetPatientProgressNoteResModel patientProgressNote = + GetPatientProgressNoteResModel(); - TextEditingController progressNoteController = TextEditingController(text: null); + TextEditingController progressNoteController = + TextEditingController(text: null); - BoxDecoration containerBorderDecoration(Color containerColor, Color borderColor) { + BoxDecoration containerBorderDecoration( + Color containerColor, Color borderColor) { return BoxDecoration( color: containerColor, shape: BoxShape.rectangle, @@ -72,22 +75,30 @@ class _UpdatePlanPageState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) async { - GetGetProgressNoteReqModel getGetProgressNoteReqModel = GetGetProgressNoteReqModel( - appointmentNo: int.parse(widget.patientInfo.appointmentNo.toString()), - patientMRN: widget.patientInfo.patientMRN, - episodeID: widget.patientInfo.episodeNo.toString(), - editedBy: '', - doctorID: ''); + GetGetProgressNoteReqModel getGetProgressNoteReqModel = + GetGetProgressNoteReqModel( + appointmentNo: + int.parse(widget.patientInfo.appointmentNo.toString()), + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString(), + editedBy: '', + doctorID: ''); await model.getPatientProgressNote(getGetProgressNoteReqModel); if (model.patientProgressNoteList.isNotEmpty) { - progressNoteController.text = Helpers.parseHtmlString(model.patientProgressNoteList[0].planNote); + progressNoteController.text = Helpers.parseHtmlString( + model.patientProgressNoteList[0].planNote); patientProgressNote.planNote = progressNoteController.text; - patientProgressNote.createdByName = model.patientProgressNoteList[0].createdByName; - patientProgressNote.createdOn = model.patientProgressNoteList[0].createdOn; - patientProgressNote.editedOn = model.patientProgressNoteList[0].editedOn; - patientProgressNote.editedByName = model.patientProgressNoteList[0].editedByName; - patientProgressNote.appointmentNo = model.patientProgressNoteList[0].appointmentNo; + patientProgressNote.createdByName = + model.patientProgressNoteList[0].createdByName; + patientProgressNote.createdOn = + model.patientProgressNoteList[0].createdOn; + patientProgressNote.editedOn = + model.patientProgressNoteList[0].editedOn; + patientProgressNote.editedByName = + model.patientProgressNoteList[0].editedByName; + patientProgressNote.appointmentNo = + model.patientProgressNoteList[0].appointmentNo; setState(() { isAddProgress = false; @@ -105,7 +116,9 @@ class _UpdatePlanPageState extends State { widthFactor: 0.90, child: Column( children: [ - SOAPStepHeader(currentIndex: widget.currentIndex, changePageViewIndex: widget.changePageViewIndex), + SOAPStepHeader( + currentIndex: widget.currentIndex, + changePageViewIndex: widget.changePageViewIndex), SizedBox( height: 10, ), @@ -124,33 +137,41 @@ class _UpdatePlanPageState extends State { children: [ if (isAddProgress) Container( - margin: EdgeInsets.only(left: 10, right: 10, top: 15), + margin: EdgeInsets.only( + left: 10, right: 10, top: 15), child: AppTextFieldCustom( - hintText: TranslationBase.of(context).progressNote, + hintText: TranslationBase.of(context) + .progressNote, controller: progressNoteController, minLines: 2, maxLines: 4, inputType: TextInputType.multiline, onChanged: (value) { - patientProgressNote.planNote = value; + setState(() { + patientProgressNote.planNote = value; + }); }, ), ), SizedBox( height: 9, ), - if (patientProgressNote.planNote != null && !isAddProgress) + if (patientProgressNote.planNote != null && + !isAddProgress) Container( margin: EdgeInsets.only( left: 5, right: 5, ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ @@ -159,24 +180,39 @@ class _UpdatePlanPageState extends State { fontSize: 12, ), AppText( - patientProgressNote.appointmentNo.toString() ?? '', + patientProgressNote + .appointmentNo != + null + ? patientProgressNote + .appointmentNo + .toString() + : '', fontWeight: FontWeight.w600, + fontSize: 14, ), ], ), AppText( - patientProgressNote.createdOn != null - ? AppDateUtils.getDayMonthYearDateFormatted( - DateTime.parse(patientProgressNote.createdOn)) - : AppDateUtils.getDayMonthYearDateFormatted(DateTime.now()), + patientProgressNote.createdOn != + null + ? AppDateUtils + .getDayMonthYearDateFormatted( + DateTime.parse( + patientProgressNote + .createdOn)) + : AppDateUtils + .getDayMonthYearDateFormatted( + DateTime.now()), fontWeight: FontWeight.w600, fontSize: 14, ) ], ), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ @@ -184,15 +220,21 @@ class _UpdatePlanPageState extends State { 'Condition: ', fontSize: 12, ), - AppText(patientProgressNote.mName ?? '', + AppText( + patientProgressNote.mName ?? + '', fontWeight: FontWeight.w600), ], ), AppText( - patientProgressNote.createdOn != null + patientProgressNote.createdOn != + null ? AppDateUtils.getHour( - DateTime.parse(patientProgressNote.createdOn)) - : AppDateUtils.getHour(DateTime.now()), + DateTime.parse( + patientProgressNote + .createdOn)) + : AppDateUtils.getHour( + DateTime.now()), fontWeight: FontWeight.w600, fontSize: 14, ) @@ -202,7 +244,8 @@ class _UpdatePlanPageState extends State { height: 8, ), Row( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, children: [ Expanded( child: AppText( @@ -214,7 +257,6 @@ class _UpdatePlanPageState extends State { onTap: () { setState(() { isAddProgress = true; - widget.changePageViewIndex(3, isChangeState: false); }); }, child: Icon( @@ -275,30 +317,38 @@ class _UpdatePlanPageState extends State { ), Expanded( child: AppButton( - title: TranslationBase.of(context).next, + title: isAddProgress + ? TranslationBase.of(context).next + : TranslationBase.of(context).finish, fontWeight: FontWeight.w600, color: Colors.red[700], - loading: model.state == ViewState.BusyLocal, disabled: progressNoteController.text.isEmpty, onPressed: () async { if (progressNoteController.text.isNotEmpty) { if (isAddProgress) { - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); + Map profile = + await sharedPref.getObj(DOCTOR_PROFILE); + DoctorProfileModel doctorProfile = + DoctorProfileModel.fromJson(profile); setState(() { patientProgressNote.createdByName = - patientProgressNote.createdByName ?? doctorProfile.doctorName; - patientProgressNote.editedByName = doctorProfile.doctorName; - patientProgressNote.createdOn = DateTime.now().toString(); - patientProgressNote.planNote = progressNoteController.text; - isAddProgress = !isAddProgress; + patientProgressNote.createdByName ?? + doctorProfile.doctorName; + patientProgressNote.editedByName = + doctorProfile.doctorName; + patientProgressNote.createdOn = + DateTime.now().toString(); + patientProgressNote.planNote = + progressNoteController.text; }); submitPlan(model); } else { Navigator.of(context).pop(); } } else { - Helpers.showErrorToast(TranslationBase.of(context).progressNoteErrorMsg); + Helpers.showErrorToast( + TranslationBase.of(context) + .progressNoteErrorMsg); } }, ), @@ -320,31 +370,32 @@ class _UpdatePlanPageState extends State { submitPlan(SOAPViewModel model) async { if (progressNoteController.text.isNotEmpty) { widget.changeLoadingState(true); - PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - planNote: patientProgressNote.planNote, - doctorID: '', - editedBy: ''); + PostProgressNoteRequestModel postProgressNoteRequestModel = + new PostProgressNoteRequestModel( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + planNote: patientProgressNote.planNote, + doctorID: '', + editedBy: ''); if (model.patientProgressNoteList.isEmpty) { await model.postProgressNote(postProgressNoteRequestModel); } else { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); postProgressNoteRequestModel.editedBy = doctorProfile.doctorID; await model.patchProgressNote(postProgressNoteRequestModel); } if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); } else { - widget.changePageViewIndex(4, isChangeState: false); - } + setState(() { + isAddProgress = !isAddProgress; + }); + } widget.changeLoadingState(false); } else { Helpers.showErrorToast(TranslationBase.of(context).progressNoteErrorMsg); diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/steps_widget.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/steps_widget.dart index c5c2e8ca..e79c24a7 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/steps_widget.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/steps_widget.dart @@ -247,6 +247,8 @@ class StepsWidget extends StatelessWidget { "Plan", fontWeight: FontWeight.bold, fontSize: 12, + textAlign: TextAlign.end, + marginLeft: 25, ), StatusLabel( selectedStepId: index, @@ -530,20 +532,22 @@ class StatusLabel extends StatelessWidget { ), border: Border.all(color: HexColor('#707070'), width: 0.30), ), - child: AppText( - stepId == selectedStepId - ? "inProgress" - : stepId < selectedStepId - ? "Completed" - : " Locked ", - fontWeight: FontWeight.bold, - textAlign: TextAlign.center, - fontSize: 10, - color: stepId == selectedStepId - ? Color(0xFFCC9B14) - : stepId < selectedStepId - ? Color(0xFF359846) - : Color(0xFF969696), + child: Center( + child: AppText( + stepId == selectedStepId + ? "inProgress" + : stepId < selectedStepId + ? "Completed" + : "Locked", + fontWeight: FontWeight.bold, + textAlign: TextAlign.center, + fontSize: 10, + color: stepId == selectedStepId + ? Color(0xFFCC9B14) + : stepId < selectedStepId + ? Color(0xFF359846) + : Color(0xFF969696), + ), ), ); } diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 165a9bb5..e30a006a 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -562,6 +562,7 @@ class TranslationBase { localizedValues['no-priscription-listed'][locale.languageCode]; String get next => localizedValues['next'][locale.languageCode]; + String get finish => localizedValues['finish'][locale.languageCode]; String get previous => localizedValues['previous'][locale.languageCode]; From 9b40638f863645a989fd06607ff3f958ef4e8eb1 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 11 Jul 2021 17:07:17 +0300 Subject: [PATCH 06/13] fix get allergies issues --- lib/models/SOAP/my_selected_allergy.dart | 8 +- .../subjective/allergies/add_allergies.dart | 15 +- .../subjective/allergies/allergies_item.dart | 195 ++++++++ ..._key_checkbox_search_allergies_widget.dart | 148 ++++++ .../allergies/update_allergies_widget.dart | 6 +- ..._key_checkbox_search_allergies_widget.dart | 421 ------------------ .../user-guid/custom_validation_error.dart | 6 +- 7 files changed, 364 insertions(+), 435 deletions(-) create mode 100644 lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart create mode 100644 lib/screens/patients/profile/soap_update/subjective/allergies/master_key_checkbox_search_allergies_widget.dart delete mode 100644 lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart diff --git a/lib/models/SOAP/my_selected_allergy.dart b/lib/models/SOAP/my_selected_allergy.dart index 66234db3..90031230 100644 --- a/lib/models/SOAP/my_selected_allergy.dart +++ b/lib/models/SOAP/my_selected_allergy.dart @@ -8,6 +8,7 @@ class MySelectedAllergy { bool isExpanded; bool isLocal; int createdBy; + bool hasValidationError; MySelectedAllergy( {this.selectedAllergySeverity, @@ -15,8 +16,9 @@ class MySelectedAllergy { this.remark, this.isChecked, this.isExpanded = true, - this.isLocal = true, - this.createdBy}); + this.isLocal = true, + this.createdBy, + this.hasValidationError = false}); MySelectedAllergy.fromJson(Map json) { selectedAllergySeverity = json['selectedAllergySeverity'] != null @@ -30,6 +32,7 @@ class MySelectedAllergy { isExpanded = json['isExpanded']; isLocal = json['isLocal']; createdBy = json['createdBy']; + hasValidationError = json['hasValidationError']; } Map toJson() { @@ -45,6 +48,7 @@ class MySelectedAllergy { data['isExpanded'] = this.isExpanded; data['createdBy'] = this.createdBy; data['isLocal'] = this.isLocal; + data['hasValidationError'] = this.hasValidationError; return data; } } 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 083c8743..4cf20318 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 @@ -9,12 +9,12 @@ import 'package:doctor_app_flutter/util/helpers.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/buttons/app_buttons_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_allergies_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import '../../shared_soap_widgets/bottom_sheet_title.dart'; +import 'master_key_checkbox_search_allergies_widget.dart'; class AddAllergies extends StatefulWidget { final Function addAllergiesFun; @@ -119,8 +119,13 @@ class _AddAllergiesState extends State { (MySelectedAllergy mySelectedAllergy) { addAllergyLocally(mySelectedAllergy); }, - addSelectedAllergy: () => widget - .addAllergiesFun(myAllergiesListLocal), + addSelectedAllergy: () { + + setState(() { + widget + .addAllergiesFun(myAllergiesListLocal); + }); + }, isServiceSelected: (master) => isServiceSelected(master), getServiceSelectedAllergy: (master) => @@ -165,7 +170,9 @@ class _AddAllergiesState extends State { padding: 10, color: Color(0xFF359846), onPressed: () { - widget.addAllergiesFun(myAllergiesListLocal); + setState(() { + widget.addAllergiesFun(myAllergiesListLocal); + }); }, ), ), diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart new file mode 100644 index 00000000..8a402a7b --- /dev/null +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart @@ -0,0 +1,195 @@ +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/util/translations_delegate_base.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/expandable-widget-header-body.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class AddAllergiesItem extends StatefulWidget { + // TODO Elham* see what fun we can move here without effects + final SOAPViewModel model; + final Function(MasterKeyModel) removeAllergy; + final Function(MySelectedAllergy mySelectedAllergy) addAllergy; + final bool Function(MasterKeyModel) isServiceSelected; + final MySelectedAllergy Function(MasterKeyModel) getServiceSelectedAllergy; + + final MasterKeyModel item; + + const AddAllergiesItem( + {Key key, + this.model, + this.removeAllergy, + this.addAllergy, + this.isServiceSelected, + this.getServiceSelectedAllergy, + this.item}) + : super(key: key); + + @override + _AddAllergiesItemState createState() => _AddAllergiesItemState(); +} + +class _AddAllergiesItemState extends State { + MasterKeyModel _selectedAllergySeverity; + bool isSubmitted = false; + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + bool isSelected = widget.isServiceSelected(widget.item); + MySelectedAllergy mySelectedAllergy; + if (isSelected) { + mySelectedAllergy = widget.getServiceSelectedAllergy(widget.item); + } + TextEditingController remarkController = TextEditingController( + text: isSelected ? mySelectedAllergy.remark : null); + TextEditingController severityController = TextEditingController( + text: isSelected + ? mySelectedAllergy.selectedAllergySeverity != null + ? projectViewModel.isArabic + ? mySelectedAllergy.selectedAllergySeverity.nameAr + : mySelectedAllergy.selectedAllergySeverity.nameEn + : null + : null); + return HeaderBodyExpandableNotifier( + headerWidget: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + Checkbox( + value: widget.isServiceSelected(widget.item), + activeColor: Colors.red[800], + onChanged: (bool newValue) { + onTapItem(); + }), + InkWell( + onTap:onTapItem, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: Container( + child: AppText( + projectViewModel.isArabic + ? widget.item.nameAr != "" + ? widget.item.nameAr + : widget.item.nameEn + : widget.item.nameEn, + color: Color(0xFF575757), + fontSize: 16, + fontWeight: FontWeight.w600, + ), + width: MediaQuery.of(context).size.width * 0.55, + ), + ), + ), + ], + ), + InkWell( + onTap: () { + if (mySelectedAllergy != null) { + setState(() { + mySelectedAllergy.isExpanded = + mySelectedAllergy.isExpanded ? false : true; + }); + } + }, + child: Icon((mySelectedAllergy != null + ? mySelectedAllergy.isExpanded + : false) + ? EvaIcons.arrowIosUpwardOutline + : EvaIcons.arrowIosDownwardOutline)) + ], + ), + bodyWidget: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Center( + child: Column( + children: [ + AppTextFieldCustom( + onClick: widget.model.allergySeverityList != null + ? () { + MasterKeyDailog dialog = MasterKeyDailog( + list: widget.model.allergySeverityList, + selectedValue: + mySelectedAllergy.selectedAllergySeverity, + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + mySelectedAllergy.selectedAllergySeverity = + selectedValue; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + isTextFieldHasSuffix: true, + hintText: TranslationBase.of(context).selectSeverity, + enabled: false, + maxLines: 2, + minLines: 2, + validationError: mySelectedAllergy != null && + mySelectedAllergy.selectedAllergySeverity == null && + mySelectedAllergy.hasValidationError + ? TranslationBase.of(context).emptyMessage + : null, + controller: severityController, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + hintText: TranslationBase.of(context).remarks, + controller: remarkController, + maxLines: 25, + minLines: 3, + hasBorder: true, + inputType: TextInputType.multiline, + + ), + SizedBox( + height: 10, + ), + ], + ), + ), + ), + ), + isExpand: + mySelectedAllergy != null ? mySelectedAllergy.isExpanded : false, + ); + } + + onTapItem(){ + setState(() { + if (widget.isServiceSelected(widget.item)) { + widget.removeAllergy(widget.item); + } else { + MySelectedAllergy mySelectedAllergy = + new MySelectedAllergy( + selectedAllergy: widget.item, + selectedAllergySeverity: _selectedAllergySeverity, + remark: null, + isChecked: true, + isExpanded: true); + widget.addAllergy(mySelectedAllergy); + } + }); + } +} diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/master_key_checkbox_search_allergies_widget.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/master_key_checkbox_search_allergies_widget.dart new file mode 100644 index 00000000..8644c9a9 --- /dev/null +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/master_key_checkbox_search_allergies_widget.dart @@ -0,0 +1,148 @@ +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_allergy.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'allergies_item.dart'; + + +class MasterKeyCheckboxSearchAllergiesWidget extends StatefulWidget { + final SOAPViewModel model; + final Function() addSelectedAllergy; + final Function(MasterKeyModel) removeAllergy; + final Function(MySelectedAllergy mySelectedAllergy) addAllergy; + final bool Function(MasterKeyModel) isServiceSelected; + final MySelectedAllergy Function(MasterKeyModel) getServiceSelectedAllergy; + + final List masterList; + final String buttonName; + final String hintSearchText; + + MasterKeyCheckboxSearchAllergiesWidget( + {Key key, + this.model, + this.addSelectedAllergy, + this.removeAllergy, + this.masterList, + this.addAllergy, + this.isServiceSelected, + this.buttonName, + this.hintSearchText, + this.getServiceSelectedAllergy}) + : super(key: key); + + @override + _MasterKeyCheckboxSearchAllergiesWidgetState createState() => + _MasterKeyCheckboxSearchAllergiesWidgetState(); +} + +class _MasterKeyCheckboxSearchAllergiesWidgetState + extends State { + List items = List(); + + + @override + void initState() { + items.addAll(widget.masterList); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + Expanded( + child: Container( + height: MediaQuery.of(context).size.height * 0.70, + child: Center( + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: Column( + children: [ + AppTextFieldCustom( + // height: + // MediaQuery.of(context).size.height * 0.070, + hintText: + TranslationBase.of(context).selectAllergy, + isTextFieldHasSuffix: true, + hasBorder: false, + // controller: filteredSearchController, + onChanged: (value) { + filterSearchResults(value); + }, + suffixIcon: IconButton( + icon: Icon( + Icons.search, + color: Colors.black, + )), + ), + DividerWithSpacesAround(), + SizedBox( + height: 10, + ), + Expanded( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Container( + height: + MediaQuery.of(context).size.height * 0.60, + child: ListView.builder( + itemCount: items.length, + itemBuilder: (context, index) { + + return AddAllergiesItem( + item:items[index], + model: widget.model, + removeAllergy: widget.removeAllergy, + addAllergy:widget.addAllergy, + isServiceSelected: widget.isServiceSelected, + getServiceSelectedAllergy: widget.getServiceSelectedAllergy, + ); + }, + ), + ), + ), + ), + ], + ))), + ), + ), + SizedBox( + height: 10, + ), + ], + ), + ); + } + + void filterSearchResults(String query) { + List dummySearchList = List(); + dummySearchList.addAll(widget.masterList); + if (query.isNotEmpty) { + List dummyListData = List(); + dummySearchList.forEach((items) { + if (items.nameAr.toLowerCase().contains(query.toLowerCase()) || + items.nameEn.toLowerCase().contains(query.toLowerCase())) { + dummyListData.add(items); + } + }); + setState(() { + items.clear(); + items.addAll(dummyListData); + }); + return; + } else { + setState(() { + items.clear(); + items.addAll(widget.masterList); + }); + } + } +} diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart index cb7d7d00..4be953a7 100644 --- a/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/update_allergies_widget.dart @@ -34,8 +34,6 @@ class _UpdateAllergiesWidgetState extends State { return Column( children: [ - - SOAPOpenItems(label: "${TranslationBase.of(context).addAllergies}",onTap: () { openAllergiesList(context, changeAllState, removeAllergy); },), @@ -173,11 +171,11 @@ class _UpdateAllergiesWidgetState extends State { builder: (context) { return AddAllergies( myAllergiesList: widget.myAllergiesList, - addAllergiesFun: (List mySelectedAllergy) { bool isAllDataFilled = true; mySelectedAllergy.forEach((element) { if (element.selectedAllergySeverity == null) { + element.hasValidationError = true; isAllDataFilled = false; } }); @@ -200,8 +198,6 @@ class _UpdateAllergiesWidgetState extends State { removedList.forEach((element) { removeAllergy(element); }); - - changeParentState(); Navigator.of(context).pop(); } else { diff --git a/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart b/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart deleted file mode 100644 index 7a1fc3f5..00000000 --- a/lib/widgets/shared/master_key_checkbox_search_allergies_widget.dart +++ /dev/null @@ -1,421 +0,0 @@ -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/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/new_text_Field.dart'; -import 'package:doctor_app_flutter/widgets/shared/user-guid/custom_validation_error.dart'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -import 'app_texts_widget.dart'; -import 'dialogs/master_key_dailog.dart'; -import 'divider_with_spaces_around.dart'; -import 'expandable-widget-header-body.dart'; -import 'text_fields/app-textfield-custom.dart'; - -class MasterKeyCheckboxSearchAllergiesWidget extends StatefulWidget { - final SOAPViewModel model; - final Function() addSelectedAllergy; - final Function(MasterKeyModel) removeAllergy; - final Function(MySelectedAllergy mySelectedAllergy) addAllergy; - final bool Function(MasterKeyModel) isServiceSelected; - final MySelectedAllergy Function(MasterKeyModel) getServiceSelectedAllergy; - - final List masterList; - final String buttonName; - final String hintSearchText; - - MasterKeyCheckboxSearchAllergiesWidget( - {Key key, - this.model, - this.addSelectedAllergy, - this.removeAllergy, - this.masterList, - this.addAllergy, - this.isServiceSelected, - this.buttonName, - this.hintSearchText, - this.getServiceSelectedAllergy}) - : super(key: key); - - @override - _MasterKeyCheckboxSearchAllergiesWidgetState createState() => - _MasterKeyCheckboxSearchAllergiesWidgetState(); -} - -class _MasterKeyCheckboxSearchAllergiesWidgetState - extends State { - List items = List(); - MasterKeyModel _selectedAllergySeverity; - bool isSubmitted = false; - - @override - void initState() { - items.addAll(widget.masterList); - super.initState(); - } - - @override - Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - return Container( - child: Column( - children: [ - Expanded( - child: Container( - height: MediaQuery.of(context).size.height * 0.70, - child: Center( - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: Column( - children: [ - AppTextFieldCustom( - // height: - // MediaQuery.of(context).size.height * 0.070, - hintText: - TranslationBase.of(context).selectAllergy, - isTextFieldHasSuffix: true, - hasBorder: false, - // controller: filteredSearchController, - onChanged: (value) { - filterSearchResults(value); - }, - suffixIcon: IconButton( - icon: Icon( - Icons.search, - color: Colors.black, - )), - ), - DividerWithSpacesAround(), - SizedBox( - height: 10, - ), - Expanded( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Container( - height: - MediaQuery.of(context).size.height * 0.60, - child: ListView.builder( - itemCount: items.length, - itemBuilder: (context, index) { - bool isSelected = widget - .isServiceSelected(items[index]); - MySelectedAllergy mySelectedAllergy; - if (isSelected) { - mySelectedAllergy = - widget.getServiceSelectedAllergy( - items[index]); - } - TextEditingController remarkController = - TextEditingController( - text: isSelected - ? mySelectedAllergy.remark - : null); - TextEditingController severityController = - TextEditingController( - text: isSelected - ? mySelectedAllergy - .selectedAllergySeverity != - null - ? projectViewModel - .isArabic - ? mySelectedAllergy - .selectedAllergySeverity - .nameAr - : mySelectedAllergy - .selectedAllergySeverity - .nameEn - : null - : null); - return HeaderBodyExpandableNotifier( - headerWidget: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - Checkbox( - value: widget - .isServiceSelected( - items[index]), - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() { - if (widget - .isServiceSelected( - items[index])) { - widget.removeAllergy( - items[index]); - } else { - MySelectedAllergy - mySelectedAllergy = - new MySelectedAllergy( - selectedAllergy: - items[ - index], - selectedAllergySeverity: - _selectedAllergySeverity, - remark: null, - isChecked: - true, - isExpanded: - true); - widget.addAllergy( - mySelectedAllergy); - } - }); - }), - InkWell( - onTap: () { - setState(() { - if (widget - .isServiceSelected( - items[index])) { - widget.removeAllergy( - items[index]); - } else { - - MySelectedAllergy mySelectedAllergy = - new MySelectedAllergy( - selectedAllergy: - items[ - index], - selectedAllergySeverity: - _selectedAllergySeverity, - remark: null, - isChecked: true, - isExpanded: - true); - widget.addAllergy( - mySelectedAllergy); - } - }); - }, - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Container( - child: AppText( - projectViewModel - .isArabic - ? items[index] - .nameAr != - "" - ? items[index] - .nameAr - : items[index] - .nameEn - : items[index] - .nameEn, - color: - Color(0xFF575757), - fontSize: 16, - fontWeight: - FontWeight.w600, - ), - width: - MediaQuery.of(context) - .size - .width * - 0.55, - ), - ), - ), - ], - ), - InkWell( - onTap: () { - if (mySelectedAllergy != - null) { - setState(() { - mySelectedAllergy - .isExpanded = - mySelectedAllergy - .isExpanded - ? false - : true; - }); - } - }, - child: Icon((mySelectedAllergy != - null - ? mySelectedAllergy - .isExpanded - : false) - ? EvaIcons - .arrowIosUpwardOutline - : EvaIcons - .arrowIosDownwardOutline)) - ], - ), - bodyWidget: Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Center( - child: Column( - children: [ - AppTextFieldCustom( - onClick: widget.model - .allergySeverityList != - null - ? () { - MasterKeyDailog - dialog = - MasterKeyDailog( - list: widget.model - .allergySeverityList, - okText: - TranslationBase.of( - context) - .ok, - okFunction: - (selectedValue) { - setState(() { - mySelectedAllergy - .selectedAllergySeverity = - selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: - false, - context: context, - builder: - (BuildContext - context) { - return dialog; - }, - ); - } - : null, - isTextFieldHasSuffix: true, - hintText: - TranslationBase.of( - context) - .selectSeverity, - enabled: false, - maxLines: 2, - minLines: 2, - controller: - severityController, - ), - SizedBox( - height: 5, - ), - if (isSubmitted && - mySelectedAllergy != - null && - mySelectedAllergy - .selectedAllergySeverity == - null) - Row( - children: [ - CustomValidationError(), - ], - mainAxisAlignment: - MainAxisAlignment - .start, - ), - SizedBox( - height: 10, - ), - Container( - margin: EdgeInsets.only( - left: 0, - right: 0, - top: 15), - child: NewTextFields( - hintText: - TranslationBase.of( - context) - .remarks, - fontSize: 13.5, - // hintColor: Colors.black, - fontWeight: - FontWeight.w600, - maxLines: 25, - minLines: 3, - initialValue: isSelected - ? mySelectedAllergy - .remark - : '', - // controller: remarkControlle - - onChanged: (value) { - if (isSelected) { - mySelectedAllergy - .remark = value; - } - }, - validator: (value) { - if (value == null) - return TranslationBase - .of(context) - .emptyMessage; - else - return null; - }), - ), - SizedBox( - height: 10, - ), - ], - ), - ), - ), - ), - isExpand: mySelectedAllergy != null - ? mySelectedAllergy.isExpanded - : false, - ); - }, - ), - ), - ), - ), - ], - ))), - ), - ), - SizedBox( - height: 10, - ), - ], - ), - ); - } - - void filterSearchResults(String query) { - List dummySearchList = List(); - dummySearchList.addAll(widget.masterList); - if (query.isNotEmpty) { - List dummyListData = List(); - dummySearchList.forEach((items) { - if (items.nameAr.toLowerCase().contains(query.toLowerCase()) || - items.nameEn.toLowerCase().contains(query.toLowerCase())) { - dummyListData.add(items); - } - }); - setState(() { - items.clear(); - items.addAll(dummyListData); - }); - return; - } else { - setState(() { - items.clear(); - items.addAll(widget.masterList); - }); - } - } -} diff --git a/lib/widgets/shared/user-guid/custom_validation_error.dart b/lib/widgets/shared/user-guid/custom_validation_error.dart index a05d52a2..fd1f2125 100644 --- a/lib/widgets/shared/user-guid/custom_validation_error.dart +++ b/lib/widgets/shared/user-guid/custom_validation_error.dart @@ -13,9 +13,9 @@ class CustomValidationError extends StatelessWidget { @override Widget build(BuildContext context) { if(error == null ) - error = TranslationBase - .of(context) - .emptyMessage; + error = TranslationBase + .of(context) + .emptyMessage; return Column( children: [ SizedBox( From f52917f2191c4260e1bd1bd82cd3fe9dc63b94da Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 11 Jul 2021 17:10:32 +0300 Subject: [PATCH 07/13] fix get allergies issues --- .../profile/soap_update/subjective/allergies/allergies_item.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart index 8a402a7b..b9eef0f5 100644 --- a/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart @@ -13,7 +13,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class AddAllergiesItem extends StatefulWidget { - // TODO Elham* see what fun we can move here without effects final SOAPViewModel model; final Function(MasterKeyModel) removeAllergy; final Function(MySelectedAllergy mySelectedAllergy) addAllergy; From 469169023a42e419d52f61187cbd4e89849c2169 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 12 Jul 2021 09:33:51 +0300 Subject: [PATCH 08/13] fix get allergies issues --- .../profile/soap_update/subjective/update_subjective_page.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart index ade555ba..89859a35 100644 --- a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -405,6 +405,9 @@ class _UpdateSubjectivePageState extends State { await model.patchAllergy(postAllergyRequestModel); } + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP( patientMRN: widget.patientInfo.patientMRN, episodeId: widget.patientInfo.episodeNo, From c3ed212e6a178759a2a2010247df8addc817d284 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 12 Jul 2021 17:09:04 +0300 Subject: [PATCH 09/13] remove base View --- .../profile/soap_update/update_soap_index.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/screens/patients/profile/soap_update/update_soap_index.dart b/lib/screens/patients/profile/soap_update/update_soap_index.dart index 883e19f0..e9d6d16d 100644 --- a/lib/screens/patients/profile/soap_update/update_soap_index.dart +++ b/lib/screens/patients/profile/soap_update/update_soap_index.dart @@ -61,12 +61,11 @@ class _UpdateSoapIndexState extends State Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; - return BaseView( - builder: (_, model, w) => AppScaffold( - isLoading: _isLoading, - isShowAppBar: false, - body: SingleChildScrollView( - child: SingleChildScrollView( + return AppScaffold( + isLoading: _isLoading, + isShowAppBar: false, + body: SingleChildScrollView( + child: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -128,6 +127,6 @@ class _UpdateSoapIndexState extends State ), ), ), - )); + ); } } From eabe16a1d37442c395fc94a226833135a4f11594 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 13 Jul 2021 09:21:53 +0300 Subject: [PATCH 10/13] change text field --- lib/widgets/shared/text_fields/app-textfield-custom.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/widgets/shared/text_fields/app-textfield-custom.dart b/lib/widgets/shared/text_fields/app-textfield-custom.dart index fc7df189..009446ff 100644 --- a/lib/widgets/shared/text_fields/app-textfield-custom.dart +++ b/lib/widgets/shared/text_fields/app-textfield-custom.dart @@ -104,7 +104,7 @@ class _AppTextFieldCustomState extends State { widget.height != 0 && widget.maxLines == 1 ? widget.height - 22 : null, - child: TextField( + child: TextFormField( textAlign: projectViewModel.isArabic ? TextAlign.right : TextAlign.left, @@ -129,7 +129,7 @@ class _AppTextFieldCustomState extends State { ? widget.inputFormatters : [], onChanged: (value) { - setState(() {}); + // setState(() {}); if (widget.onChanged != null) { widget.onChanged(value); } From 3b6fcb424084655e0d44f66ce250ad39c12889fa Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Tue, 13 Jul 2021 10:54:12 +0300 Subject: [PATCH 11/13] fix app text field custom --- .../subjective/update_subjective_page.dart | 1 + .../text_fields/app-textfield-custom.dart | 36 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart index 89859a35..47b7e6df 100644 --- a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -324,6 +324,7 @@ class _UpdateSubjectivePageState extends State { addSubjectiveInfo( {SOAPViewModel model, List myAllergiesList, List myHistoryList}) async { + FocusScope.of(context).unfocus(); widget.changeLoadingState(true); formKey.currentState.save(); formKey.currentState.validate(); diff --git a/lib/widgets/shared/text_fields/app-textfield-custom.dart b/lib/widgets/shared/text_fields/app-textfield-custom.dart index fc7df189..05f139a2 100644 --- a/lib/widgets/shared/text_fields/app-textfield-custom.dart +++ b/lib/widgets/shared/text_fields/app-textfield-custom.dart @@ -27,6 +27,7 @@ class AppTextFieldCustom extends StatefulWidget { final String validationError; final bool isPrscription; final bool isSecure; + final bool focus; AppTextFieldCustom({ this.height = 0, @@ -47,6 +48,7 @@ class AppTextFieldCustom extends StatefulWidget { this.validationError, this.isPrscription = false, this.isSecure = false, + this.focus = false, }); @override @@ -54,6 +56,32 @@ class AppTextFieldCustom extends StatefulWidget { } class _AppTextFieldCustomState extends State { + final FocusNode _focusNode = FocusNode(); + bool focus = false; + bool view = false; + + @override + void initState() { + super.initState(); + _focusNode.addListener(() { + setState(() { + focus = _focusNode.hasFocus; + }); + }); + } + + @override + void didUpdateWidget(AppTextFieldCustom oldWidget) { + if (widget.focus) _focusNode.requestFocus(); + super.didUpdateWidget(oldWidget); + } + + @override + void dispose() { + _focusNode.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -104,10 +132,11 @@ class _AppTextFieldCustomState extends State { widget.height != 0 && widget.maxLines == 1 ? widget.height - 22 : null, - child: TextField( + child: TextFormField( textAlign: projectViewModel.isArabic ? TextAlign.right : TextAlign.left, + focusNode: _focusNode, decoration: TextFieldsUtils .textFieldSelectorDecoration( widget.hintText, null, true), @@ -129,7 +158,7 @@ class _AppTextFieldCustomState extends State { ? widget.inputFormatters : [], onChanged: (value) { - setState(() {}); + // setState(() {}); if (widget.onChanged != null) { widget.onChanged(value); } @@ -162,9 +191,10 @@ class _AppTextFieldCustomState extends State { ), ), ), - if (widget.validationError != null) + if (widget.validationError != null && widget.validationError.isNotEmpty) TextFieldsError(error: widget.validationError), ], ); } + } From 87c906ae2bf5cab5af0c107df9a156087e6956ee Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Tue, 13 Jul 2021 10:57:11 +0300 Subject: [PATCH 12/13] Add check if has focus --- .../profile/soap_update/subjective/update_subjective_page.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart index 47b7e6df..7a48a786 100644 --- a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -324,6 +324,7 @@ class _UpdateSubjectivePageState extends State { addSubjectiveInfo( {SOAPViewModel model, List myAllergiesList, List myHistoryList}) async { + if(FocusScope.of(context).hasFocus) FocusScope.of(context).unfocus(); widget.changeLoadingState(true); formKey.currentState.save(); From b015cb06f7262bbcc4a6876e07995673db77d9fa Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 13 Jul 2021 11:16:08 +0300 Subject: [PATCH 13/13] add fixes on episode --- .../assessment/add_assessment_details.dart | 2 +- .../soap_update/plan/update_plan_page.dart | 104 ++++++++++++------ .../subjective/allergies/allergies_item.dart | 3 + .../subjective/medication/add_medication.dart | 4 + 4 files changed, 81 insertions(+), 32 deletions(-) diff --git a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart index 6f51fa40..e14eb6f2 100644 --- a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart +++ b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart @@ -372,7 +372,7 @@ class _AddAssessmentDetailsState extends State { ), ), ), - bottomSheet: Container( + bottomSheet: model.state == ViewState.Busy?Container(height: 0,):Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all( diff --git a/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart b/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart index 47165896..4622bc94 100644 --- a/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart +++ b/lib/screens/patients/profile/soap_update/plan/update_plan_page.dart @@ -71,6 +71,38 @@ class _UpdatePlanPageState extends State { } } + + getPatientProgressNote(model, {bool isAddProgress = false}) async { + GetGetProgressNoteReqModel getGetProgressNoteReqModel = + GetGetProgressNoteReqModel( + appointmentNo: + int.parse(widget.patientInfo.appointmentNo.toString()), + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString(), + editedBy: '', + doctorID: ''); + await model.getPatientProgressNote(getGetProgressNoteReqModel); + + if (model.patientProgressNoteList.isNotEmpty) { + progressNoteController.text = Helpers.parseHtmlString( + model.patientProgressNoteList[0].planNote); + patientProgressNote.planNote = progressNoteController.text; + patientProgressNote.createdByName = + model.patientProgressNoteList[0].createdByName; + patientProgressNote.createdOn = + model.patientProgressNoteList[0].createdOn; + patientProgressNote.editedOn = + model.patientProgressNoteList[0].editedOn; + patientProgressNote.editedByName = + model.patientProgressNoteList[0].editedByName; + patientProgressNote.appointmentNo = + model.patientProgressNoteList[0].appointmentNo; + setState(() { + isAddProgress = isAddProgress; + }); + } + } + @override Widget build(BuildContext context) { return BaseView( @@ -210,22 +242,22 @@ class _UpdatePlanPageState extends State { ), Row( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - AppText( - 'Condition: ', - fontSize: 12, - ), - AppText( - patientProgressNote.mName ?? - '', - fontWeight: FontWeight.w600), - ], - ), + // Row( + // children: [ + // AppText( + // 'Condition: ', + // fontSize: 12, + // ), + // AppText( + // patientProgressNote.mName ?? + // '', + // fontWeight: FontWeight.w600), + // ], + // ), AppText( patientProgressNote.createdOn != null @@ -326,21 +358,6 @@ class _UpdatePlanPageState extends State { onPressed: () async { if (progressNoteController.text.isNotEmpty) { if (isAddProgress) { - Map profile = - await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = - DoctorProfileModel.fromJson(profile); - setState(() { - patientProgressNote.createdByName = - patientProgressNote.createdByName ?? - doctorProfile.doctorName; - patientProgressNote.editedByName = - doctorProfile.doctorName; - patientProgressNote.createdOn = - DateTime.now().toString(); - patientProgressNote.planNote = - progressNoteController.text; - }); submitPlan(model); } else { Navigator.of(context).pop(); @@ -391,10 +408,35 @@ class _UpdatePlanPageState extends State { if (model.state == ViewState.ErrorLocal) { Helpers.showErrorToast(model.error); } else { - setState(() { - isAddProgress = !isAddProgress; - }); + GetGetProgressNoteReqModel getGetProgressNoteReqModel = + GetGetProgressNoteReqModel( + appointmentNo: + int.parse(widget.patientInfo.appointmentNo.toString()), + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString(), + editedBy: '', + doctorID: ''); + await model.getPatientProgressNote(getGetProgressNoteReqModel); + if (model.patientProgressNoteList.isNotEmpty) { + progressNoteController.text = Helpers.parseHtmlString( + model.patientProgressNoteList[0].planNote); + patientProgressNote.planNote = progressNoteController.text; + patientProgressNote.createdByName = + model.patientProgressNoteList[0].createdByName; + patientProgressNote.createdOn = + model.patientProgressNoteList[0].createdOn; + patientProgressNote.editedOn = + model.patientProgressNoteList[0].editedOn; + patientProgressNote.editedByName = + model.patientProgressNoteList[0].editedByName; + patientProgressNote.appointmentNo = + model.patientProgressNoteList[0].appointmentNo; + + setState(() { + isAddProgress = false; + }); + } } widget.changeLoadingState(false); } else { diff --git a/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart b/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart index b9eef0f5..55e36342 100644 --- a/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart +++ b/lib/screens/patients/profile/soap_update/subjective/allergies/allergies_item.dart @@ -159,6 +159,9 @@ class _AddAllergiesItemState extends State { maxLines: 25, minLines: 3, hasBorder: true, + onChanged: (value){ + mySelectedAllergy.remark = value; + }, inputType: TextInputType.multiline, ), diff --git a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart index d7f8f6ed..11e4fa72 100644 --- a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart +++ b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart @@ -188,6 +188,7 @@ class _AddMedicationState extends State { list: model.medicationDoseTimeList, okText: TranslationBase.of(context).ok, + selectedValue: _selectedMedicationDose, okFunction: (selectedValue) { setState(() { _selectedMedicationDose = @@ -236,6 +237,7 @@ class _AddMedicationState extends State { list: model.medicationStrengthList, okText: TranslationBase.of(context).ok, + selectedValue: _selectedMedicationStrength, okFunction: (selectedValue) { setState(() { _selectedMedicationStrength = @@ -284,6 +286,7 @@ class _AddMedicationState extends State { MasterKeyDailog dialog = MasterKeyDailog( list: model.medicationRouteList, + selectedValue: _selectedMedicationRoute, okText: TranslationBase.of(context).ok, okFunction: (selectedValue) { @@ -333,6 +336,7 @@ class _AddMedicationState extends State { list: model.medicationFrequencyList, okText: TranslationBase.of(context).ok, + selectedValue: _selectedMedicationFrequency, okFunction: (selectedValue) { setState(() { _selectedMedicationFrequency =