cr-connect-workflow/crc/models/protocol_builder.py

85 lines
2.5 KiB
Python

import enum
from marshmallow import INCLUDE, post_load
from crc import ma
class ProtocolBuilderInvestigatorType(enum.Enum):
PI = "Primary Investigator"
SI = "Sub Investigator"
DC = "Department Contact"
SC_I = "Study Coordinator 1"
SC_II = "Study Coordinator 2"
AS_C = "Additional Study Coordinators"
DEPT_CH = "Department Chair"
IRBC = "IRB Coordinator"
SCI = "Scientific Contact"
class ProtocolBuilderStatus(enum.Enum):
DRAFT = 'draft', # !Q_COMPLETE
IN_PROCESS = 'in_process', # Q_COMPLETE && !UPLOAD_COMPLETE && !HSRNUMBER
IN_REVIEW = 'in_review', # Q_COMPLETE && (!UPLOAD_COMPLETE || !HSRNUMBER)
REVIEW_COMPLETE = 'review_complete', # Q_COMPLETE && UPLOAD_COMPLETE && HSRNUMBER
INACTIVE = 'inactive', # Not found in PB
class ProtocolBuilderStudy(object):
def __init__(
self, STUDYID: int, HSRNUMBER: str, TITLE: str, NETBADGEID: str,
Q_COMPLETE: bool, DATE_MODIFIED: str
):
self.STUDYID = STUDYID
self.HSRNUMBER = HSRNUMBER
self.TITLE = TITLE
self.NETBADGEID = NETBADGEID
self.Q_COMPLETE = Q_COMPLETE
self.DATE_MODIFIED = DATE_MODIFIED
class ProtocolBuilderStudySchema(ma.Schema):
class Meta:
model = ProtocolBuilderStudy
unknown = INCLUDE
fields = ["STUDYID", "HSRNUMBER", "TITLE", "NETBADGEID",
"Q_COMPLETE", "DATE_MODIFIED"]
@post_load
def make_pbs(self, data, **kwargs):
return ProtocolBuilderStudy(**data)
class ProtocolBuilderInvestigator(object):
def __init__(self, NETBADGEID: str, INVESTIGATORTYPE: str, INVESTIGATORTYPEFULL: str):
self.NETBADGEID = NETBADGEID
self.INVESTIGATORTYPE = INVESTIGATORTYPE
self.INVESTIGATORTYPEFULL = INVESTIGATORTYPEFULL
class ProtocolBuilderInvestigatorSchema(ma.Schema):
class Meta:
model = ProtocolBuilderInvestigator
unknown = INCLUDE
fields = ["NETBADGEID", "INVESTIGATORTYPE", "INVESTIGATORTYPEFULL"]
@post_load
def make_inv(self, data, **kwargs):
return ProtocolBuilderInvestigator(**data)
class ProtocolBuilderRequiredDocument(object):
def __init__(self, AUXDOCID: str, AUXDOC: str):
self.AUXDOCID = AUXDOCID
self.AUXDOC = AUXDOC
class ProtocolBuilderRequiredDocumentSchema(ma.Schema):
class Meta:
fields = ["AUXDOCID","AUXDOC"]
unknown = INCLUDE
@post_load
def make_req(self, data, **kwargs):
return ProtocolBuilderRequiredDocument(**data)