Change the study_sponsors script so that we can actually call it :
var = study_info('sponsors') to keep it more in line with other scripts that we have
This commit is contained in:
parent
1815a4b657
commit
e598994d34
|
@ -29,6 +29,33 @@ class StudyInfo(Script):
|
||||||
"ind_number": "1234",
|
"ind_number": "1234",
|
||||||
"inactive": False
|
"inactive": False
|
||||||
},
|
},
|
||||||
|
"sponsors": [
|
||||||
|
{
|
||||||
|
"COMMONRULEAGENCY": None,
|
||||||
|
"SPONSOR_ID": 2453,
|
||||||
|
"SP_NAME": "Abbott Ltd",
|
||||||
|
"SP_TYPE": "Private",
|
||||||
|
"SP_TYPE_GROUP_NAME": None,
|
||||||
|
"SS_STUDY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"COMMONRULEAGENCY": None,
|
||||||
|
"SPONSOR_ID": 2387,
|
||||||
|
"SP_NAME": "Abbott-Price",
|
||||||
|
"SP_TYPE": "Incoming Sub Award",
|
||||||
|
"SP_TYPE_GROUP_NAME": "Government",
|
||||||
|
"SS_STUDY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"COMMONRULEAGENCY": None,
|
||||||
|
"SPONSOR_ID": 1996,
|
||||||
|
"SP_NAME": "Abernathy-Heidenreich",
|
||||||
|
"SP_TYPE": "Foundation/Not for Profit",
|
||||||
|
"SP_TYPE_GROUP_NAME": "Other External Funding",
|
||||||
|
"SS_STUDY": 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
"investigators": {
|
"investigators": {
|
||||||
'PI': {
|
'PI': {
|
||||||
'label': ProtocolBuilderInvestigatorType.PI.value,
|
'label': ProtocolBuilderInvestigatorType.PI.value,
|
||||||
|
@ -165,6 +192,33 @@ Returns information specific to the protocol.
|
||||||
"ind_number": "1234",
|
"ind_number": "1234",
|
||||||
"inactive": False
|
"inactive": False
|
||||||
},
|
},
|
||||||
|
"sponsors": [
|
||||||
|
{
|
||||||
|
"COMMONRULEAGENCY": None,
|
||||||
|
"SPONSOR_ID": 2453,
|
||||||
|
"SP_NAME": "Abbott Ltd",
|
||||||
|
"SP_TYPE": "Private",
|
||||||
|
"SP_TYPE_GROUP_NAME": None,
|
||||||
|
"SS_STUDY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"COMMONRULEAGENCY": None,
|
||||||
|
"SPONSOR_ID": 2387,
|
||||||
|
"SP_NAME": "Abbott-Price",
|
||||||
|
"SP_TYPE": "Incoming Sub Award",
|
||||||
|
"SP_TYPE_GROUP_NAME": "Government",
|
||||||
|
"SS_STUDY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"COMMONRULEAGENCY": None,
|
||||||
|
"SPONSOR_ID": 1996,
|
||||||
|
"SP_NAME": "Abernathy-Heidenreich",
|
||||||
|
"SP_TYPE": "Foundation/Not for Profit",
|
||||||
|
"SP_TYPE_GROUP_NAME": "Other External Funding",
|
||||||
|
"SS_STUDY": 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
"investigators": {
|
"investigators": {
|
||||||
"PI": {
|
"PI": {
|
||||||
"label": ProtocolBuilderInvestigatorType.PI.value,
|
"label": ProtocolBuilderInvestigatorType.PI.value,
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
import json
|
|
||||||
|
|
||||||
from crc.api.common import ApiError
|
|
||||||
from crc.scripts.script import Script
|
|
||||||
from crc.services.protocol_builder import ProtocolBuilderService
|
|
||||||
|
|
||||||
|
|
||||||
class StudySponsors(Script):
|
|
||||||
"""Please see the detailed description that is provided below. """
|
|
||||||
|
|
||||||
pb = ProtocolBuilderService()
|
|
||||||
|
|
||||||
# This is used for test/workflow validation, as well as documentation.
|
|
||||||
example_data = [
|
|
||||||
{
|
|
||||||
"COMMONRULEAGENCY": None,
|
|
||||||
"SPONSOR_ID": 2453,
|
|
||||||
"SP_NAME": "Abbott Ltd",
|
|
||||||
"SP_TYPE": "Private",
|
|
||||||
"SP_TYPE_GROUP_NAME": None,
|
|
||||||
"SS_STUDY": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"COMMONRULEAGENCY": None,
|
|
||||||
"SPONSOR_ID": 2387,
|
|
||||||
"SP_NAME": "Abbott-Price",
|
|
||||||
"SP_TYPE": "Incoming Sub Award",
|
|
||||||
"SP_TYPE_GROUP_NAME": "Government",
|
|
||||||
"SS_STUDY": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"COMMONRULEAGENCY": None,
|
|
||||||
"SPONSOR_ID": 1996,
|
|
||||||
"SP_NAME": "Abernathy-Heidenreich",
|
|
||||||
"SP_TYPE": "Foundation/Not for Profit",
|
|
||||||
"SP_TYPE_GROUP_NAME": "Other External Funding",
|
|
||||||
"SS_STUDY": 2
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
def example_to_string(self, key):
|
|
||||||
return json.dumps(self.example_data['StudyInfo'][key], indent=2, separators=(',', ': '))
|
|
||||||
|
|
||||||
def get_description(self):
|
|
||||||
return ""
|
|
||||||
# return """
|
|
||||||
# Returns a list of sponsors related to a study in the following format:
|
|
||||||
# {{example}}
|
|
||||||
#z """.format(example=json.dumps(self.example_data, index=2, separators=(',', ': ')))
|
|
||||||
|
|
||||||
def check_args(self, args):
|
|
||||||
if len(args) > 0:
|
|
||||||
raise ApiError(code="invalid_argument",
|
|
||||||
message="The Sponsor script does not take any arguments. "
|
|
||||||
"It returns the list of sponsors for the current study only. ")
|
|
||||||
|
|
||||||
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
|
|
||||||
"""For validation only, pretend no results come back from pb"""
|
|
||||||
self.check_args(args)
|
|
||||||
return self.example_data
|
|
||||||
|
|
||||||
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
|
|
||||||
self.check_args(args)
|
|
||||||
retval = ProtocolBuilderService.get_sponsors(study_id)
|
|
||||||
# Check on returning box, as in return Box(retval) - may not work with list.
|
|
||||||
return retval
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0kmksnn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.3">
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0kmksnn" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.0">
|
||||||
<bpmn:process id="Process_0exnnpv" isExecutable="true">
|
<bpmn:process id="Process_0exnnpv" isExecutable="true">
|
||||||
<bpmn:startEvent id="StartEvent_1">
|
<bpmn:startEvent id="StartEvent_1">
|
||||||
<bpmn:outgoing>SequenceFlow_1nfe5m9</bpmn:outgoing>
|
<bpmn:outgoing>SequenceFlow_1nfe5m9</bpmn:outgoing>
|
||||||
|
@ -8,7 +8,8 @@
|
||||||
<bpmn:scriptTask id="Task_Script_Load_Study_Sponsors" name="Load Study Sponsors">
|
<bpmn:scriptTask id="Task_Script_Load_Study_Sponsors" name="Load Study Sponsors">
|
||||||
<bpmn:incoming>SequenceFlow_1nfe5m9</bpmn:incoming>
|
<bpmn:incoming>SequenceFlow_1nfe5m9</bpmn:incoming>
|
||||||
<bpmn:outgoing>SequenceFlow_1bqiin0</bpmn:outgoing>
|
<bpmn:outgoing>SequenceFlow_1bqiin0</bpmn:outgoing>
|
||||||
<bpmn:script>sponsors = study_sponsors()</bpmn:script>
|
<bpmn:script>sponsors = study_info('sponsors')
|
||||||
|
</bpmn:script>
|
||||||
</bpmn:scriptTask>
|
</bpmn:scriptTask>
|
||||||
<bpmn:sequenceFlow id="SequenceFlow_1bqiin0" sourceRef="Task_Script_Load_Study_Sponsors" targetRef="EndEvent_171dj09" />
|
<bpmn:sequenceFlow id="SequenceFlow_1bqiin0" sourceRef="Task_Script_Load_Study_Sponsors" targetRef="EndEvent_171dj09" />
|
||||||
<bpmn:endEvent id="EndEvent_171dj09">
|
<bpmn:endEvent id="EndEvent_171dj09">
|
||||||
|
|
|
@ -4,7 +4,6 @@ from tests.base_test import BaseTest
|
||||||
|
|
||||||
from crc import session, app
|
from crc import session, app
|
||||||
from crc.models.study import StudyModel
|
from crc.models.study import StudyModel
|
||||||
from crc.scripts.study_sponsors import StudySponsors
|
|
||||||
from crc.services.study_service import StudyService
|
from crc.services.study_service import StudyService
|
||||||
from crc.services.workflow_processor import WorkflowProcessor
|
from crc.services.workflow_processor import WorkflowProcessor
|
||||||
from crc.services.workflow_service import WorkflowService
|
from crc.services.workflow_service import WorkflowService
|
||||||
|
@ -13,7 +12,12 @@ class TestSudySponsorsScript(BaseTest):
|
||||||
test_uid = "dhf8r"
|
test_uid = "dhf8r"
|
||||||
test_study_id = 1
|
test_study_id = 1
|
||||||
|
|
||||||
|
|
||||||
def test_study_sponsors_script_validation(self):
|
def test_study_sponsors_script_validation(self):
|
||||||
|
self.load_example_data() # study_info script complains if irb_documents.xls is not loaded
|
||||||
|
# during the validate phase I'm going to assume that we will never
|
||||||
|
# have a case where irb_documents.xls is not loaded ??
|
||||||
|
|
||||||
self.load_test_spec("study_sponsors")
|
self.load_test_spec("study_sponsors")
|
||||||
WorkflowService.test_spec("study_sponsors") # This would raise errors if it didn't validate
|
WorkflowService.test_spec("study_sponsors") # This would raise errors if it didn't validate
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue