cr-connect-workflow/crc/scripts/get_irb_info.py
Dan 483d7e858b Improved Errors - Pick up on the new task_trace information in WorkflowException and pass it on through the api.
Also:  All script tasks should raise WorkflowTaskExecExceptions - NOT APIExceptions - this is because our scripts are executed by Spiff (not the other way around)  so the errors need to pass fluidly through spiff, and come back to use THEN we can convert them to APIErrors.  Otherwise we lose all kinds of good information about the error.
2022-03-14 16:00:53 -04:00

25 lines
854 B
Python

from SpiffWorkflow.exceptions import WorkflowTaskExecException
from crc.scripts.script import Script
from crc.api.common import ApiError
from crc.services.protocol_builder import ProtocolBuilderService
class IRBInfo(Script):
pb = ProtocolBuilderService()
def get_description(self):
return """Returns the IRB Info data for a Study"""
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
return isinstance(study_id, int)
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
irb_info = self.pb.get_irb_info(study_id)
if irb_info:
return irb_info
else:
raise WorkflowTaskExecException(task, f'get_irb_info failed. There was a problem retrieving IRB Info'
f' for study {study_id}.')