Ticket 275 - adding new API endpoint for IRB Study Info
models.py - Added new IRBInfo model - Added relationship to Study table forms.py - Added form to edit the data - Added column in Study table for link to edit new info __init__.py - Added route for new form page - Added method to update the db
This commit is contained in:
parent
2c780c9028
commit
40f45202df
|
@ -0,0 +1,37 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 277f05065db0
|
||||
Revises: 119c1269ee7c
|
||||
Create Date: 2021-04-07 16:14:01.470659
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '277f05065db0'
|
||||
down_revision = '119c1269ee7c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('irb_info',
|
||||
sa.Column('SS_STUDY_ID', sa.Integer(), nullable=False),
|
||||
sa.Column('UVA_STUDY_TRACKING', sa.String(), nullable=False, default=''),
|
||||
sa.Column('DATE_MODIFIED', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('IRB_ADMINISTRATIVE_REVIEWER', sa.String(), nullable=False, default=''),
|
||||
sa.Column('AGENDA_DATE', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('IRB_REVIEW_TYPE', sa.String(), nullable=False, default=''),
|
||||
sa.Column('IRBEVENT', sa.String(), nullable=False, default=''),
|
||||
sa.Column('IRB_STATUS', sa.String(), nullable=False, default=''),
|
||||
sa.Column('RB_OF_RECORD', sa.String(), nullable=False, default=''),
|
||||
sa.Column('UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES', sa.Integer(), nullable=True),
|
||||
sa.Column('STUDYIRBREVIEWERADMIN', sa.String(), nullable=False, default=''),
|
||||
sa.ForeignKeyConstraint(['SS_STUDY_ID'], ['study.STUDYID'],),
|
||||
sa.PrimaryKeyConstraint('SS_STUDY_ID'))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('irb_info')
|
|
@ -160,9 +160,11 @@ def site_map():
|
|||
# **************************
|
||||
# WEB FORMS
|
||||
# **************************
|
||||
from pb.forms import StudyForm, StudyTable, InvestigatorForm, StudyDetailsForm, ConfirmDeleteForm, StudySponsorForm
|
||||
from pb.forms import StudyForm, StudyTable, InvestigatorForm, StudyDetailsForm, ConfirmDeleteForm, StudySponsorForm, \
|
||||
IRBInfoForm
|
||||
from pb.models import Study, RequiredDocument, Investigator, StudySchema, RequiredDocumentSchema, InvestigatorSchema, \
|
||||
StudyDetails, StudyDetailsSchema, StudySponsor, Sponsor, SponsorSchema, StudySponsorSchema, IRBStatus, IRBStatusSchema
|
||||
StudyDetails, StudyDetailsSchema, StudySponsor, Sponsor, SponsorSchema, StudySponsorSchema, IRBStatus, \
|
||||
IRBStatusSchema, IRBInfo, IRBInfoSchema
|
||||
from pb.ldap.ldap_service import LdapService
|
||||
|
||||
|
||||
|
@ -245,6 +247,29 @@ def edit_study(study_id):
|
|||
)
|
||||
|
||||
|
||||
@app.route('/irb_info/<study_id>', methods=['GET', 'POST'])
|
||||
def edit_irb_info(study_id):
|
||||
irb_info = db.session.query(IRBInfo).filter(IRBInfo.SS_STUDY_ID == study_id).first()
|
||||
form = IRBInfoForm(request.form, obj=irb_info)
|
||||
action = BASE_HREF + "/irb_info/" + study_id
|
||||
title = "Edit IRB Info #" + study_id
|
||||
# if request.method == 'GET':
|
||||
# form.SS_STUDY_ID.data = study_id
|
||||
if request.method == 'POST':
|
||||
if form.validate():
|
||||
_update_irb_info(study_id, irb_info, form)
|
||||
flash('IRB Info updated successfully!', 'success')
|
||||
return redirect_home()
|
||||
return render_template(
|
||||
'form.html',
|
||||
form=form,
|
||||
action=action,
|
||||
title=title,
|
||||
description_map={},
|
||||
base_href=BASE_HREF
|
||||
)
|
||||
|
||||
|
||||
@app.route('/investigator/<study_id>', methods=['GET', 'POST'])
|
||||
def new_investigator(study_id):
|
||||
form = InvestigatorForm(request.form)
|
||||
|
@ -473,6 +498,26 @@ def _update_study(study, form):
|
|||
db.session.commit()
|
||||
|
||||
|
||||
def _update_irb_info(study_id, irb_info, form):
|
||||
if irb_info is None:
|
||||
irb_info = IRBInfo(SS_STUDY_ID=study_id)
|
||||
irb_info.UVA_STUDY_TRACKING = form.UVA_STUDY_TRACKING.data
|
||||
irb_info.DATE_MODIFIED = form.DATE_MODIFIED.data
|
||||
irb_info.IRB_ADMINISTRATIVE_REVIEWER = form.IRB_ADMINISTRATIVE_REVIEWER.data
|
||||
irb_info.AGENDA_DATE = form.AGENDA_DATE.data
|
||||
irb_info.IRB_REVIEW_TYPE = form.IRB_REVIEW_TYPE.data
|
||||
irb_info.IRBEVENT = form.IRBEVENT.data
|
||||
irb_info.IRB_STATUS = form.IRB_STATUS.data
|
||||
irb_info.RB_OF_RECORD = form.RB_OF_RECORD.data
|
||||
irb_info.UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES = form.UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES.data
|
||||
irb_info.STUDYIRBREVIEWERADMIN = form.STUDYIRBREVIEWERADMIN.data
|
||||
|
||||
db.session.add(irb_info)
|
||||
db.session.commit()
|
||||
|
||||
print('_update_irb_info')
|
||||
|
||||
|
||||
def _allowed_file(filename):
|
||||
allowed_extensions = ['csv', 'xls', 'xlsx']
|
||||
return '.' in filename and \
|
||||
|
|
15
pb/forms.py
15
pb/forms.py
|
@ -1,9 +1,9 @@
|
|||
from flask_table import Table, Col, LinkCol, BoolCol, DatetimeCol, NestedTableCol
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import SelectMultipleField, StringField, BooleanField, SelectField, validators, HiddenField
|
||||
from wtforms import SelectMultipleField, StringField, BooleanField, SelectField, validators, HiddenField, DateField, IntegerField
|
||||
from wtforms_alchemy import ModelForm
|
||||
|
||||
from pb.models import RequiredDocument, Investigator, StudyDetails, IRBStatus
|
||||
from pb.models import RequiredDocument, Investigator, StudyDetails, IRBStatus, IRBInfo
|
||||
|
||||
|
||||
class StudyForm(FlaskForm):
|
||||
|
@ -18,6 +18,12 @@ class StudyForm(FlaskForm):
|
|||
choices=[((q.STATUS, q.DETAIL), q.DETAIL) for q in IRBStatus.all()])
|
||||
|
||||
|
||||
class IRBInfoForm(ModelForm, FlaskForm):
|
||||
class Meta:
|
||||
model = IRBInfo
|
||||
hidden = 'SS_STUDY_ID'
|
||||
|
||||
|
||||
class InvestigatorForm(FlaskForm):
|
||||
NETBADGEID = StringField('UVA Id')
|
||||
INVESTIGATORTYPE = SelectField("InvestigatorType", choices=[(i.INVESTIGATORTYPE, i.INVESTIGATORTYPEFULL) for i in Investigator.all_types()])
|
||||
|
@ -115,6 +121,11 @@ class StudyTable(Table):
|
|||
anchor_attrs={'class': 'btn btn-icon btn-accent', 'title': 'Edit Sponsor(s)'},
|
||||
th_html_attrs={'class': 'mat-icon text-center', 'title': 'Edit Sponsor(s)'}
|
||||
)
|
||||
irb_info = LinkCol(
|
||||
'irb_info', 'edit_irb_info', url_kwargs=dict(study_id='STUDYID'),
|
||||
anchor_attrs={'class': 'btn btn-icon btn-accent', 'title': 'Edit Info'},
|
||||
th_html_attrs={'class': 'mat-icon text-center', 'title': 'Edit Info'}
|
||||
)
|
||||
STUDYID = Col('Study Id')
|
||||
TITLE = Col('Title')
|
||||
NETBADGEID = Col('User')
|
||||
|
|
22
pb/models.py
22
pb/models.py
|
@ -69,6 +69,7 @@ class Study(db.Model):
|
|||
NETBADGEID = db.Column(db.String(), nullable=False)
|
||||
DATE_MODIFIED = db.Column(db.DateTime(timezone=True), default=func.now())
|
||||
Q_COMPLETE = db.relationship("IRBStatus", backref="study", lazy='dynamic')
|
||||
irb_info = db.relationship("IRBInfo", backref="study", lazy='dynamic')
|
||||
requirements = db.relationship("RequiredDocument", backref="study", lazy='dynamic')
|
||||
investigators = db.relationship("Investigator", backref="study", lazy='dynamic')
|
||||
study_details = db.relationship("StudyDetails", uselist=False, backref="study")
|
||||
|
@ -82,6 +83,27 @@ class StudySchema(ma.Schema):
|
|||
"DATE_MODIFIED")
|
||||
|
||||
|
||||
class IRBInfo(db.Model):
|
||||
SS_STUDY_ID = db.Column(db.Integer, db.ForeignKey('study.STUDYID'), primary_key=True)
|
||||
UVA_STUDY_TRACKING = db.Column(db.String(), nullable=False, default='')
|
||||
DATE_MODIFIED = db.Column(db.Date, nullable=True)
|
||||
IRB_ADMINISTRATIVE_REVIEWER = db.Column(db.String(), nullable=False, default='')
|
||||
AGENDA_DATE = db.Column(db.Date, nullable=True)
|
||||
IRB_REVIEW_TYPE = db.Column(db.String(), nullable=False, default='')
|
||||
IRBEVENT = db.Column(db.String(), nullable=False, default='')
|
||||
IRB_STATUS = db.Column(db.String(), nullable=False, default='')
|
||||
RB_OF_RECORD = db.Column(db.String(), nullable=False, default='')
|
||||
UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES = db.Column(db.Integer(), nullable=True)
|
||||
STUDYIRBREVIEWERADMIN = db.Column(db.String(), nullable=False, default='')
|
||||
|
||||
|
||||
class IRBInfoSchema(ma.Schema):
|
||||
class Meta:
|
||||
# Fields to expose
|
||||
fields = ("UVA_STUDY_TRACKING", "DATE_MODIFIED", "IRB_ADMINISTRATIVE_REVIEWER",
|
||||
"AGENDA_DATE", "IRB_REVIEW_TYPE", "IRBEVENT", "IRB_STATUS", "RB_OF_RECORD",
|
||||
"UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES", "STUDYIRBREVIEWERADMIN")
|
||||
|
||||
class Investigator(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
STUDYID = db.Column(db.Integer, db.ForeignKey('study.STUDYID'))
|
||||
|
|
Loading…
Reference in New Issue