diff --git a/lib/widgets/patients/profile/SOAP/assessment_page.dart b/lib/widgets/patients/profile/SOAP/assessment_page.dart index edb2f608..0e7a6b41 100644 --- a/lib/widgets/patients/profile/SOAP/assessment_page.dart +++ b/lib/widgets/patients/profile/SOAP/assessment_page.dart @@ -308,28 +308,34 @@ class _AssessmentPageState extends State { } submitAssessment(SOAPViewModel model) async { - PostAssessmentRequestModel postAssessmentRequestModel = - new PostAssessmentRequestModel( - patientMRN: 3120690, - episodeId: 200012117, - appointmentNo: 2016054573, - icdCodeDetails: [new IcdCodeDetails( - remarks: widget.mySelectedAssessment.remark, - complexDiagnosis: true, - conditionId: widget.mySelectedAssessment.selectedDiagnosisCondition.id, - diagnosisTypeId: widget.mySelectedAssessment.selectedDiagnosisType.id , - icdcode10Id: "1" - )] - ); + if (widget.mySelectedAssessment.selectedDiagnosisCondition != null && + widget.mySelectedAssessment.selectedDiagnosisType != null) { + PostAssessmentRequestModel postAssessmentRequestModel = + new PostAssessmentRequestModel( + patientMRN: 3120690, + episodeId: 200012117, + appointmentNo: 2016054573, + icdCodeDetails: [ + new IcdCodeDetails( + remarks: widget.mySelectedAssessment.remark, + complexDiagnosis: true, + conditionId: + widget.mySelectedAssessment.selectedDiagnosisCondition.id, + diagnosisTypeId: + widget.mySelectedAssessment.selectedDiagnosisType.id, + icdcode10Id: "1") + ]); - await model.postAssessment(postAssessmentRequestModel); + await model.postAssessment(postAssessmentRequestModel); - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + widget.changePageViewIndex(3); + } } else { - widget.changePageViewIndex(3); + helpers.showErrorToast('Please add required field correctly'); } - } openAssessmentDialog(BuildContext context) { diff --git a/lib/widgets/patients/profile/SOAP/objective_page.dart b/lib/widgets/patients/profile/SOAP/objective_page.dart index add9ca16..6b8a4661 100644 --- a/lib/widgets/patients/profile/SOAP/objective_page.dart +++ b/lib/widgets/patients/profile/SOAP/objective_page.dart @@ -352,11 +352,12 @@ class _ObjectivePageState extends State { if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error); } else { + widget.changePageViewIndex(2); } + } else { + helpers.showErrorToast('Please add required field correctly'); } - // TODO move it back to else stat when it work. - widget.changePageViewIndex(2); } diff --git a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart index 9100cb76..c45ca457 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart @@ -277,13 +277,45 @@ class _SubjectivePageState extends State { {SOAPViewModel model, List myAllergiesList, List myHistoryList}) async { - await postChiefComplaint(model: model); - if (myHistoryList.length != 0) - await postHistories(model: model, myHistoryList: myHistoryList); - if (myAllergiesList.length != 0) - await postAllergy(myAllergiesList: myAllergiesList, model: model); + formKey.currentState.save(); + formKey.currentState.validate(); + if(complaintsController.text.isNotEmpty && illnessController.text.isNotEmpty && complaintsController.text.length>25) { + await postChiefComplaint(model: model); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + if (myHistoryList.length != 0) { + await postHistories(model: model, myHistoryList: myHistoryList); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + if (myAllergiesList.length != 0) { + await postAllergy(myAllergiesList: myAllergiesList, model: model); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + widget.changePageViewIndex(1); + } + } + + } + } else { + if (myAllergiesList.length != 0) { + await postAllergy(myAllergiesList: myAllergiesList, model: model); + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + widget.changePageViewIndex(1); + } + } else { + widget.changePageViewIndex(1); + } + } + } + } else { + helpers.showErrorToast('Please add required field correctly'); + } - widget.changePageViewIndex(1); } postAllergy( @@ -362,9 +394,6 @@ class _SubjectivePageState extends State { await model.postChiefComplaint(postChiefComplaintRequestModel); - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } } }