Added study_id to workflow_api

This commit is contained in:
mike cullerton 2021-04-29 14:29:21 -04:00
parent 09d8c8bcba
commit 24c818bf31
3 changed files with 9 additions and 5 deletions

View File

@ -427,7 +427,7 @@ paths:
- name: spec_id
in: path
required: true
description: The unique id of an existing workflow specification to modify.
description: The unique id of an existing workflow specification.
schema:
type: string
get:
@ -1640,6 +1640,8 @@ components:
type: integer
num_tasks_incomplete:
type: integer
study_id:
type: integer
example:
id: 291234

View File

@ -191,7 +191,7 @@ class DocumentDirectory(object):
class WorkflowApi(object):
def __init__(self, id, status, next_task, navigation,
spec_version, is_latest_spec, workflow_spec_id, total_tasks, completed_tasks,
last_updated, is_review, title):
last_updated, is_review, title, study_id):
self.id = id
self.status = status
self.next_task = next_task # The next task that requires user input.
@ -204,13 +204,14 @@ class WorkflowApi(object):
self.last_updated = last_updated
self.title = title
self.is_review = is_review
self.study_id = study_id or ''
class WorkflowApiSchema(ma.Schema):
class Meta:
model = WorkflowApi
fields = ["id", "status", "next_task", "navigation",
"workflow_spec_id", "spec_version", "is_latest_spec", "total_tasks", "completed_tasks",
"last_updated", "is_review", "title"]
"last_updated", "is_review", "title", "study_id"]
unknown = INCLUDE
status = EnumField(WorkflowStatus)
@ -221,7 +222,7 @@ class WorkflowApiSchema(ma.Schema):
def make_workflow(self, data, **kwargs):
keys = ['id', 'status', 'next_task', 'navigation',
'workflow_spec_id', 'spec_version', 'is_latest_spec', "total_tasks", "completed_tasks",
"last_updated", "is_review", "title"]
"last_updated", "is_review", "title", "study_id"]
filtered_fields = {key: data[key] for key in keys}
filtered_fields['next_task'] = TaskSchema().make_task(data['next_task'])
return WorkflowApi(**filtered_fields)

View File

@ -408,7 +408,8 @@ class WorkflowService(object):
completed_tasks=processor.workflow_model.completed_tasks,
last_updated=processor.workflow_model.last_updated,
is_review=is_review,
title=spec.display_name
title=spec.display_name,
study_id=processor.workflow_model.study_id or None
)
if not next_task: # The Next Task can be requested to be a certain task, useful for parallel tasks.
# This may or may not work, sometimes there is no next task to complete.