Skip to content

Commit

Permalink
correct withdrawn patient status in /patients (#4371)
Browse files Browse the repository at this point in the history
another bug introduced with extending timeline beyond the user's point
of withdrawal.

now looking specifically for withdrawn status in /patients list, as it
was still assuming the timeline terminated at the point of withdrawal as
it used to.
  • Loading branch information
pbugni authored Mar 21, 2024
1 parent 07f1f11 commit 08ad9ad
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions portal/models/qb_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit 08ad9ad

Please sign in to comment.