From 6d548c2a74bb09168d85fc3fcfae07a2aa1745d2 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 5 Nov 2021 09:59:14 -0400 Subject: [PATCH] *** WIP *** Committing to work on another ticket There are TODOs in study_service --- crc/models/protocol_builder.py | 3 ++- crc/services/protocol_builder.py | 2 -- crc/services/study_service.py | 11 ++++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crc/models/protocol_builder.py b/crc/models/protocol_builder.py index 067bab5b..a68c55c9 100644 --- a/crc/models/protocol_builder.py +++ b/crc/models/protocol_builder.py @@ -41,13 +41,14 @@ class ProtocolBuilderStatus(enum.Enum): class ProtocolBuilderStudy(object): def __init__( self, STUDYID: int, TITLE: str, NETBADGEID: str, - DATE_MODIFIED: str, Q_COMPLETE: str=None + DATE_MODIFIED: str, Q_COMPLETE: str, HSRNUMBER: str ): self.STUDYID = STUDYID self.TITLE = TITLE self.NETBADGEID = NETBADGEID self.DATE_MODIFIED = DATE_MODIFIED self.Q_COMPLETE = Q_COMPLETE + self.HSRNUMBER = HSRNUMBER class ProtocolBuilderStudySchema(ma.Schema): class Meta: diff --git a/crc/services/protocol_builder.py b/crc/services/protocol_builder.py index 88a05e59..1f854b5e 100644 --- a/crc/services/protocol_builder.py +++ b/crc/services/protocol_builder.py @@ -30,10 +30,8 @@ class ProtocolBuilderService(object): ProtocolBuilderService.__enabled_or_raise() if not isinstance(user_id, str): raise ApiError("protocol_builder_error", "This user id is invalid: " + str(user_id)) - user_id = 'cah3us' url = ProtocolBuilderService.STUDY_URL % user_id logging.info(f'get_studies: url: {url}') - logging.debug(f'get_studies: url: {url}') response = requests.get(url) if response.ok and response.text: logging.info(f'get_studies: response.text: {response.text}') diff --git a/crc/services/study_service.py b/crc/services/study_service.py index bdeb6fe0..53d34306 100755 --- a/crc/services/study_service.py +++ b/crc/services/study_service.py @@ -37,9 +37,13 @@ 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 'REVIEW_TYPE' in study_info.keys() and study_info['REVIEW_TYPE'] in [2, 3, 23, 24]: - return True + 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 return False def get_studies_for_user(self, user, include_invalid=False): @@ -271,7 +275,8 @@ class StudyService(object): for code, doc in doc_dictionary.items(): doc['required'] = False - if ProtocolBuilderService.is_enabled() and doc['id']: + # 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) if pb_data: doc['required'] = True