2019-12-31 21:32:47 +00:00
|
|
|
from marshmallow_enum import EnumField
|
2020-03-16 17:37:31 +00:00
|
|
|
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
|
|
|
|
from sqlalchemy import func
|
2019-12-31 21:32:47 +00:00
|
|
|
|
|
|
|
from crc import db
|
2020-02-27 16:17:58 +00:00
|
|
|
from crc.models.protocol_builder import ProtocolBuilderStatus
|
2019-12-31 21:32:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StudyModel(db.Model):
|
|
|
|
__tablename__ = 'study'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
title = db.Column(db.String)
|
|
|
|
last_updated = db.Column(db.DateTime(timezone=True), default=func.now())
|
|
|
|
protocol_builder_status = db.Column(db.Enum(ProtocolBuilderStatus))
|
2020-02-28 16:14:30 +00:00
|
|
|
primary_investigator_id = db.Column(db.String, nullable=True)
|
|
|
|
sponsor = db.Column(db.String, nullable=True)
|
|
|
|
hsr_number = db.Column(db.String, nullable=True)
|
|
|
|
ind_number = db.Column(db.String, nullable=True)
|
|
|
|
user_uid = db.Column(db.String, db.ForeignKey('user.uid'), nullable=False)
|
|
|
|
investigator_uids = db.Column(db.ARRAY(db.String), nullable=True)
|
2020-02-27 16:17:58 +00:00
|
|
|
inactive = db.Column(db.Boolean, default=False)
|
2020-02-28 16:14:30 +00:00
|
|
|
requirements = db.Column(db.ARRAY(db.Integer), nullable=True)
|
2020-03-15 19:52:59 +00:00
|
|
|
status_spec_id = db.Column(db.String, db.ForeignKey('workflow_spec.id'))
|
|
|
|
status_spec_version = db.Column(db.String)
|
2019-12-31 21:32:47 +00:00
|
|
|
|
|
|
|
|
2020-03-16 17:37:31 +00:00
|
|
|
class StudyModelSchema(SQLAlchemyAutoSchema):
|
2019-12-31 21:32:47 +00:00
|
|
|
class Meta:
|
|
|
|
model = StudyModel
|
2020-03-16 17:37:31 +00:00
|
|
|
load_instance = True
|
|
|
|
include_relationships = True
|
2020-02-26 23:06:51 +00:00
|
|
|
include_fk = True # Includes foreign keys
|
2019-12-31 21:32:47 +00:00
|
|
|
|
2020-01-03 16:44:24 +00:00
|
|
|
protocol_builder_status = EnumField(ProtocolBuilderStatus)
|