mirror of
https://github.com/sartography/protocol-builder-mock.git
synced 2025-01-12 08:44:46 +00:00
58 lines
2.3 KiB
Python
58 lines
2.3 KiB
Python
from pb import session
|
|
from pb.models import Investigator, InvestigatorSchema, IRBInfo, IRBInfoSchema, IRBInfoErrorSchema,\
|
|
IRBStatus, IRBStatusSchema, RequiredDocument, RequiredDocumentSchema, \
|
|
Study, StudySchema, StudyDetails, StudyDetailsSchema, \
|
|
StudySponsor, StudySponsorSchema, CreatorStudySchema, \
|
|
PreReview, PreReviewSchema, PreReviewErrorSchema
|
|
|
|
|
|
def get_user_studies(uva_id):
|
|
studies = session.query(Study).filter(Study.NETBADGEID == uva_id).all()
|
|
return CreatorStudySchema(many=True).dump(studies)
|
|
|
|
|
|
def required_docs(studyid):
|
|
docs = session.query(RequiredDocument).filter(RequiredDocument.STUDYID == studyid).all()
|
|
docs_schema = RequiredDocumentSchema(many=True).dump(docs)
|
|
return {'AUXDOCS': docs_schema,
|
|
'TEMPLATEDOCS': [],
|
|
'OTHERDOCS': []}
|
|
|
|
|
|
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()
|
|
return [StudyDetailsSchema().dump(details)]
|
|
|
|
|
|
def check_study(studyid):
|
|
irb_status = session.query(IRBStatus).filter(IRBStatus.STUDYID == studyid).first()
|
|
return IRBStatusSchema().dump(irb_status)
|
|
|
|
|
|
def current_irb_info(studyid):
|
|
irb_info = session.query(IRBInfo).filter(IRBInfo.SS_STUDY_ID == studyid).first()
|
|
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])
|
|
|
|
|
|
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)
|