From 521aaf57a6c3e39318081ff3271b6c1132ce02b0 Mon Sep 17 00:00:00 2001 From: Paul Bugni Date: Fri, 9 Feb 2024 04:55:13 -0800 Subject: [PATCH] Raise reasonable error when EMPRO patient can't receive email message --- portal/trigger_states/empro_states.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/portal/trigger_states/empro_states.py b/portal/trigger_states/empro_states.py index 70e490711..a2c73e52f 100644 --- a/portal/trigger_states/empro_states.py +++ b/portal/trigger_states/empro_states.py @@ -292,9 +292,13 @@ def process_processed(ts): patient = User.query.get(ts.user_id) # Patient always gets mail - pending_emails.append(( - patient_email(patient, soft_triggers, hard_triggers), - "patient thank you")) + if patient.email_ready(): + pending_emails.append(( + patient_email(patient, soft_triggers, hard_triggers), + "patient thank you")) + else: + current_app.logger.error( + f"EMPRO Patient({patient.id}) w/o email! Can't send message") if hard_triggers: triggers['action_state'] = 'required'