*** WIP ***

Committing to work on another ticket
There are TODOs in study_service
This commit is contained in:
mike cullerton 2021-11-05 09:59:14 -04:00
parent b03e596dcf
commit 6d548c2a74
3 changed files with 10 additions and 6 deletions

View File

@ -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:

View File

@ -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}')

View File

@ -37,8 +37,12 @@ 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]:
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
@ -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