2021-04-09 10:00:24 -04:00
|
|
|
from pb import session
|
2022-04-07 17:29:23 -04:00
|
|
|
from pb.models import Investigator, InvestigatorSchema, IRBInfo, IRBInfoSchema, IRBInfoErrorSchema,\
|
2021-04-09 12:04:46 -04:00
|
|
|
IRBStatus, IRBStatusSchema, RequiredDocument, RequiredDocumentSchema, \
|
|
|
|
Study, StudySchema, StudyDetails, StudyDetailsSchema, \
|
2022-06-17 13:12:24 -04:00
|
|
|
StudySponsor, StudySponsorSchema, CreatorStudySchema, \
|
|
|
|
PreReview, PreReviewSchema, PreReviewErrorSchema
|
2021-04-09 10:00:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
def get_user_studies(uva_id):
|
|
|
|
studies = session.query(Study).filter(Study.NETBADGEID == uva_id).all()
|
2021-12-06 15:49:56 -05:00
|
|
|
return CreatorStudySchema(many=True).dump(studies)
|
2021-04-09 10:00:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
def required_docs(studyid):
|
|
|
|
docs = session.query(RequiredDocument).filter(RequiredDocument.STUDYID == studyid).all()
|
2021-11-11 15:32:02 -05:00
|
|
|
docs_schema = RequiredDocumentSchema(many=True).dump(docs)
|
|
|
|
return {'AUXDOCS': docs_schema,
|
|
|
|
'TEMPLATEDOCS': [],
|
|
|
|
'OTHERDOCS': []}
|
2021-04-09 10:00:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
def investigators(studyid):
|
|
|
|
inv = session.query(Investigator).filter(Investigator.STUDYID == studyid).all()
|
|
|
|
return InvestigatorSchema(many=True).dump(inv)
|
|
|
|
|
|
|
|
|
|
|
|
def sponsors(studyid):
|
|
|
|
sponsors = session.query(StudySponsor).filter(StudySponsor.SS_STUDY == studyid).all()
|
|
|
|
return StudySponsorSchema(many=True).dump(sponsors)
|
|
|
|
|
|
|
|
|
|
|
|
def get_study_details(studyid):
|
|
|
|
details = session.query(StudyDetails).filter(StudyDetails.STUDYID == studyid).first()
|
2021-11-09 09:31:53 -05:00
|
|
|
return [StudyDetailsSchema().dump(details)]
|
2021-04-09 10:00:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
def check_study(studyid):
|
|
|
|
irb_status = session.query(IRBStatus).filter(IRBStatus.STUDYID == studyid).first()
|
|
|
|
return IRBStatusSchema().dump(irb_status)
|
2021-04-09 12:04:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
def current_irb_info(studyid):
|
|
|
|
irb_info = session.query(IRBInfo).filter(IRBInfo.SS_STUDY_ID == studyid).first()
|
2022-04-07 17:29:23 -04:00
|
|
|
if irb_info and hasattr(irb_info, 'IRB_ONLINE_STATUS') and irb_info.IRB_ONLINE_STATUS == 'Error':
|
|
|
|
# IRB Online returns a dictionary in this case
|
|
|
|
return IRBInfoErrorSchema().dump(irb_info)
|
|
|
|
else:
|
|
|
|
# IRB Online returns a list with 1 dictionary in this case
|
|
|
|
return IRBInfoSchema(many=True).dump([irb_info])
|
2022-06-17 13:12:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
def returned_to_pi(study_id):
|
|
|
|
results = session.query(PreReview).filter(PreReview.SS_STUDY_ID == study_id).all()
|
|
|
|
if results:
|
|
|
|
return PreReviewSchema(many=True).dump(results)
|
|
|
|
pre_review = PreReview(STATUS='Error', DETAIL='No records found.')
|
|
|
|
return PreReviewErrorSchema().dump(pre_review)
|