Module: email-generator

The functions exported from this module generate different types of emails depending on their purpose. They all need information contained in the "email_info" JSON objects.
Version:
  • 0.0.2
Author:
  • Danilo Del Busso, Luka Kralj

Example

The email_info JSON needs to reflect this format in order to be properly parsed:

{
  "patient": {
    "patient_no": "P799886",
    "patient_name": "Bruce",
    "patient_surname": "Wayne",
    "patient_email": "imnotbatman@gotham.com",
    "patient_phone": null,
    "hospital_id": 551,
    "carer_id": null,
    "additional_info": null
  },
  "test": {
    "test_id": 1,
    "patient_no": "P799886",
    "due_date": date_obj,  //a date object
    "frequency": "4-W",
    "occurrences": 9,
    "completed_status": "yes",
    "completed_date": date_obj, //a date object
    "notes": null
  },
  "hospital": {
    "hospital_id": 551,
    "hospital_name": "Gotham City Hospital",
    "hospital_email": "hospital@gotham.com",
    "hospital_phone": null
  }
  "user":{
    "username": "admin"
    "new_password": "newpassword123"
    "recovery_email": "admin@admin.com"
  }
}

Methods


<inner> beautifyDate(date)

Beautify a date object as a readable string of "1st October 2020" format
Parameters:
Name Type Description
date date the date object to be beautified
Returns:
the beautified date
Type
string

<async, inner> generateRecoveryEmailBody(contentConfiguration)

Generates the body of the email according to the content configuration.
Parameters:
Name Type Description
contentConfiguration JSON format: { "subject": "", "mainBody": "", },

<async, inner> generateReminderBody(contentConfiguration)

Generates the body of the email according to the content configuration.
Parameters:
Name Type Description
contentConfiguration JSON format: { "subject": { "title": "", "appendDate": true|false }, "mainBody": "", "details": { "includePatientNo": true|false, "includePatientName": true|false, "includePatientContact": true|false, "includeDueDate": true|false } },

<inner> getFooter()

Get mjml code describing common footer of emails
Returns:
mjml code describing common footer of emails
Type
string

<inner> getHead(the)

Get mjml code describing common head of emails
Parameters:
Name Type Description
the title title of the html document
Returns:
mjml code describing common head of emails
Type
string

Get mjml code for image at the top of emails
Returns:
mjml code for image at the top of emails
Type
string

<async, inner> overdueTestReminderForCarer(email_info)

Return html for an email containing info about a test which is overdue for a patient.
Parameters:
Name Type Description
email_info JSON the json containing info needed to generate the email. For format info look at the module's documentation.
Returns:
html for an email containing info about a test which is due for a patient
Type
string

<async, inner> overdueTestReminderForHospital(email_info)

Return html for an email containing info about a test which is overdue for a patient.
Parameters:
Name Type Description
email_info JSON the json containing info needed to generate the email. For format info look at the module's documentation.
Returns:
html for an email containing info about a test which is due for a patient
Type
string

<async, inner> overdueTestReminderForPatient(email_info)

Return html for an email containing info about a test which is overdue for a patient.
Parameters:
Name Type Description
email_info JSON the json containing info needed to generate the email. For format info look at the module's documentation.
Returns:
html for an email containing info about a test which is due for a patient
Type
string

<async, inner> passwordRecoveryEmail(email_info)

Return html for an email containing info about a new password which is generated for a User.
Parameters:
Name Type Description
email_info JSON the json containing info needed to generate the email. For format info look at the module's documentation.
Returns:
html for an email containing info about a test which is due for a patient
Type
string

<async, inner> testReminderForCarer(email_info)

Generate an email aimed at carers which reminds of a blood test due for a patient
Parameters:
Name Type Description
email_info JSON the json containing info needed to generate the email. For format info look at the module's documentation.

<async, inner> testReminderForHospital(email_info)

Generate an email aimed at hospitals which reminds of a blood test due for a patient of theirs
Parameters:
Name Type Description
email_info JSON the json containing info needed to generate the email. For format info look at the module's documentation.

<async, inner> testReminderForPatient(email_info)

Return html for an email containing info about a test which is due for a patient.
Parameters:
Name Type Description
email_info JSON the json containing info needed to generate the email. For format info look at the module's documentation.
Returns:
html for an email containing info about a test which is due for a patient
Type
string