Skip to content

Commit

Permalink
Revert "TN-2417 provide ugly workaround to failed query until we can …
Browse files Browse the repository at this point in the history
…figure out the source of the problem. (#3579)"

This reverts commit 08a7642.
  • Loading branch information
ivan-c committed Dec 11, 2019
1 parent 4d33091 commit 6aa380e
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions portal/models/questionnaire_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,41 +340,15 @@ def qnrs(self):
).filter(
QuestionnaireResponse.qb_iteration == self.qb_iteration)
self._qnrs = []
requery = False
for qnr in query:
if qnr.instrument_id is None:
current_app.logger.warning(
"QNR {} query returned no instrument".format(qnr.id))
instrument = None
requery = True
else:
instrument = qnr.instrument_id.split('/')[-1]
self._qnrs.append(QNR(
qnr_id=qnr.id,
qb_id=qnr.questionnaire_bank_id,
iteration=qnr.qb_iteration,
status=qnr.status,
instrument=instrument,
instrument=qnr.instrument_id.split('/')[-1],
authored=qnr.authored,
encounter_id=qnr.encounter_id))

if requery:
# Ugly workaround till we figure out why this is happening
# see TN-2417
for i, qnr in enumerate(self._qnrs):
if qnr.instrument is None:
doc = QuestionnaireResponse.query.filter(
QuestionnaireResponse.id == qnr.qnr_id).with_entities(
QuestionnaireResponse.document).first()
if doc is None:
current_app.logger.warning(
"doc still None on second try for "
"qnr {}".format(qnr.qnr_id))
else:
self._qnrs[i] = qnr._replace(
instrument=
doc[0]['questionnaire']['reference'].split(
'/')[-1])
return self._qnrs

def assign_qb_relationships(self, qb_generator):
Expand Down

0 comments on commit 6aa380e

Please sign in to comment.