2020-05-07 17:57:24 +00:00
|
|
|
import json
|
2020-04-20 20:02:13 +00:00
|
|
|
|
2020-05-07 17:57:24 +00:00
|
|
|
from crc import session
|
2020-03-03 18:50:22 +00:00
|
|
|
from crc.api.common import ApiError
|
2020-08-04 20:42:35 +00:00
|
|
|
from crc.models.protocol_builder import ProtocolBuilderInvestigatorType
|
Created a "StudyService" and moved all complex logic around study manipulation out of the study api, and this service, as things were getting complicated. The Workflow Processor no longer creates the WorkflowModel, the study object handles that, and only passes the model into the workflow processor when it is ready to start the workflow.
Created a Study object (seperate from the StudyModel) that can cronstructed on request, and contains a different data structure than we store in the DB. This allows us to return underlying Categories and Workflows in a clean way.
Added a new status to workflows called "not_started", meaning we have not yet instantiated a processor or created a BPMN, they have no version yet and no stored data, just the possiblity of being started.
The Top Level Workflow or "Master" workflow is now a part of the sample data, and loaded at all times.
Removed the ability to "add a workflow to a study" and "remove a workflow from a study", a study contains all possible workflows by definition.
Example data no longer creates users or studies, it just creates the specs.
2020-03-30 12:00:16 +00:00
|
|
|
from crc.models.study import StudyModel, StudySchema
|
2020-04-23 23:25:01 +00:00
|
|
|
from crc.models.workflow import WorkflowStatus
|
2020-05-07 17:57:24 +00:00
|
|
|
from crc.scripts.script import Script
|
2020-05-11 21:42:24 +00:00
|
|
|
from crc.services.file_service import FileService
|
2020-03-03 18:50:22 +00:00
|
|
|
from crc.services.protocol_builder import ProtocolBuilderService
|
2020-04-23 18:40:05 +00:00
|
|
|
from crc.services.study_service import StudyService
|
2020-07-24 16:08:46 +00:00
|
|
|
from box import Box
|
2020-03-03 18:50:22 +00:00
|
|
|
|
|
|
|
class StudyInfo(Script):
|
2020-05-07 17:57:24 +00:00
|
|
|
"""Please see the detailed description that is provided below. """
|
2020-04-20 20:02:13 +00:00
|
|
|
|
2020-03-03 18:50:22 +00:00
|
|
|
pb = ProtocolBuilderService()
|
2020-11-04 19:34:10 +00:00
|
|
|
type_options = ['info', 'investigators', 'roles', 'details', 'approvals', 'documents', 'protocol','sponsors']
|
2020-03-03 18:50:22 +00:00
|
|
|
|
2020-05-07 17:57:24 +00:00
|
|
|
# This is used for test/workflow validation, as well as documentation.
|
|
|
|
example_data = {
|
|
|
|
"StudyInfo": {
|
|
|
|
"info": {
|
|
|
|
"id": 12,
|
|
|
|
"title": "test",
|
|
|
|
"primary_investigator_id": 21,
|
|
|
|
"user_uid": "dif84",
|
|
|
|
"sponsor": "sponsor",
|
|
|
|
"ind_number": "1234",
|
|
|
|
"inactive": False
|
|
|
|
},
|
2020-11-05 15:31:47 +00:00
|
|
|
"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
|
|
|
|
}
|
|
|
|
],
|
|
|
|
|
2020-05-07 17:57:24 +00:00
|
|
|
"investigators": {
|
|
|
|
'PI': {
|
2020-08-04 20:42:35 +00:00
|
|
|
'label': ProtocolBuilderInvestigatorType.PI.value,
|
2020-05-07 17:57:24 +00:00
|
|
|
'display': 'Always',
|
|
|
|
'unique': 'Yes',
|
|
|
|
'user_id': 'dhf8r',
|
|
|
|
'display_name': 'Dan Funk',
|
|
|
|
'given_name': 'Dan',
|
|
|
|
'email': 'dhf8r@virginia.edu',
|
|
|
|
'telephone_number': '+1 (434) 924-1723',
|
|
|
|
'title': "E42:He's a hoopy frood",
|
|
|
|
'department': 'E0:EN-Eng Study of Parallel Universes',
|
|
|
|
'affiliation': 'faculty',
|
|
|
|
'sponsor_type': 'Staff'},
|
|
|
|
'SC_I': {
|
|
|
|
'label': 'Study Coordinator I',
|
|
|
|
'display': 'Always',
|
|
|
|
'unique': 'Yes',
|
|
|
|
'user_id': None},
|
|
|
|
'DC': {
|
|
|
|
'label': 'Department Contact',
|
|
|
|
'display': 'Optional',
|
|
|
|
'unique': 'Yes',
|
|
|
|
'user_id': 'asd3v',
|
|
|
|
'error': 'Unable to locate a user with id asd3v in LDAP'}
|
|
|
|
},
|
|
|
|
"documents": {
|
|
|
|
'AD_CoCApp': {'category1': 'Ancillary Document', 'category2': 'CoC Application', 'category3': '',
|
|
|
|
'Who Uploads?': 'CRC', 'id': '12',
|
|
|
|
'description': 'Certificate of Confidentiality Application', 'required': False,
|
|
|
|
'study_id': 1, 'code': 'AD_CoCApp', 'display_name': 'Ancillary Document / CoC Application',
|
|
|
|
'count': 0, 'files': []},
|
|
|
|
'UVACompl_PRCAppr': {'category1': 'UVA Compliance', 'category2': 'PRC Approval', 'category3': '',
|
|
|
|
'Who Uploads?': 'CRC', 'id': '6', 'description': "Cancer Center's PRC Approval Form",
|
|
|
|
'required': True, 'study_id': 1, 'code': 'UVACompl_PRCAppr',
|
|
|
|
'display_name': 'UVA Compliance / PRC Approval', 'count': 1, 'files': [
|
|
|
|
{'file_id': 10,
|
|
|
|
'task_id': 'fakingthisout',
|
|
|
|
'workflow_id': 2,
|
|
|
|
'workflow_spec_id': 'docx'}],
|
|
|
|
'status': 'complete'}
|
|
|
|
},
|
|
|
|
"details":
|
|
|
|
{},
|
|
|
|
"approvals": {
|
|
|
|
"study_id": 12,
|
|
|
|
"workflow_id": 321,
|
|
|
|
"display_name": "IRB API Details",
|
|
|
|
"name": "irb_api_details",
|
|
|
|
"status": WorkflowStatus.not_started.value,
|
|
|
|
"workflow_spec_id": "irb_api_details",
|
|
|
|
},
|
|
|
|
'protocol': {
|
|
|
|
id: 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def example_to_string(self, key):
|
|
|
|
return json.dumps(self.example_data['StudyInfo'][key], indent=2, separators=(',', ': '))
|
|
|
|
|
2020-03-03 18:50:22 +00:00
|
|
|
def get_description(self):
|
2020-05-07 17:57:24 +00:00
|
|
|
return """
|
|
|
|
StudyInfo [TYPE], where TYPE is one of 'info', 'investigators', 'details', 'approvals',
|
|
|
|
'documents' or 'protocol'.
|
|
|
|
|
|
|
|
Adds details about the current study to the Task Data. The type of information required should be
|
|
|
|
provided as an argument. The following arguments are available:
|
|
|
|
|
|
|
|
### Info ###
|
|
|
|
Returns the basic information such as the id and title
|
|
|
|
```
|
|
|
|
{info_example}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Investigators ###
|
|
|
|
Returns detailed information about related personnel.
|
|
|
|
The order returned is guaranteed to match the order provided in the investigators.xslx reference file.
|
2020-07-06 16:09:21 +00:00
|
|
|
Detailed information is added in from LDAP about each personnel based on their user_id.
|
2020-05-07 17:57:24 +00:00
|
|
|
```
|
|
|
|
{investigators_example}
|
|
|
|
```
|
|
|
|
|
2020-07-06 16:09:21 +00:00
|
|
|
### Investigator Roles ###
|
|
|
|
Returns a list of all investigator roles, populating any roles with additional information available from
|
|
|
|
the Protocol Builder and LDAP. Its basically just like Investigators, but it includes all the roles, rather
|
|
|
|
that just those that were set in Protocol Builder.
|
|
|
|
```
|
|
|
|
{investigators_example}
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2020-05-07 17:57:24 +00:00
|
|
|
### Details ###
|
|
|
|
Returns detailed information about variable keys read in from the Protocol Builder.
|
|
|
|
|
|
|
|
### Approvals ###
|
|
|
|
Returns data about the status of approvals related to a study.
|
|
|
|
```
|
|
|
|
{approvals_example}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Documents ###
|
|
|
|
Returns a list of all documents that might be related to a study, reading all columns from the irb_documents.xsl
|
|
|
|
file. Including information about any files that were uploaded or generated that relate to a given document.
|
|
|
|
Please note this is just a few examples, ALL known document types are returned in an actual call.
|
|
|
|
```
|
|
|
|
{documents_example}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Protocol ###
|
|
|
|
Returns information specific to the protocol.
|
|
|
|
|
|
|
|
|
|
|
|
""".format(info_example=self.example_to_string("info"),
|
|
|
|
investigators_example=self.example_to_string("investigators"),
|
|
|
|
approvals_example=self.example_to_string("approvals"),
|
|
|
|
documents_example=self.example_to_string("documents"),
|
|
|
|
)
|
2020-03-03 18:50:22 +00:00
|
|
|
|
2020-05-24 20:13:15 +00:00
|
|
|
def do_task_validate_only(self, task, study_id, workflow_id, *args, **kwargs):
|
2020-03-27 12:29:31 +00:00
|
|
|
"""For validation only, pretend no results come back from pb"""
|
2020-07-28 15:02:49 +00:00
|
|
|
self.check_args(args,2)
|
Refactor the document details scripts. Now there is one script, it returns data in a consistent format, and has all the details required. The script is located in StudyInfo, with the argument documents. Make note that it returns a dictionary of ALL the documents, with a field to mark which ones are required according to the protocol builder. Others may become required if a workflow determines such, in which case the workflow will enforce this, and the document will have a count > 0, and additional details in a list of files within the document. I modified the XLS file to use lower case variable names, because it disturbed me, and we have to reference them frequently. Removed devious "as_object" variable on get_required_docs, so it behaves like the other methods all the time, and returns a dictionary. All the core business logic for finding the documents list now resides in the StudyService.
Because this changes the endpoint for all existing document details, I've modified all the test and static bpmn files to use the new format.
Shorting up the SponsorsList.xls file makes for slightly faster tests. seems senseless to load 5000 everytime we reset the data.
Tried to test all of this carefully in the test_study_details_documents.py test.
2020-04-29 19:08:11 +00:00
|
|
|
# Assure the reference file exists (a bit hacky, but we want to raise this error early, and cleanly.)
|
2020-05-11 21:42:24 +00:00
|
|
|
FileService.get_reference_file_data(FileService.DOCUMENT_LIST)
|
|
|
|
FileService.get_reference_file_data(FileService.INVESTIGATOR_LIST)
|
2020-07-28 15:02:49 +00:00
|
|
|
data = Box({
|
2020-04-06 20:56:00 +00:00
|
|
|
"study":{
|
|
|
|
"info": {
|
|
|
|
"id": 12,
|
|
|
|
"title": "test",
|
|
|
|
"primary_investigator_id":21,
|
|
|
|
"user_uid": "dif84",
|
|
|
|
"sponsor": "sponsor",
|
|
|
|
"ind_number": "1234",
|
|
|
|
"inactive": False
|
|
|
|
},
|
2020-11-05 15:31:47 +00:00
|
|
|
"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
|
|
|
|
}
|
|
|
|
],
|
|
|
|
|
2020-08-04 19:50:29 +00:00
|
|
|
"investigators": {
|
|
|
|
"PI": {
|
2020-08-04 20:42:35 +00:00
|
|
|
"label": ProtocolBuilderInvestigatorType.PI.value,
|
2020-08-04 19:50:29 +00:00
|
|
|
"display": "Always",
|
|
|
|
"unique": "Yes",
|
|
|
|
"user_id": "dhf8r",
|
|
|
|
"title": "",
|
|
|
|
"display_name": "Daniel Harold Funk",
|
|
|
|
"sponsor_type": "Contractor",
|
|
|
|
"telephone_number": "0000000000",
|
|
|
|
"department": "",
|
|
|
|
"email_address": "dhf8r@virginia.edu",
|
|
|
|
"given_name": "Daniel",
|
|
|
|
"uid": "dhf8r",
|
|
|
|
"affiliation": "",
|
|
|
|
"date_cached": "2020-08-04T19:32:08.006128+00:00"
|
2020-04-06 20:56:00 +00:00
|
|
|
},
|
2020-08-04 19:50:29 +00:00
|
|
|
"SC_I": {
|
2020-08-04 20:42:35 +00:00
|
|
|
"label": ProtocolBuilderInvestigatorType.SC_I.value,
|
2020-08-04 19:50:29 +00:00
|
|
|
"display": "Always",
|
|
|
|
"unique": "Yes",
|
|
|
|
"user_id": "ajl2j",
|
|
|
|
"title": "",
|
|
|
|
"display_name": "Aaron Louie",
|
|
|
|
"sponsor_type": "Contractor",
|
|
|
|
"telephone_number": "0000000000",
|
|
|
|
"department": "",
|
|
|
|
"email_address": "ajl2j@virginia.edu",
|
|
|
|
"given_name": "Aaron",
|
|
|
|
"uid": "ajl2j",
|
|
|
|
"affiliation": "sponsored",
|
|
|
|
"date_cached": "2020-08-04T19:32:10.699666+00:00"
|
|
|
|
},
|
|
|
|
"SC_II": {
|
2020-08-04 20:42:35 +00:00
|
|
|
"label": ProtocolBuilderInvestigatorType.SC_II.value,
|
2020-08-04 19:50:29 +00:00
|
|
|
"display": "Optional",
|
|
|
|
"unique": "Yes",
|
|
|
|
"user_id": "cah3us",
|
|
|
|
"title": "",
|
|
|
|
"display_name": "Alex Herron",
|
|
|
|
"sponsor_type": "Contractor",
|
|
|
|
"telephone_number": "0000000000",
|
|
|
|
"department": "",
|
|
|
|
"email_address": "cah3us@virginia.edu",
|
|
|
|
"given_name": "Alex",
|
|
|
|
"uid": "cah3us",
|
|
|
|
"affiliation": "sponsored",
|
|
|
|
"date_cached": "2020-08-04T19:32:10.075852+00:00"
|
2020-09-01 19:58:50 +00:00
|
|
|
},
|
2020-08-04 19:50:29 +00:00
|
|
|
},
|
|
|
|
"pi": {
|
|
|
|
"PI": {
|
2020-08-04 20:42:35 +00:00
|
|
|
"label": ProtocolBuilderInvestigatorType.PI.value,
|
2020-08-04 19:50:29 +00:00
|
|
|
"display": "Always",
|
|
|
|
"unique": "Yes",
|
|
|
|
"user_id": "dhf8r",
|
|
|
|
"title": "",
|
|
|
|
"display_name": "Daniel Harold Funk",
|
|
|
|
"sponsor_type": "Contractor",
|
|
|
|
"telephone_number": "0000000000",
|
|
|
|
"department": "",
|
|
|
|
"email_address": "dhf8r@virginia.edu",
|
|
|
|
"given_name": "Daniel",
|
|
|
|
"uid": "dhf8r",
|
|
|
|
"affiliation": "",
|
|
|
|
"date_cached": "2020-08-04T19:32:08.006128+00:00"
|
|
|
|
}
|
|
|
|
},
|
2020-07-06 16:09:21 +00:00
|
|
|
"roles":
|
|
|
|
{
|
|
|
|
"INVESTIGATORTYPE": "PI",
|
2020-08-04 20:42:35 +00:00
|
|
|
"INVESTIGATORTYPEFULL": ProtocolBuilderInvestigatorType.PI.value,
|
2020-07-06 16:09:21 +00:00
|
|
|
"NETBADGEID": "dhf8r"
|
|
|
|
},
|
2020-04-06 20:56:00 +00:00
|
|
|
"details":
|
2020-05-11 21:04:05 +00:00
|
|
|
{
|
2020-08-12 21:04:59 +00:00
|
|
|
"DSMB": None,
|
|
|
|
"DSMB_FREQUENCY": None,
|
|
|
|
"GCRC_NUMBER": None,
|
|
|
|
"IBC_NUMBER": None,
|
|
|
|
"IDE": None,
|
|
|
|
"IND_1": 1234,
|
|
|
|
"IND_2": None,
|
|
|
|
"IND_3": None,
|
|
|
|
"IRBREVIEWERADMIN": None,
|
|
|
|
"IS_ADULT_PARTICIPANT": None,
|
|
|
|
"IS_APPROVED_DEVICE": None,
|
|
|
|
"IS_AUX": None,
|
|
|
|
"IS_BIOMEDICAL": None,
|
|
|
|
"IS_CANCER_PATIENT": None,
|
|
|
|
"IS_CENTRAL_REG_DB": None,
|
|
|
|
"IS_CHART_REVIEW": None,
|
|
|
|
"IS_COMMITTEE_CONFLICT": None,
|
|
|
|
"IS_CONSENT_WAIVER": None,
|
|
|
|
"IS_DB": None,
|
|
|
|
"IS_ELDERLY_POP": None,
|
|
|
|
"IS_ENGAGED_RESEARCH": None,
|
|
|
|
"IS_FETUS_POP": None,
|
|
|
|
"IS_FINANCIAL_CONFLICT": None,
|
|
|
|
"IS_FOR_CANCER_CENTER": None,
|
|
|
|
"IS_FUNDING_SOURCE": None,
|
|
|
|
"IS_GCRC": None,
|
|
|
|
"IS_GENE_TRANSFER": None,
|
|
|
|
"IS_GRANT": None,
|
|
|
|
"IS_HGT": None,
|
|
|
|
"IS_IBC": None,
|
|
|
|
"IS_IDE": None,
|
|
|
|
"IS_IND": None,
|
|
|
|
"IS_MENTAL_IMPAIRMENT_POP": None,
|
|
|
|
"IS_MINOR": None,
|
|
|
|
"IS_MINOR_PARTICIPANT": None,
|
|
|
|
"IS_MULTI_SITE": None,
|
|
|
|
"IS_NOT_CONSENT_WAIVER": None,
|
|
|
|
"IS_NOT_PRC_WAIVER": None,
|
|
|
|
"IS_OTHER_VULNERABLE_POP": None,
|
|
|
|
"IS_OUTSIDE_CONTRACT": None,
|
|
|
|
"IS_PI_INITIATED": None,
|
|
|
|
"IS_PI_SCHOOL": None,
|
|
|
|
"IS_PRC": None,
|
|
|
|
"IS_PRC_DSMP": None,
|
|
|
|
"IS_PREGNANT_POP": None,
|
|
|
|
"IS_PRISONERS_POP": None,
|
|
|
|
"IS_QUALITATIVE": None,
|
|
|
|
"IS_RADIATION": None,
|
|
|
|
"IS_REVIEW_BY_CENTRAL_IRB": None,
|
|
|
|
"IS_SPONSOR": None,
|
|
|
|
"IS_SPONSOR_MONITORING": None,
|
|
|
|
"IS_SURROGATE_CONSENT": None,
|
|
|
|
"IS_TISSUE_BANKING": None,
|
|
|
|
"IS_UVA_DB": None,
|
|
|
|
"IS_UVA_IDE": None,
|
|
|
|
"IS_UVA_IND": None,
|
|
|
|
"IS_UVA_LOCATION": None,
|
|
|
|
"IS_UVA_PI_MULTI": None,
|
|
|
|
"MULTI_SITE_LOCATIONS": None,
|
|
|
|
"NON_UVA_LOCATION": None,
|
|
|
|
"OTHER_VULNERABLE_DESC": None,
|
|
|
|
"PRC_NUMBER": None,
|
|
|
|
"SPONSORS_PROTOCOL_REVISION_DATE": None,
|
|
|
|
"UPLOAD_COMPLETE": None
|
2020-05-11 21:04:05 +00:00
|
|
|
},
|
2020-04-23 23:25:01 +00:00
|
|
|
"approvals": {
|
2020-04-24 03:32:20 +00:00
|
|
|
"study_id": 12,
|
|
|
|
"workflow_id": 321,
|
2020-04-23 23:25:01 +00:00
|
|
|
"display_name": "IRB API Details",
|
|
|
|
"name": "irb_api_details",
|
|
|
|
"status": WorkflowStatus.not_started.value,
|
|
|
|
"workflow_spec_id": "irb_api_details",
|
|
|
|
},
|
2020-04-29 14:21:24 +00:00
|
|
|
'protocol': {
|
2020-07-16 17:28:00 +00:00
|
|
|
'id': 0,
|
2020-04-29 14:21:24 +00:00
|
|
|
}
|
2020-04-06 20:56:00 +00:00
|
|
|
}
|
2020-07-28 15:02:49 +00:00
|
|
|
})
|
|
|
|
if args[0]=='documents':
|
|
|
|
return StudyService().get_documents_status(study_id)
|
|
|
|
return data['study'][args[0]]
|
2020-07-27 16:18:28 +00:00
|
|
|
#self.add_data_to_task(task=task, data=data["study"])
|
|
|
|
#self.add_data_to_task(task, {"documents": StudyService().get_documents_status(study_id)})
|
2020-03-27 12:29:31 +00:00
|
|
|
|
2020-07-24 18:33:24 +00:00
|
|
|
def do_task(self, task, study_id, workflow_id, *args, **kwargs):
|
2020-07-24 16:08:46 +00:00
|
|
|
self.check_args(args,2)
|
|
|
|
prefix = None
|
|
|
|
if len(args) > 1:
|
|
|
|
prefix = args[1]
|
|
|
|
cmd = args[0]
|
2020-07-28 15:02:49 +00:00
|
|
|
# study_info = {}
|
|
|
|
# if self.__class__.__name__ in task.data:
|
|
|
|
# study_info = task.data[self.__class__.__name__]
|
2020-07-24 16:08:46 +00:00
|
|
|
retval = None
|
|
|
|
if cmd == 'info':
|
|
|
|
study = session.query(StudyModel).filter_by(id=study_id).first()
|
|
|
|
schema = StudySchema()
|
|
|
|
retval = schema.dump(study)
|
|
|
|
if cmd == 'investigators':
|
|
|
|
retval = StudyService().get_investigators(study_id)
|
|
|
|
if cmd == 'roles':
|
|
|
|
retval = StudyService().get_investigators(study_id, all=True)
|
|
|
|
if cmd == 'details':
|
|
|
|
retval = self.pb.get_study_details(study_id)
|
2020-11-04 19:34:10 +00:00
|
|
|
if cmd == 'sponsors':
|
|
|
|
retval = self.pb.get_sponsors(study_id)
|
2020-07-24 16:08:46 +00:00
|
|
|
if cmd == 'approvals':
|
|
|
|
retval = StudyService().get_approvals(study_id)
|
|
|
|
if cmd == 'documents':
|
|
|
|
retval = StudyService().get_documents_status(study_id)
|
|
|
|
if cmd == 'protocol':
|
|
|
|
retval = StudyService().get_protocol(study_id)
|
2020-12-30 19:51:51 +00:00
|
|
|
if isinstance(retval, list):
|
|
|
|
retval = [Box(item) for item in retval]
|
2020-07-24 16:08:46 +00:00
|
|
|
if isinstance(retval,dict) and prefix is not None:
|
|
|
|
return Box({x:retval[x] for x in retval.keys() if x[:len(prefix)] == prefix})
|
2020-12-30 19:51:51 +00:00
|
|
|
elif isinstance(retval,dict) :
|
2020-07-24 16:08:46 +00:00
|
|
|
return Box(retval)
|
|
|
|
else:
|
|
|
|
return retval
|
|
|
|
|
2020-04-23 23:25:01 +00:00
|
|
|
|
2020-03-27 12:29:31 +00:00
|
|
|
|
2020-07-24 16:08:46 +00:00
|
|
|
def check_args(self, args, maxlen=1):
|
|
|
|
if len(args) < 1 or len(args) > maxlen or (args[0] not in StudyInfo.type_options):
|
2020-03-27 12:29:31 +00:00
|
|
|
raise ApiError(code="missing_argument",
|
|
|
|
message="The StudyInfo script requires a single argument which must be "
|
|
|
|
"one of %s" % ",".join(StudyInfo.type_options))
|
2020-04-13 20:23:31 +00:00
|
|
|
|
|
|
|
|