Skip to content

Commit

Permalink
look for withdrawn status in /patients list, now that timelines exten…
Browse files Browse the repository at this point in the history
…d beyond point of withdrawal.
  • Loading branch information
pbugni committed Mar 21, 2024
1 parent 07f1f11 commit de2bdf4
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 de2bdf4

Please sign in to comment.