From 47de010a88122e24dfbc7700d8ea2094cf79dda4 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Thu, 23 Apr 2020 21:02:08 -0400 Subject: [PATCH 1/2] Puts data from sequential calls to StudyInfo into the right place. Sets the required document flag correctly. --- crc/scripts/script.py | 6 +++++- crc/scripts/study_info.py | 2 -- crc/services/study_service.py | 2 +- .../bpmn/documents_approvals/documents_approvals.bpmn | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/crc/scripts/script.py b/crc/scripts/script.py index dfa2512e..69c505a3 100644 --- a/crc/scripts/script.py +++ b/crc/scripts/script.py @@ -54,7 +54,11 @@ class Script(object): return all_subclasses def add_data_to_task(self, task, data): - task.data[self.__class__.__name__] = data + key = self.__class__.__name__ + if key in task.data: + task.data[key].update(data) + else: + task.data[key] = data class ScriptValidationError: diff --git a/crc/scripts/study_info.py b/crc/scripts/study_info.py index 5fcca820..d9dcfb69 100644 --- a/crc/scripts/study_info.py +++ b/crc/scripts/study_info.py @@ -95,8 +95,6 @@ class StudyInfo(Script): if cmd == 'documents_status': self.add_data_to_task(task, {cmd: StudyService().get_documents_status(study_id)}) - task.data["study"] = study_info - def check_args(self, args): if len(args) != 1 or (args[0] not in StudyInfo.type_options): diff --git a/crc/services/study_service.py b/crc/services/study_service.py index 013f64b5..308c908f 100644 --- a/crc/services/study_service.py +++ b/crc/services/study_service.py @@ -94,7 +94,7 @@ class StudyService(object): doc_service = Documents() # Get PB required docs - pb_docs = ProtocolBuilderService.get_required_docs(study_id) + pb_docs = ProtocolBuilderService.get_required_docs(study_id=study_id, as_objects=True) # Get required docs for study study_docs = doc_service.get_documents(study_id=study_id, pb_docs=pb_docs) diff --git a/crc/static/bpmn/documents_approvals/documents_approvals.bpmn b/crc/static/bpmn/documents_approvals/documents_approvals.bpmn index 95f648a0..c9f4cbdc 100644 --- a/crc/static/bpmn/documents_approvals/documents_approvals.bpmn +++ b/crc/static/bpmn/documents_approvals/documents_approvals.bpmn @@ -15,15 +15,15 @@ |:-------------- |:-------- |:------ | {% for approval in StudyInfo.approvals -%} | [{{approval.display_name}}](/workflow/{{approval.id}}) | {{approval.status}} | [Context here](/help/{{approval.workflow_spec_id}}) | -{% endfor -%} +{% endfor %} ## Documents | Code | Status | Help | |:-------------- |:-------- |:------ | -{% for doc in study.documents_status -%} +{% for doc in StudyInfo.documents_status -%} | [{{doc.code}}](/study/{{doc.study_id}}/workflow/{{doc.workflow_id}}) | {{doc.status}} | [Context here](/help/{{doc.workflow_spec_id}}) | -{% endfor -%} +{% endfor %} From af1bb9f80d7918da67ed798680205623480141d7 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Thu, 23 Apr 2020 23:32:20 -0400 Subject: [PATCH 2/2] Adds more useful metadata to approvals and documents status scripts. Fleshes out and pretties up Documents & Approvals screen --- crc/scripts/study_info.py | 13 +++++++-- crc/services/study_service.py | 20 +++++++++++-- .../documents_approvals.bpmn | 28 +++++++++++++------ 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/crc/scripts/study_info.py b/crc/scripts/study_info.py index d9dcfb69..3d42b656 100644 --- a/crc/scripts/study_info.py +++ b/crc/scripts/study_info.py @@ -50,7 +50,8 @@ class StudyInfo(Script): "details": {}, "approvals": { - "id": 321, + "study_id": 12, + "workflow_id": 321, "display_name": "IRB API Details", "name": "irb_api_details", "status": WorkflowStatus.not_started.value, @@ -65,8 +66,14 @@ class StudyInfo(Script): 'Id': '12', 'Name': 'Certificate of Confidentiality Application', 'count': 0, - 'required': False, - 'code': 'AD_CoCApp' + 'required': True, + 'code': 'AD_CoCApp', + 'display_name': 'Certificate of Confidentiality Application', + 'file_id': 123, + 'task_id': 'abcdef14236890', + 'workflow_id': 456, + 'workflow_spec_id': 'irb_api_details', + 'status': 'complete', } ] } diff --git a/crc/services/study_service.py b/crc/services/study_service.py index 308c908f..25dbe1a2 100644 --- a/crc/services/study_service.py +++ b/crc/services/study_service.py @@ -80,7 +80,8 @@ class StudyService(object): for workflow in workflows: workflow: WorkflowModel = workflow approvals.append({ - 'id': workflow.id, + 'study_id': study_id, + 'workflow_id': workflow.id, 'display_name': workflow.workflow_spec.display_name, 'name': workflow.workflow_spec.display_name, 'status': workflow.status.value, @@ -104,14 +105,29 @@ class StudyService(object): # For each required doc, get file(s) for code, doc in study_docs.items(): + if not doc['required']: + continue + doc['study_id'] = study_id doc['code'] = code - doc_files = FileService.get_files(study_id=study_id, irb_doc_code=code) + + # Make a display name out of categories if none exists + if 'Name' in doc and len(doc['Name']) > 0: + doc['display_name'] = doc['Name'] + else: + name_list = [] + for cat_key in ['category1', 'category2', 'category3']: + if doc[cat_key] not in ['', 'NULL']: + name_list.append(doc[cat_key]) + doc['display_name'] = ' '.join(name_list) # For each file, get associated workflow status + doc_files = FileService.get_files(study_id=study_id, irb_doc_code=code) for file in doc_files: doc['file_id'] = file.id + doc['task_id'] = file.task_id doc['workflow_id'] = file.workflow_id + doc['workflow_spec_id'] = file.workflow_spec_id if doc['status'] is None: workflow: WorkflowModel = session.query(WorkflowModel).filter_by(id=file.workflow_id).first() diff --git a/crc/static/bpmn/documents_approvals/documents_approvals.bpmn b/crc/static/bpmn/documents_approvals/documents_approvals.bpmn index c9f4cbdc..953e0771 100644 --- a/crc/static/bpmn/documents_approvals/documents_approvals.bpmn +++ b/crc/static/bpmn/documents_approvals/documents_approvals.bpmn @@ -10,20 +10,30 @@ - ## Approvals -| Name | Status | Help | -|:-------------- |:-------- |:------ | + # Documents & Approvals + +> ## Protocol Document Management +> [Upload Protocol Here](/) + +> ## Approvals +> | Name | Status | Help | +|:---- |:------ |:---- | {% for approval in StudyInfo.approvals -%} -| [{{approval.display_name}}](/workflow/{{approval.id}}) | {{approval.status}} | [Context here](/help/{{approval.workflow_spec_id}}) | +| [{{approval.display_name}}](/study/{{approval.study_id}}/workflow/{{approval.workflow_id}}) | {{approval.status}} | [Context here](/help/{{approval.workflow_spec_id}}) | {% endfor %} - -## Documents -| Code | Status | Help | -|:-------------- |:-------- |:------ | +> ## Documents +> | Name | Status | Help | Download | +|:---- |:------ |:---- |:-------- | {% for doc in StudyInfo.documents_status -%} -| [{{doc.code}}](/study/{{doc.study_id}}/workflow/{{doc.workflow_id}}) | {{doc.status}} | [Context here](/help/{{doc.workflow_spec_id}}) | + {% if doc.file_id is defined -%} + | [{{doc.display_name}}](/study/{{doc.study_id}}/workflow/{{doc.workflow_id}}/task/{{doc.task_id}}) | {{doc.status}} | [Context here](/help/documents/{{doc.code}}) | [Download](/file/{{doc.file_id}}) | + {%- else -%} + | {{doc.display_name}} | Not started | [Context here](/help/documents/{{doc.code}}) | No file yet | + {%- endif %} {% endfor %} + +