From 8c66a3d2efc528affa821e0a85faf49cd7ef604a Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 2 Dec 2021 15:30:47 -0500 Subject: [PATCH] Script to get the status of the current script --- crc/scripts/get_study_status.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 crc/scripts/get_study_status.py diff --git a/crc/scripts/get_study_status.py b/crc/scripts/get_study_status.py new file mode 100644 index 00000000..fea9d656 --- /dev/null +++ b/crc/scripts/get_study_status.py @@ -0,0 +1,18 @@ +from crc import session +from crc.models.study import StudyModel +from crc.scripts.script import Script + + +class StudyStatus(Script): + + def get_description(self): + return """Get the status of the current study. + Status can be one of `in_progress`, `hold`, `open_for_enrollment`, or `abandoned`.""" + + 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): + study_status = session.query(StudyModel.status).filter(StudyModel.id == study_id).scalar() + if study_status: + return study_status.value