mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-20 11:48:16 +00:00
Collecting user generated study changes
This commit is contained in:
parent
79381c4099
commit
bf3dae1885
@ -28,6 +28,11 @@ class IrbStatus(enum.Enum):
|
||||
hsr_assigned = 'hsr number assigned'
|
||||
|
||||
|
||||
class StudyEventType(enum.Enum):
|
||||
user = 'user'
|
||||
automatic = 'automatic'
|
||||
|
||||
|
||||
class StudyModel(db.Model):
|
||||
__tablename__ = 'study'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
@ -60,6 +65,17 @@ class StudyModel(db.Model):
|
||||
self.status = StudyStatus.hold
|
||||
|
||||
|
||||
class StudyEvent(db.Model):
|
||||
__tablename__ = 'study_event'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
study_id = db.Column(db.Integer, db.ForeignKey(StudyModel.id), nullable=False)
|
||||
study = db.relationship(StudyModel)
|
||||
create_date = db.Column(db.DateTime(timezone=True), default=func.now())
|
||||
status = db.Column(db.Enum(StudyStatus))
|
||||
comment = db.Column(db.String, default='')
|
||||
event_type = db.Column(db.Enum(StudyEventType))
|
||||
|
||||
|
||||
class WorkflowMetadata(object):
|
||||
def __init__(self, id, name = None, display_name = None, description = None, spec_version = None,
|
||||
category_id = None, category_display_name = None, state: WorkflowState = None,
|
||||
@ -128,7 +144,7 @@ class CategorySchema(ma.Schema):
|
||||
class Study(object):
|
||||
|
||||
def __init__(self, title, last_updated, primary_investigator_id, user_uid,
|
||||
id=None, status=None, irb_status=None,
|
||||
id=None, status=None, irb_status=None, comment="",
|
||||
sponsor="", hsr_number="", ind_number="", categories=[],
|
||||
files=[], approvals=[], enrollment_date=None, **argsv):
|
||||
self.id = id
|
||||
@ -137,6 +153,7 @@ class Study(object):
|
||||
self.last_updated = last_updated
|
||||
self.status = status
|
||||
self.irb_status = irb_status
|
||||
self.comment = comment
|
||||
self.primary_investigator_id = primary_investigator_id
|
||||
self.sponsor = sponsor
|
||||
self.hsr_number = hsr_number
|
||||
@ -165,18 +182,14 @@ class Study(object):
|
||||
if status == StudyStatus.open_for_enrollment:
|
||||
study_model.enrollment_date = self.enrollment_date
|
||||
|
||||
# change = {
|
||||
# 'status': ProtocolBuilderStatus(self.protocol_builder_status).value,
|
||||
# 'comment': '' if not hasattr(self, 'comment') else self.comment,
|
||||
# 'date': str(datetime.datetime.now())
|
||||
# }
|
||||
|
||||
# if study_model.changes_history:
|
||||
# changes_history = json.loads(study_model.changes_history)
|
||||
# changes_history.append(change)
|
||||
# else:
|
||||
# changes_history = [change]
|
||||
# study_model.changes_history = json.dumps(changes_history)
|
||||
study_event = StudyEvent(
|
||||
study=study_model,
|
||||
status=status,
|
||||
comment='' if not hasattr(self, 'comment') else self.comment,
|
||||
event_type=StudyEventType.user
|
||||
)
|
||||
db.session.add(study_event)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def model_args(self):
|
||||
|
37
migrations/versions/59a71fb532cb_.py
Normal file
37
migrations/versions/59a71fb532cb_.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 59a71fb532cb
|
||||
Revises: 1c3f88dbccc3
|
||||
Create Date: 2020-08-05 19:45:53.039959
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '59a71fb532cb'
|
||||
down_revision = '1c3f88dbccc3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('study_event',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('study_id', sa.Integer(), nullable=False),
|
||||
sa.Column('create_date', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('status', sa.Enum('in_progress', 'hold', 'open_for_enrollment', 'abandoned', name='studyeventstatus'), nullable=True),
|
||||
sa.Column('comment', sa.String(), nullable=True),
|
||||
sa.Column('event_type', sa.Enum('user', 'automatic', name='studyeventtype'), nullable=True),
|
||||
sa.ForeignKeyConstraint(['study_id'], ['study.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('study_event')
|
||||
# ### end Alembic commands ###
|
Loading…
x
Reference in New Issue
Block a user