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 6336f8ed..b41cb4fe 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 @@ -4,15 +4,15 @@ import 'package:doctor_app_flutter/core/enum/view_state.dart'; import 'package:doctor_app_flutter/core/model/SOAP/progress_note/GetGetProgressNoteResModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/progress_note/get_progress_note_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/progress_note/post_progress_note_request_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; -import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/plan/plan_call_back.dart'; import 'package:doctor_app_flutter/utils/date-utils.dart'; -import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; @@ -30,31 +30,20 @@ class UpdatePlanPage extends StatefulWidget { final int currentIndex; - UpdatePlanPage( - {Key key, - this.changePageViewIndex, - this.patientInfo, - this.changeLoadingState, - this.currentIndex, - this.sOAPViewModel, - this.changeStateFun}); + UpdatePlanPage({Key key, this.changePageViewIndex, this.patientInfo, this.changeLoadingState, this.currentIndex, this.sOAPViewModel, this.changeStateFun}); @override _UpdatePlanPageState createState() => _UpdatePlanPageState(); } -class _UpdatePlanPageState extends State - implements PlanCallBack { +class _UpdatePlanPageState extends State implements PlanCallBack { 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, @@ -76,35 +65,25 @@ class _UpdatePlanPageState extends State } } - getPatientProgressNote(SOAPViewModel model, - {bool isAddProgress = false}) async { - GetProgressNoteReqModel getGetProgressNoteReqModel = - GetProgressNoteReqModel( - appointmentNo: - int.parse(widget.patientInfo.appointmentNo.toString()), - patientMRN: widget.patientInfo.patientMRN, - episodeID: widget.patientInfo.episodeNo.toString(), - editedBy: '', - doctorID: ''); - await widget.sOAPViewModel - .getPatientProgressNote(getGetProgressNoteReqModel); + getPatientProgressNote(SOAPViewModel model, {bool isAddProgress = false}) async { + GetProgressNoteReqModel getGetProgressNoteReqModel = GetProgressNoteReqModel( + appointmentNo: int.parse(widget.patientInfo.appointmentNo.toString()), + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString(), + editedBy: '', + doctorID: ''); + await widget.sOAPViewModel.getPatientProgressNote(getGetProgressNoteReqModel); ///TODO set progressNote in model; if (widget.sOAPViewModel.patientProgressNoteList.isNotEmpty) { - progressNoteController.text = Utils.parseHtmlString( - widget.sOAPViewModel.patientProgressNoteList[0].planNote); + progressNoteController.text = Utils.parseHtmlString(widget.sOAPViewModel.patientProgressNoteList[0].planNote); patientProgressNote.planNote = progressNoteController.text; - patientProgressNote.createdByName = - widget.sOAPViewModel.patientProgressNoteList[0].createdByName; - patientProgressNote.createdOn = - widget.sOAPViewModel.patientProgressNoteList[0].createdOn; - patientProgressNote.editedOn = - widget.sOAPViewModel.patientProgressNoteList[0].editedOn; - patientProgressNote.editedByName = - widget.sOAPViewModel.patientProgressNoteList[0].editedByName; - patientProgressNote.appointmentNo = - widget.sOAPViewModel.patientProgressNoteList[0].appointmentNo; + patientProgressNote.createdByName = widget.sOAPViewModel.patientProgressNoteList[0].createdByName; + patientProgressNote.createdOn = widget.sOAPViewModel.patientProgressNoteList[0].createdOn; + patientProgressNote.editedOn = widget.sOAPViewModel.patientProgressNoteList[0].editedOn; + patientProgressNote.editedByName = widget.sOAPViewModel.patientProgressNoteList[0].editedByName; + patientProgressNote.appointmentNo = widget.sOAPViewModel.patientProgressNoteList[0].appointmentNo; setState(() { isAddProgress = isAddProgress; widget.sOAPViewModel.isAddProgress = isAddProgress; @@ -118,31 +97,22 @@ class _UpdatePlanPageState extends State return BaseView( onModelReady: (model) async { widget.sOAPViewModel.setPlanCallBack(this); - GetProgressNoteReqModel getGetProgressNoteReqModel = - GetProgressNoteReqModel( - appointmentNo: - int.parse(widget.patientInfo.appointmentNo.toString()), - patientMRN: widget.patientInfo.patientMRN, - episodeID: widget.patientInfo.episodeNo.toString(), - editedBy: '', - doctorID: ''); - await widget.sOAPViewModel - .getPatientProgressNote(getGetProgressNoteReqModel); + GetProgressNoteReqModel getGetProgressNoteReqModel = GetProgressNoteReqModel( + appointmentNo: int.parse(widget.patientInfo.appointmentNo.toString()), + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString(), + editedBy: '', + doctorID: ''); + await widget.sOAPViewModel.getPatientProgressNote(getGetProgressNoteReqModel); if (widget.sOAPViewModel.patientProgressNoteList.isNotEmpty) { - progressNoteController.text = Utils.parseHtmlString( - widget.sOAPViewModel.patientProgressNoteList[0].planNote); + progressNoteController.text = Utils.parseHtmlString(widget.sOAPViewModel.patientProgressNoteList[0].planNote); patientProgressNote.planNote = progressNoteController.text; - patientProgressNote.createdByName = - widget.sOAPViewModel.patientProgressNoteList[0].createdByName; - patientProgressNote.createdOn = - widget.sOAPViewModel.patientProgressNoteList[0].createdOn; - patientProgressNote.editedOn = - widget.sOAPViewModel.patientProgressNoteList[0].editedOn; - patientProgressNote.editedByName = - widget.sOAPViewModel.patientProgressNoteList[0].editedByName; - patientProgressNote.appointmentNo = - widget.sOAPViewModel.patientProgressNoteList[0].appointmentNo; + patientProgressNote.createdByName = widget.sOAPViewModel.patientProgressNoteList[0].createdByName; + patientProgressNote.createdOn = widget.sOAPViewModel.patientProgressNoteList[0].createdOn; + patientProgressNote.editedOn = widget.sOAPViewModel.patientProgressNoteList[0].editedOn; + patientProgressNote.editedByName = widget.sOAPViewModel.patientProgressNoteList[0].editedByName; + patientProgressNote.appointmentNo = widget.sOAPViewModel.patientProgressNoteList[0].appointmentNo; widget.sOAPViewModel.progressNoteText = progressNoteController.text; setState(() { @@ -185,19 +155,16 @@ 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) { setState(() { - patientProgressNote.planNote = - value; + patientProgressNote.planNote = value; model.progressNoteText = value; widget.changeStateFun(); }); @@ -207,73 +174,48 @@ class _UpdatePlanPageState extends State 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: [ AppText( 'Appointment No: ', - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3, letterSpacing: -0.4, color: Color(0xFF575757), ), AppText( - patientProgressNote - .appointmentNo != - null - ? patientProgressNote - .appointmentNo - .toString() - : '', + patientProgressNote.appointmentNo != null ? patientProgressNote.appointmentNo.toString() : '', fontWeight: FontWeight.w600, letterSpacing: -0.48, color: Color(0xFF2B353E), - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.6, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.6, ), ], ), 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: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.6, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.6, ) ], ), Row( - mainAxisAlignment: - MainAxisAlignment.end, - crossAxisAlignment: - CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, children: [ // Row( // children: [ @@ -288,19 +230,10 @@ class _UpdatePlanPageState extends State // ], // ), AppText( - patientProgressNote.createdOn != - null - ? AppDateUtils.getHour( - DateTime.parse( - patientProgressNote - .createdOn)) - : AppDateUtils.getHour( - DateTime.now()), + patientProgressNote.createdOn != null ? AppDateUtils.getHour(DateTime.parse(patientProgressNote.createdOn)) : AppDateUtils.getHour(DateTime.now()), fontWeight: FontWeight.w600, color: Color(0xFF575757), - fontSize: SizeConfig - .getTextMultiplierBasedOnWidth() * - 3.6, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.6, ) ], ), @@ -308,8 +241,7 @@ class _UpdatePlanPageState extends State height: 8, ), Row( - mainAxisAlignment: - MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( child: AppText( @@ -321,8 +253,7 @@ class _UpdatePlanPageState extends State onTap: () { setState(() { isAddProgress = true; - widget.sOAPViewModel - .isAddProgress = true; + widget.sOAPViewModel.isAddProgress = true; }); }, child: Icon( @@ -341,8 +272,7 @@ class _UpdatePlanPageState extends State isExpanded: isProgressExpanded, ), SizedBox( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 20 : 10), + height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 20 : 10), ), ], ), @@ -355,59 +285,51 @@ 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: widget.patientInfo.doctorId, - editedBy: ''); + PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + planNote: patientProgressNote.planNote, + doctorID: widget.patientInfo.doctorId, + editedBy: ''); if (widget.sOAPViewModel.patientProgressNoteList.isEmpty) { - await widget.sOAPViewModel - .postProgressNote(postProgressNoteRequestModel); + await widget.sOAPViewModel.postProgressNote(postProgressNoteRequestModel); } else { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); postProgressNoteRequestModel.editedBy = doctorProfile.doctorID; - await widget.sOAPViewModel - .patchProgressNote(postProgressNoteRequestModel); + await widget.sOAPViewModel.patchProgressNote(postProgressNoteRequestModel); } if (widget.sOAPViewModel.state == ViewState.ErrorLocal) { Utils.showErrorToast(widget.sOAPViewModel.error); } else { - GetProgressNoteReqModel getGetProgressNoteReqModel = - GetProgressNoteReqModel( - appointmentNo: - int.parse(widget.patientInfo.appointmentNo.toString()), - patientMRN: widget.patientInfo.patientMRN, - episodeID: widget.patientInfo.episodeNo.toString(), - editedBy: '', - doctorID: ''); - await widget.sOAPViewModel - .getPatientProgressNote(getGetProgressNoteReqModel); + GetProgressNoteReqModel getGetProgressNoteReqModel = GetProgressNoteReqModel( + appointmentNo: int.parse(widget.patientInfo.appointmentNo.toString()), + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString(), + editedBy: '', + doctorID: ''); + await widget.sOAPViewModel.getPatientProgressNote(getGetProgressNoteReqModel); if (widget.sOAPViewModel.patientProgressNoteList.isNotEmpty) { - progressNoteController.text = Utils.parseHtmlString( - widget.sOAPViewModel.patientProgressNoteList[0].planNote); + progressNoteController.text = Utils.parseHtmlString(widget.sOAPViewModel.patientProgressNoteList[0].planNote); patientProgressNote.planNote = progressNoteController.text; - patientProgressNote.createdByName = - widget.sOAPViewModel.patientProgressNoteList[0].createdByName; - patientProgressNote.createdOn = - widget.sOAPViewModel.patientProgressNoteList[0].createdOn; - patientProgressNote.editedOn = - widget.sOAPViewModel.patientProgressNoteList[0].editedOn; - patientProgressNote.editedByName = - widget.sOAPViewModel.patientProgressNoteList[0].editedByName; - patientProgressNote.appointmentNo = - widget.sOAPViewModel.patientProgressNoteList[0].appointmentNo; + patientProgressNote.createdByName = widget.sOAPViewModel.patientProgressNoteList[0].createdByName; + patientProgressNote.createdOn = widget.sOAPViewModel.patientProgressNoteList[0].createdOn; + patientProgressNote.editedOn = widget.sOAPViewModel.patientProgressNoteList[0].editedOn; + patientProgressNote.editedByName = widget.sOAPViewModel.patientProgressNoteList[0].editedByName; + patientProgressNote.appointmentNo = widget.sOAPViewModel.patientProgressNoteList[0].appointmentNo; setState(() { isAddProgress = false; widget.sOAPViewModel.isAddProgress = false; }); } + + Navigator.of(context).pop(); + Utils.showErrorToast("Episode Created Successfully"); + } widget.changeLoadingState(false); } else {