Skip to content

Commit

Permalink
TN-3331 prevent staff users from sending reminder emails when patient…
Browse files Browse the repository at this point in the history
… has no outstanding work
  • Loading branch information
pbugni committed Jan 30, 2025
1 parent 17217ad commit bdb08e0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions portal/views/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from flask_wtf import FlaskForm
from sqlalchemy import and_
from sqlalchemy.orm.exc import NoResultFound
from werkzeug.exceptions import BadRequest
from wtforms import (
BooleanField,
HiddenField,
Expand Down Expand Up @@ -70,6 +71,7 @@
OrgTree,
UserOrganization,
)
from ..models.overall_status import OverallStatus
from ..models.research_study import EMPRO_RS_ID, ResearchStudy
from ..models.role import ALL_BUT_WRITE_ONLY, ROLE
from ..models.table_preference import TablePreference
Expand Down Expand Up @@ -749,6 +751,7 @@ def patient_reminder_email(user_id):
Query string
:param research_study_id: set for targeted reminder emails, defaults to 0
:raises BadRequest: if the patient isn't currently eligible for reminder
"""
from ..models.qb_status import QB_Status
user = get_user(user_id, 'edit')
Expand All @@ -767,6 +770,10 @@ def patient_reminder_email(user_id):
user,
research_study_id=research_study_id,
as_of_date=datetime.utcnow())
if qstats.overall_status not in (
OverallStatus.due, OverallStatus.overdue, OverallStatus.in_progress):
raise BadRequest('No questionnaires available for patient to complete')

qbd = qstats.current_qbd()
if qbd:
qb_id, qb_iteration = qbd.qb_id, qbd.iteration
Expand Down

0 comments on commit bdb08e0

Please sign in to comment.