From de2bdf43007c9e28b7f190a153e9e69dd4323f63 Mon Sep 17 00:00:00 2001 From: Paul Bugni Date: Thu, 21 Mar 2024 12:51:52 -0700 Subject: [PATCH] look for withdrawn status in /patients list, now that timelines extend beyond point of withdrawal. --- portal/models/qb_timeline.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/portal/models/qb_timeline.py b/portal/models/qb_timeline.py index aee9822af..e75954ec5 100644 --- a/portal/models/qb_timeline.py +++ b/portal/models/qb_timeline.py @@ -1348,6 +1348,15 @@ def qb_status_visit_name(user_id, research_study_id, as_of_date): QBT.at <= as_of_date).order_by( QBT.at.desc(), QBT.id.desc()).first() if qbt: + # now that timelines are built beyond withdrawal, check for a + # withdrawal row before the one found above + withdrawn_qbt = (QBT.query.filter(QBT.user_id == user_id).filter( + QBT.research_study_id == research_study_id).filter( + QBT.at <= qbt.at).filter( + QBT.status == OverallStatus.withdrawn)).first() + if withdrawn_qbt: + qbt = withdrawn_qbt + results['status'] = qbt.status results['visit_name'] = visit_name(qbt.qbd())