2022-03-14 16:00:53 -04:00
|
|
|
from SpiffWorkflow.exceptions import WorkflowTaskExecException
|
|
|
|
|
2021-07-02 15:21:35 -04:00
|
|
|
from crc.scripts.script import Script
|
|
|
|
from crc.api.common import ApiError
|
|
|
|
from crc.services.protocol_builder import ProtocolBuilderService
|
2021-07-02 15:51:24 -04:00
|
|
|
from crc.services.study_service import StudyService
|
2022-02-09 08:50:00 -05:00
|
|
|
from crc.services.workflow_spec_service import WorkflowSpecService
|
2021-07-02 15:21:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
class CheckStudy(Script):
|
|
|
|
|
|
|
|
pb = ProtocolBuilderService()
|
|
|
|
|
|
|
|
def get_description(self):
|
2021-07-02 15:51:24 -04:00
|
|
|
return """Returns the Check Study data for a Study"""
|
2021-07-02 15:21:35 -04:00
|
|
|
|
|
|
|
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
|
2022-02-09 08:50:00 -05:00
|
|
|
spec_service = WorkflowSpecService()
|
|
|
|
categories = spec_service.get_categories()
|
|
|
|
study = StudyService.get_study(study_id, categories)
|
2021-07-02 15:51:24 -04:00
|
|
|
if study:
|
|
|
|
return {"DETAIL": "Passed validation.", "STATUS": "No Error"}
|
|
|
|
else:
|
2022-03-14 16:00:53 -04:00
|
|
|
raise WorkflowTaskExecException(task, 'Function check_study failed. There is no study for study_id {study_id}.')
|
2021-07-02 15:21:35 -04:00
|
|
|
|
|
|
|
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
|
|
|
|
check_study = self.pb.check_study(study_id)
|
|
|
|
if check_study:
|
|
|
|
return check_study
|
|
|
|
else:
|
2022-03-14 16:00:53 -04:00
|
|
|
raise WorkflowTaskExecException(task, 'There was a problem checking information for this study.')
|