diff --git a/smash/web/models/mail_template.py b/smash/web/models/mail_template.py index e11033eccedff8782bce8d11544432a4a88cb2cb..3c3eea5c48bb50281784c07d1e464b0f652fcf61 100644 --- a/smash/web/models/mail_template.py +++ b/smash/web/models/mail_template.py @@ -111,6 +111,11 @@ class MailTemplate(models.Model): ("##S_VIRUS_4_IGG_STATUS##", "IgG Status in visit 4", ""), ("##S_VIRUS_5_IGG_STATUS##", "IgG Status in visit 5", ""), + ("##S_HEALTH_PARTNER_NAME##", "Name of the health partner", ""), + ("##S_HEALTH_PARTNER_ADDRESS##", "Address of the health partner", ""), + ("##S_HEALTH_PARTNER_ZIP_CODE##", "Zip code of the health partner", ""), + ("##S_HEALTH_PARTNER_CITY##", "City of the health partner", ""), + ] MAILS_TEMPLATE_VISIT_TAGS = [ @@ -321,6 +326,17 @@ class MailTemplate(models.Model): '##S_MAIL_LANGUAGE##': str(study_subject.subject.default_written_communication_language), '##S_KNOWN_LANGUAGES##': ", ".join([l.name for l in study_subject.subject.languages.all()]) } + if study_subject.health_partner is not None: + result["##S_HEALTH_PARTNER_NAME##"] = str(study_subject.health_partner.name) + result["##S_HEALTH_PARTNER_ADDRESS##"] = str(study_subject.health_partner.address) + result["##S_HEALTH_PARTNER_ZIP_CODE##"] = str(study_subject.health_partner.postal_code) + result["##S_HEALTH_PARTNER_CITY##"] = str(study_subject.health_partner.city) + else: + result["##S_HEALTH_PARTNER_NAME##"] = "" + result["##S_HEALTH_PARTNER_ADDRESS##"] = "" + result["##S_HEALTH_PARTNER_ZIP_CODE##"] = "" + result["##S_HEALTH_PARTNER_CITY##"] = "" + for i in range(1, 6): virus_test_field = "##S_VIRUS_{}_RESULT##".format(i) virus_test_value = virus_test_to_str(getattr(study_subject, "virus_test_{}".format(i)),