diff --git a/crc/scripts/get_study_progress_status.py b/crc/scripts/get_study_progress_status.py new file mode 100644 index 00000000..d2d6d2ee --- /dev/null +++ b/crc/scripts/get_study_progress_status.py @@ -0,0 +1,21 @@ +from crc import session +from crc.models.study import StudyModel +from crc.scripts.script import Script + + +class GetStudyProgressStatus(Script): + + def get_description(self): + return """ + Get the progress status of the current study. + Progress status is only set when `status` is `in_progress`. + Progress status can be one of `in_progress`, `submitted_for_pre_review`, `in_pre_review`, `returned_from_pre_review`, `pre_review_complete`, `agenda_date_set`, `approved`, `approved_with_conditions`, `deferred`, or `disapproved`. + """ + + def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs): + return self.do_task(task, study_id, workflow_id, *args, **kwargs) + + def do_task(self, task, study_id, workflow_id, *args, **kwargs): + progress_status = session.query(StudyModel.progress_status).filter(StudyModel.id == study_id).scalar() + if progress_status: + return progress_status.value