From 9247bec1d869f4ee6ab3d9faf06540ae0ecaf42c Mon Sep 17 00:00:00 2001 From: Paul Bugni Date: Tue, 3 Dec 2024 13:25:03 -0800 Subject: [PATCH] TN-2747 look for indefinite QNR in both v3 and v5 when looking up `in-progress` session id. --- portal/models/questionnaire_response.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/portal/models/questionnaire_response.py b/portal/models/questionnaire_response.py index 85bfe34fd..e24ad500d 100644 --- a/portal/models/questionnaire_response.py +++ b/portal/models/questionnaire_response.py @@ -910,11 +910,16 @@ def qnr_document_id( QuestionnaireResponse.subject_id == subject_id).filter( QuestionnaireResponse.document[ ('questionnaire', 'reference') - ].astext.endswith(questionnaire_name)).filter( - QuestionnaireResponse.questionnaire_bank_id == - questionnaire_bank_id).with_entities( + ].astext.endswith(questionnaire_name)).with_entities( QuestionnaireResponse.document[( 'identifier', 'value')]) + if questionnaire_name != 'irondemog_v3': + # Another special indefinite workaround. irondemog_v3 happens to live + # in multiple questionnaire banks, thus the lookup will fail when + # restricted by QB.id, should the org have transitioned since the user + # left work incomplete from the previous protocol (TN-2747) + qnr = qnr.filter(QuestionnaireResponse.questionnaire_bank_id == questionnaire_bank_id) + if iteration is not None: qnr = qnr.filter(QuestionnaireResponse.qb_iteration == iteration) else: