Skip to content

Commit

Permalink
rdrf #2425 handle consent
Browse files Browse the repository at this point in the history
  • Loading branch information
id2359 committed Mar 22, 2023
1 parent 10b690f commit 5c9bcec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rdrf/rdrf/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,3 +1210,18 @@ def custom_text(registry_model, key, default):

def has_died(patient):
return patient.date_of_death


def has_consented_to_receive_proms_emails(patient):
from rdrf.models.definition.models import ConsentQuestion

registry_model = patient.rdrf_registry.all()[0]
consent_code = registry_model.metadata["proms_consent_code"]
consent_model = ConsentQuestion.objects.get(code=consent_code)

consent_answer = patient.get_consent(consent_model)

if consent_answer:
return True

return False
7 changes: 7 additions & 0 deletions rdrf/rdrf/services/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def check_proms(registry_code, pid):
from registry.patients.models import Patient
from rdrf.scheduling.scheduling import PromsDataAnalyser, PromsAction
from rdrf.helpers.utils import has_died
from rdrf.helpers.utils import has_consented_to_receive_proms_emails

registry = Registry.objects.get(code=registry_code)
patient = Patient.objects.get(id=pid)
Expand All @@ -217,6 +218,12 @@ def check_proms(registry_code, pid):
logger.debug("patient has died so won't be sent proms requests")
return

if not has_consented_to_receive_proms_emails(patient):
logger.debug(
"patient not consented to receive emails so won't be sent proms requests"
)
return

logger.debug(f"analysing proms for {pid}")
proms_data_analyser = PromsDataAnalyser(registry, patient)

Expand Down

0 comments on commit 5c9bcec

Please sign in to comment.