Every good deed goes punished.

This commit is contained in:
Dan Funk 2020-03-27 15:48:21 -04:00
parent 6ebd4dce42
commit c9900d787e
2 changed files with 17 additions and 8 deletions

View File

@ -39,9 +39,9 @@ class StudyInfo(Script):
schema = StudyModelSchema()
study_info["info"] = schema.dump(study)
if cmd == 'investigators':
study_info["investigators"] = self.pb.get_investigators(study_id)
study_info["investigators"] = self.pb.get_investigators(study_id, as_json=True)
if cmd == 'details':
study_info["details"] = self.pb.get_study_details(study_id)
study_info["details"] = self.pb.get_study_details(study_id, as_json=True)
task.data["study"] = study_info

View File

@ -30,11 +30,14 @@ class ProtocolBuilderService(object):
(response.status_code, response.text))
@staticmethod
def get_investigators(study_id) -> Optional[List[ProtocolBuilderInvestigator]]:
def get_investigators(study_id, as_json=False) -> Optional[List[ProtocolBuilderInvestigator]]:
ProtocolBuilderService.check_args(study_id)
response = requests.get(ProtocolBuilderService.INVESTIGATOR_URL % study_id)
if response.ok and response.text:
pb_studies = ProtocolBuilderInvestigatorSchema(many=True).loads(response.text)
if as_json:
return ProtocolBuilderInvestigatorSchema(many=True).dump(pb_studies)
else:
return pb_studies
else:
raise ApiError("protocol_builder_error",
@ -42,11 +45,14 @@ class ProtocolBuilderService(object):
(response.status_code, response.text))
@staticmethod
def get_required_docs(study_id) -> Optional[List[ProtocolBuilderRequiredDocument]]:
def get_required_docs(study_id, as_json=False) -> Optional[List[ProtocolBuilderRequiredDocument]]:
ProtocolBuilderService.check_args(study_id)
response = requests.get(ProtocolBuilderService.REQUIRED_DOCS_URL % study_id)
if response.ok and response.text:
pb_studies = ProtocolBuilderRequiredDocumentSchema(many=True).loads(response.text)
if as_json:
return ProtocolBuilderRequiredDocumentSchema(many=True).dump(pb_studies)
else:
return pb_studies
else:
raise ApiError("protocol_builder_error",
@ -54,11 +60,14 @@ class ProtocolBuilderService(object):
(response.status_code, response.text))
@staticmethod
def get_study_details(study_id) -> Optional[ProtocolBuilderStudyDetails]:
def get_study_details(study_id, as_json=False) -> Optional[ProtocolBuilderStudyDetails]:
ProtocolBuilderService.check_args(study_id)
response = requests.get(ProtocolBuilderService.STUDY_DETAILS_URL % study_id)
if response.ok and response.text:
pb_study_details = ProtocolBuilderStudyDetailsSchema().loads(response.text)
if as_json:
return ProtocolBuilderStudyDetailsSchema().dump(pb_study_details)
else:
return pb_study_details
else:
raise ApiError("protocol_builder_error",