From c69f122713f05ab93645e5a5ea133e0d3791f37f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 8 Jul 2021 16:31:35 +0300 Subject: [PATCH] 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) ], ),