From 6db5191e07226ef4a013f3f732cea746e0eb3dc3 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 8 Aug 2021 11:09:11 +0300 Subject: [PATCH] return the function code back --- lib/core/viewModel/SOAP_view_model.dart | 4 +- .../assessment/update_assessment_page.dart | 18 ++- .../objective/update_objective_page.dart | 132 +++++++++--------- .../soap_update/plan/update_plan_page.dart | 1 - .../subjective/update_subjective_page.dart | 90 ++++++------ 5 files changed, 117 insertions(+), 128 deletions(-) diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index a3320145..a74e4a42 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -363,8 +363,8 @@ class SOAPViewModel extends BaseViewModel { GetPhysicalExamReqModel getPhysicalExamReqModel = GetPhysicalExamReqModel( patientMRN: patientInfo.patientMRN, - episodeID: patientInfo.episodeNo.toString(), - appointmentNo: int.parse( + episodeID: patientInfo.episodeNo == null?"0":patientInfo.episodeNo.toString(), + appointmentNo: patientInfo.appointmentNo == null ?0:int.parse( patientInfo.appointmentNo.toString(), ), ); 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 c059c2b0..dfcbba50 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 @@ -507,15 +507,13 @@ class _UpdateAssessmentPageState extends State implements @override nextFunction(model) { - // TODO Elham* - widget.changePageViewIndex(3); - // if (mySelectedAssessmentList.isEmpty) { - // Helpers.showErrorToast( - // TranslationBase.of(context) - // .assessmentErrorMsg); - // } else { - // widget.changeLoadingState(true); - // widget.changePageViewIndex(3); - // } + if (mySelectedAssessmentList.isEmpty) { + Helpers.showErrorToast( + TranslationBase.of(context) + .assessmentErrorMsg); + } else { + widget.changeLoadingState(true); + widget.changePageViewIndex(3); + } } } 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 396d492d..cb245b7d 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 @@ -205,75 +205,71 @@ class _UpdateObjectivePageState extends State } submitUpdateObjectivePage(SOAPViewModel model) async { - // TODO Elham* - widget.changePageViewIndex(2); + if (mySelectedExamination.isNotEmpty) { + widget.changeLoadingState(true); + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - /// TODO Elham* move this logic to view model - // if (mySelectedExamination.isNotEmpty) { - // widget.changeLoadingState(true); - // Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - // - // DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - // PostPhysicalExamRequestModel postPhysicalExamRequestModel = - // new PostPhysicalExamRequestModel(); - // mySelectedExamination.forEach((exam) { - // if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == - // null) - // postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = - // []; - // ListHisProgNotePhysicalExaminationVM - // listHisProgNotePhysicalExaminationVM = - // 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 (widget.patientInfo.admissionNo != null && - // widget.patientInfo.admissionNo.isNotEmpty) { - // listHisProgNotePhysicalExaminationVM.admissionNo = - // int.parse(widget.patientInfo.admissionNo); - // } - // postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM - // .add(listHisProgNotePhysicalExaminationVM); - // }); - // - // if (model.patientPhysicalExamList.isEmpty) { - // await model.postPhysicalExam(postPhysicalExamRequestModel); - // } else { - // await model.patchPhysicalExam(postPhysicalExamRequestModel); - // } - // - // if (model.state == ViewState.ErrorLocal) { - // widget.changeLoadingState(false); - // Helpers.showErrorToast(model.error); - // } else { - // widget.changeLoadingState(true); - // widget.changePageViewIndex(2); - // } - // } else { - // Helpers.showErrorToast(TranslationBase.of(context).examinationErrorMsg); - // } + DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); + PostPhysicalExamRequestModel postPhysicalExamRequestModel = + new PostPhysicalExamRequestModel(); + mySelectedExamination.forEach((exam) { + if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == + null) + postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = + []; + ListHisProgNotePhysicalExaminationVM + listHisProgNotePhysicalExaminationVM = + ListHisProgNotePhysicalExaminationVM( + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo == null?0: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo == null?0: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 (widget.patientInfo.admissionNo != null && + widget.patientInfo.admissionNo.isNotEmpty) { + listHisProgNotePhysicalExaminationVM.admissionNo = + int.parse(widget.patientInfo.admissionNo); + } + postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM + .add(listHisProgNotePhysicalExaminationVM); + }); + + if (model.patientPhysicalExamList.isEmpty) { + await model.postPhysicalExam(postPhysicalExamRequestModel); + } else { + await model.patchPhysicalExam(postPhysicalExamRequestModel); + } + + if (model.state == ViewState.ErrorLocal) { + widget.changeLoadingState(false); + Helpers.showErrorToast(model.error); + } else { + widget.changeLoadingState(true); + widget.changePageViewIndex(2); + } + } else { + Helpers.showErrorToast(TranslationBase.of(context).examinationErrorMsg); + } } removeExamination(MasterKeyModel 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 c627b151..16d53804 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 @@ -400,7 +400,6 @@ class _UpdatePlanPageState extends State implements PlanCallBack @override nextFunction(model) { - print("dfdfdf"); if (progressNoteController.text.isNotEmpty) { if (isAddProgress) { submitPlan(model); 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 269f20a5..5971fb6f 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 @@ -334,54 +334,50 @@ class _UpdateSubjectivePageState extends State complaintsControllerError = ''; medicationControllerError = ''; illnessControllerError = ''; + if (complaintsController.text.isNotEmpty && + illnessController.text.isNotEmpty && + complaintsController.text.length > 25) { + await postChiefComplaint(model: model); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } + if (myHistoryList.length != 0) { + await postHistories(model: model, myHistoryList: myHistoryList); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } + } + if (myAllergiesList.length != 0) { + await postAllergy(myAllergiesList: myAllergiesList, model: model); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } + } + widget.changeLoadingState(true); + + widget.changePageViewIndex(1); + } else { + setState(() { + if (complaintsController.text.isEmpty) { + complaintsControllerError = TranslationBase.of(context).emptyMessage; + } else if (complaintsController.text.length < 25) { + complaintsControllerError = + TranslationBase.of(context).chiefComplaintLength; + } + + if (illnessController.text.isEmpty) { + illnessControllerError = TranslationBase.of(context).emptyMessage; + } - ///TODO Elham* - /// - widget.changePageViewIndex(1); - // if (complaintsController.text.isNotEmpty && - // illnessController.text.isNotEmpty && - // complaintsController.text.length > 25) { - // await postChiefComplaint(model: model); - // if (model.state == ViewState.ErrorLocal) { - // Helpers.showErrorToast(model.error); - // } - // if (myHistoryList.length != 0) { - // await postHistories(model: model, myHistoryList: myHistoryList); - // if (model.state == ViewState.ErrorLocal) { - // Helpers.showErrorToast(model.error); - // } - // } - // if (myAllergiesList.length != 0) { - // await postAllergy(myAllergiesList: myAllergiesList, model: model); - // if (model.state == ViewState.ErrorLocal) { - // Helpers.showErrorToast(model.error); - // } - // } - // widget.changeLoadingState(true); - // - // widget.changePageViewIndex(1); - // } else { - // setState(() { - // if (complaintsController.text.isEmpty) { - // complaintsControllerError = TranslationBase.of(context).emptyMessage; - // } else if (complaintsController.text.length < 25) { - // complaintsControllerError = - // TranslationBase.of(context).chiefComplaintLength; - // } - // - // if (illnessController.text.isEmpty) { - // illnessControllerError = TranslationBase.of(context).emptyMessage; - // } - // - // if (medicationController.text.isEmpty) { - // medicationControllerError = TranslationBase.of(context).emptyMessage; - // } - // }); - // - // widget.changeLoadingState(false); - // Helpers.showErrorToast( - // TranslationBase.of(context).chiefComplaintErrorMsg); - // } + if (medicationController.text.isEmpty) { + medicationControllerError = TranslationBase.of(context).emptyMessage; + } + }); + + widget.changeLoadingState(false); + Helpers.showErrorToast( + TranslationBase.of(context).chiefComplaintErrorMsg); + } } postAllergy(