From 6f09b0d7dd8ad6a60d486d90323d08418deb2097 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 5 Nov 2021 14:37:41 -0400 Subject: [PATCH] Added comment to _is_valid_study. Fixed get_required_docs. The data returned for get_required_dcs from UVA PB was *very* different than what we had. --- crc/services/study_service.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crc/services/study_service.py b/crc/services/study_service.py index 53d34306..ba1bbba5 100755 --- a/crc/services/study_service.py +++ b/crc/services/study_service.py @@ -37,13 +37,15 @@ class StudyService(object): @staticmethod def _is_valid_study(study_id): - # TODO: Determine if this is always a list now - # TODO: If so, just grab the first item, and get rid of this `if` statement - study_info = ProtocolBuilderService().get_study_details(study_id) - if isinstance(study_info, list) and len(study_info) > 0: - study_info = study_info[0] - if isinstance(study_info, dict) and 'REVIEW_TYPE' in study_info.keys() and study_info['REVIEW_TYPE'] in [2, 3, 23, 24]: - return True + study_details = ProtocolBuilderService().get_study_details(study_id) + if len(study_details) > 0: + study_info = study_details[0] + else: + study_info = None + # The review types 2, 3, 23, 24 correspond to review type names + # `Full Committee`, `Expedited`, `Non-UVA IRB Full Board`, and `Non-UVA IRB Expedited` + if isinstance(study_info, dict) and 'REVIEW_TYPE' in study_info.keys() and study_info['REVIEW_TYPE'] in [2, 3, 23, 24]: + return True return False def get_studies_for_user(self, user, include_invalid=False): @@ -275,9 +277,8 @@ class StudyService(object): for code, doc in doc_dictionary.items(): doc['required'] = False - # TODO: figure out the correct test here if ProtocolBuilderService.is_enabled() and doc['id'] != '': - pb_data = next((item for item in pb_docs if int(item['AUXDOCID']) == int(doc['id'])), None) + pb_data = next((item for item in pb_docs['AUXDOCS'] if int(item['SS_AUXILIARY_DOC_TYPE_ID']) == int(doc['id'])), None) if pb_data: doc['required'] = True