Difference between revisions of "Sms and Email Notification Howtos"

From OpenEMR Project Wiki
 
(47 intermediate revisions by 8 users not shown)
Line 1: Line 1:
The email/sms notification module is used to notify a patient about an upcoming event/appointment. The module consists of two parts, a front end setup and a back end engine. The front end is  used to set the message template, access for the Sms/email engines and specify if a certain patient should receive notifications. The back end is set to query the database every hour for upcoming events which are set to send notifications and send them.  
==Note==
:*<span style = "color:green;">TM4B and Clickatell services cannot be integrated without considerable modifications.</span>
:*<span style = "color:green;">Refer to</span> [[Short Message Service]] <span style = "color:green;">for a more complete configuration guide.</span>
:*<span style = "color:green;">SMS and email configurations have no bearing on each other. They are related only as far as two separate topics under one heading.</span>
:*<span style = "color:green;">See</span> [[Mercury Mail Configuration in Windows]] <span style = "color:green;">for more details.</span>


==Overview==
The email/SMS notification module is used to notify a patient about an upcoming event/appointment (a Notification). The module consists of two parts, a "front end" setup and a "back end" engine. The front end is  used to set the message template, access for the SMS/email engines and specify if a certain patient should receive notifications. The back end is set to query the database every hour for upcoming events which are set to send notifications and send them.
==Gateways Supported==
Gateways Supported as of 3.2 are:
Gateways Supported as of 3.2 are:
:* '''tm4b''' http://www.tm4b.com/sending-sms/ - Outside USA only
:* '''TM4B''' http://www.tm4b.com/sending-sms/ - Outside USA only
:* '''clickatell''' - http://www.clickatell.com/
:* '''Clickatell''' - http://www.clickatell.com/
 
==Setup (4.0.0)+==
'''Setup SMS/email notification module you need follow these steps for version 4.0.0 and higher:'''
 
'''1.''' Go to Administration => Globals => Notifications and adjust the configuration as appropriate for your setup:


'''Setup Sms/email notification module you need follow these steps for version 4.0:'''
===Email /SMS Settings===
Email Notification Hours - limits when messages should be sent


'''1.''' In Administration->Globals->Notifications and adjust the configuration as appropriate for your setup:
===SMS Settings===
Email Notification Hours - limits when messages should be sent
For SMS messages you need to give the correct info for:
SMS Notification Hours - limits when messages should be sent
SMS Notification Hours - limits when messages should be sent  
SMS Gateway Username - user name used for sms gateway access
SMS Gateway Username - user name used for SMS gateway access
SMS Gateway Password - access password
SMS Gateway Password - access password
SMS Gateway API Key - used to interface with clickatell
SMS Gateway API Key - used to interface with Clickatell
 
===Email Settings===
For Email Services the following info is needed:
 
* Notification Email Address - Where will the message come from
* Email Transport Method - Select: SMTP, SENDMAIL or built in PHPMAIL
* SMTP Server Hostname - email outgoing server host/ip
* SMTP Server Port Number
* SMTP User for Authentication - outgoing server user
* SMTP Password for Authentication - outgoing server password
* SMTP Security Protocol - Most newer servers use TLS, but some may use SSL.  Not recommended to use NONE except for testing or connecting inside a firewall to an intermediary MTA (Mail Transferring Agent).
 
====Email Services Supported & Configuration====
Note pretty much any SMTP service should feasibly work with OpenEMR's configuration, but the following list are services that have been verified by developers to work in OpenEMR.  This list is current as of May 2023.
 
===== Mailgun =====
* [https://www.mailgun.com/ Mailgun] (see [https://help.mailgun.com/hc/en-us/articles/203380100-Where-Can-I-Find-My-API-Key-and-SMTP-Credentials- Mailgun Find SMTP Credentials])
** Email Transport Method SMTP
** SMTP Server Hostname: smtp.mailgun.org
** SMTP Server Port Number: 587
** SMTP User for Authentication: login user created in Mailgun (see above linked article)
** SMTP Password for Authentication: password credentials created in Mailgun (see above linked article)
** SMTP Security Protocol: TLS
** Note even though Mailgun's document suggests you would use port 465 we had to use port 587 in the docker images to get mailgun to connect properly.


Notification Email Address - Where will the message come from
===== Google Workspace SMTP Relay =====
Email Transport Method - select SMTP, SENDMAIL or built in PHPMAIL
* [https://apps.google.com/supportwidget/articlehome?hl=en&article_url=https%3A%2F%2Fsupport.google.com%2Fa%2Fanswer%2F2956491%3Fhl%3Den&assistant_id=generic-unu&product_context=2956491&product_name=UnuFlow&trigger_context=a Google Workspace SMTP Relay]
SMTP Server Hostname - email outgoing server host/ip
** Email Transport Method SMTP
SMTP Server Port Number  
** SMTP Server Hostname: smtp-relay.gmail.com
SMTP User for Authentication - outgoing server user
** SMTP Server Port Number: 587
SMTP Password for Authentication - outgoing server password
** SMTP User for Authentication: user created for workspace domain
** SMTP Password for Authentication: create app password [https://support.google.com/mail/answer/185833?hl=en-GB Sign in using app passwords]
** SMTP Security Protocol: TLS


'''These globals from 3.2 seems to be missing in the admin tool''' --[[User:Tmccormi|Tony - www.mi-squared.com]] 21:01, 2 March 2011 (UTC)
===== Gmail personal accounts =====
:*$GLOBALS['smtp_use_ssl']
* [https://support.google.com/accounts/answer/185833?hl=en&visit_id=638218481360565045-1920440819&p=app_passwords_sa&rd=1 Gmail personal accounts]
:*$log_folder_path - this is the path where the back end process will save the logs. You must set this with write access for the user which will run the cron jobs.
** Email Transport Method SMTP
** SMTP Server Hostname: smtp.gmail.com
** SMTP Server Port Number: 587
** SMTP User for Authentication: gmail address like somebody@gmail.com
** SMTP Password for Authentication: create app password, click on above Gmail personal accounts link
** SMTP Security Protocol: TLS


:(Note: at the moment only to Sms engines are supported Tm4B - http://www.tm4b.com and Clickatell - http://www.clickatell.com)
=== Backend Notifications===
*$log_folder_path - this is the path where the back end process will save the logs. You must set this with write access for the user which will run the cron jobs.


'''2.''' Install backend notification processes you need to add
:(Note: at the moment only two SMS engines are supported TM4B - http://www.tm4b.com and Clickatell - http://www.clickatell.com)
 
'''2.''' In order to install back end notification processes you need to add
cron_email_notification.php and cron_sms_notification.php in system crontab to run
cron_email_notification.php and cron_sms_notification.php in system crontab to run
every hour. Do this in the command *LINUX* command line.  ''Note: Need windows instructions written''
every hour. Do this in the command *LINUX* command line.   
:''(REMARK: Windows instructions need to be written, Cronjobs could be accomplished with Windows Task Scheduler.)''
 
'''For Linux follow these instructions:
:bash$ crontab -e
:bash$ crontab -e
:then put in the following lines:
:then put in the following lines:
Line 36: Line 87:
::(note: make sure you adjust the path as per your configuration)
::(note: make sure you adjust the path as per your configuration)


'''BELOW (3) is missing for V4.0''' --[[User:Tmccormi|Tony - www.mi-squared.com]] 21:03, 2 March 2011 (UTC)


'''3.''' Login into openEMR and go in section Admin.Notification and there you will find three new sections:
'''3.''' Login into openEMR and go in section Administration => Globals => Nofications.  
:- Sms notification - set provider name and the body of the sms message
:There you will find three new sections:
:- Email notification - set subject, provider name and the body of the email message.
::- SMS notification - set provider name and the body of the sms message
::- e-Mail notification - set subject, provider name and the body of the email message.
::- Phone notification - set USER name, Passsword and URL
 
'''4.''' In openEMR front end, under Patient/Client => summary (-page)=> Edit Demographics => Choices
 
:In this section you will find two options: 1. Allow E-mail and 2. Allow SMS.  


'''4.''' In openEMR front end, under patient summary page, in Choices section you will find two options: Allow Email and Allow Sms. This is to be set as required if you want your patient to be notified about an upcoming appointment.
:This is to be set as required if you want your patient to be notified about an upcoming appointment.


'''5.''' Go to Administration->Other->Database, find the table automatic_notification, there edit the 2nd row in which email is the default value. only change the provider name, Message subject and message send from. Write the body as per your requirement in the "message" section.  --[[User:Arnab Naha|Dr.Arnab Naha]]
'''5.''' Go to Administration => Other => Database.
:Find the table automatic_notification:
:: Edit the 2nd row in which email is the default value. Only change "provider name", "message subject" and "message send from". Write the body as per your requirement in the "message" section.  --[[User:Arnab Naha|Dr.Arnab Naha]]


'''6.''' Some useful Annonations:  
'''6.''' Some useful Annonations:  
Line 55: Line 113:
'''7.''' You need to configure mercury mail in your xampp or separately to be able to send mails. Mercury Mail acts as a secure mail server on your local machine. [[User:Arnab Naha|Dr. Arnab Naha]]
'''7.''' You need to configure mercury mail in your xampp or separately to be able to send mails. Mercury Mail acts as a secure mail server on your local machine. [[User:Arnab Naha|Dr. Arnab Naha]]


'''Patient Appointment Reminders via automated dialing system''' -- [[User:Sherwin Gaddis|Sherwin - ww2.openmedpractice.com]] 6 Aug 2013
=='''Emails for Appointment Reminders, Recalls and General Announcements'''==
 
If the operating system is Linux, the above <span style = "color:red;">'''will not work'''</span>. An alternative is to use an email client, such as [https://www.mozilla.org/en-US/thunderbird/ Thunderbird] and the add-on, [https://addons.mozilla.org/en-US/thunderbird/addon/mail-merge/?src=hp-dl-featured Mail Merge], as explained in this [http://www.hongkiat.com/blog/mass-mail-thunderbird/ tutorial]. Another alternative, available on all platforms using openEMR version >= 5.0.1, is [[MedEx]], a commercial module.
Open Med Practice as of July 18th 2013 began building a automated patient appointment reminder.
As of Aug 6th 2013, the preliminary system is in place and we have begun beta testing of the  
software and tweaking the foundation of the program.
 
The call reminders will require only the click of a button to start the calls going out. The system
will be able to make up to 100 simultaneous call. So if your office has 30 appointments on the schedule.
All 30 patients will be called at once. The patient will be asked to select 1 to confirm appointment and
that selection will be recorded. The second selection will be recorded which is to cancel appointment.
This information will be gathered within one hour and posted back to the EMR for viewing.
 
Please contact us via our website ww2.openmedpractice.com to signup to be a beta tester.
We will have the patch ready shortly after the release of version 4.1.2.
 


'''UPDATE 8/12/2013'''
OpenOffice or LibreOffice usually comes pre-loaded with the operating system to create the spreadsheet for the .csv file.


Here is a screenshot of the returned report  after the calls have been made. We still have some work to do on creating a better report. The report will generally show the current days call report and the day before. We are planning to build a call history report.  
A stock email for an upcoming appointment day would be paired with variables such the patients' first and last names plus the patients' email addresses. The time of the appointment can be another variable. The user is free to incorporate more variables with additional columns in the spreadsheet.


We are going to leave the system in a semi-automatic state with maybe an option to be completely automated. It does require some human intervention because we as humans don't always put phone numbers in the system for the patient. And there is an alert to show which patient does not have a phone number. That is the semi automatic part. Once past the phone number check the rest is automatic.
This process can be used to recall patients for their annual exam or to make a general announcement, e.g., the office will be closing because the physician plans to retire.


'''UPDATE 8/26/2013'''
Old emails can be quickly deleted with ctrl and shift by holding the Control key while clicking the first email to be deleted, then holding the Shift key and clicking the last email to be deleted; thus minimizing clutter in Thunderbird.


We have made a lot of changes to the system trying to get it production ready by the Sept deadline. There is a lot of promise in the code at this point. We just want to focus on doing one thing right now and doing that one thing well. So, right now the code is really purpose driven but has the ability to be developed into multiple functions in the future.  
Both Thunderbird and Mail Merge are open source.


We are still looking for another practice to use the code so we can look for weakness that we can't see being so close to the project.  
This method does not integrate emails with OpenEMR, but security is enhanced.
[[Category:Configuration Guide]]

Latest revision as of 21:11, 17 June 2024

Note

  • TM4B and Clickatell services cannot be integrated without considerable modifications.
  • Refer to Short Message Service for a more complete configuration guide.
  • SMS and email configurations have no bearing on each other. They are related only as far as two separate topics under one heading.
  • See Mercury Mail Configuration in Windows for more details.

Overview

The email/SMS notification module is used to notify a patient about an upcoming event/appointment (a Notification). The module consists of two parts, a "front end" setup and a "back end" engine. The front end is used to set the message template, access for the SMS/email engines and specify if a certain patient should receive notifications. The back end is set to query the database every hour for upcoming events which are set to send notifications and send them.

Gateways Supported

Gateways Supported as of 3.2 are:

Setup (4.0.0)+

Setup SMS/email notification module you need follow these steps for version 4.0.0 and higher:

1. Go to Administration => Globals => Notifications and adjust the configuration as appropriate for your setup:

Email /SMS Settings

Email Notification Hours - limits when messages should be sent

SMS Settings

For SMS messages you need to give the correct info for: SMS Notification Hours - limits when messages should be sent SMS Gateway Username - user name used for SMS gateway access SMS Gateway Password - access password SMS Gateway API Key - used to interface with Clickatell

Email Settings

For Email Services the following info is needed:

  • Notification Email Address - Where will the message come from
  • Email Transport Method - Select: SMTP, SENDMAIL or built in PHPMAIL
  • SMTP Server Hostname - email outgoing server host/ip
  • SMTP Server Port Number
  • SMTP User for Authentication - outgoing server user
  • SMTP Password for Authentication - outgoing server password
  • SMTP Security Protocol - Most newer servers use TLS, but some may use SSL. Not recommended to use NONE except for testing or connecting inside a firewall to an intermediary MTA (Mail Transferring Agent).

Email Services Supported & Configuration

Note pretty much any SMTP service should feasibly work with OpenEMR's configuration, but the following list are services that have been verified by developers to work in OpenEMR. This list is current as of May 2023.

Mailgun
  • Mailgun (see Mailgun Find SMTP Credentials)
    • Email Transport Method SMTP
    • SMTP Server Hostname: smtp.mailgun.org
    • SMTP Server Port Number: 587
    • SMTP User for Authentication: login user created in Mailgun (see above linked article)
    • SMTP Password for Authentication: password credentials created in Mailgun (see above linked article)
    • SMTP Security Protocol: TLS
    • Note even though Mailgun's document suggests you would use port 465 we had to use port 587 in the docker images to get mailgun to connect properly.
Google Workspace SMTP Relay
  • Google Workspace SMTP Relay
    • Email Transport Method SMTP
    • SMTP Server Hostname: smtp-relay.gmail.com
    • SMTP Server Port Number: 587
    • SMTP User for Authentication: user created for workspace domain
    • SMTP Password for Authentication: create app password Sign in using app passwords
    • SMTP Security Protocol: TLS
Gmail personal accounts
  • Gmail personal accounts
    • Email Transport Method SMTP
    • SMTP Server Hostname: smtp.gmail.com
    • SMTP Server Port Number: 587
    • SMTP User for Authentication: gmail address like somebody@gmail.com
    • SMTP Password for Authentication: create app password, click on above Gmail personal accounts link
    • SMTP Security Protocol: TLS

Backend Notifications

  • $log_folder_path - this is the path where the back end process will save the logs. You must set this with write access for the user which will run the cron jobs.
(Note: at the moment only two SMS engines are supported TM4B - http://www.tm4b.com and Clickatell - http://www.clickatell.com)

2. In order to install back end notification processes you need to add cron_email_notification.php and cron_sms_notification.php in system crontab to run every hour. Do this in the command *LINUX* command line.

(REMARK: Windows instructions need to be written, Cronjobs could be accomplished with Windows Task Scheduler.)

For Linux follow these instructions:

bash$ crontab -e
then put in the following lines:
* */1 * * * /var/www/html/openemr/modules/sms_email_reminder/cron_sms_notification.php
* */1 * * * /var/www/html/openemr/modules/sms_email_reminder/cron_email_notification.php
(note: make sure you adjust the path as per your configuration)


3. Login into openEMR and go in section Administration => Globals => Nofications.

There you will find three new sections:
- SMS notification - set provider name and the body of the sms message
- e-Mail notification - set subject, provider name and the body of the email message.
- Phone notification - set USER name, Passsword and URL

4. In openEMR front end, under Patient/Client => summary (-page)=> Edit Demographics => Choices

In this section you will find two options: 1. Allow E-mail and 2. Allow SMS.
This is to be set as required if you want your patient to be notified about an upcoming appointment.

5. Go to Administration => Other => Database.

Find the table automatic_notification:
Edit the 2nd row in which email is the default value. Only change "provider name", "message subject" and "message send from". Write the body as per your requirement in the "message" section. --Dr.Arnab Naha

6. Some useful Annonations:

***NAME*** - for entering the name of the patient automatically
***DATE*** - for entering the date of the appointment automatically
***STARTTIME*** - For entering the start time of the appointment
***ENDTIME*** - for the end time of the appointment
***PROVIDER*** - to state the provider automatically with whom the appointment is fixed --Dr. Arnab Naha

7. You need to configure mercury mail in your xampp or separately to be able to send mails. Mercury Mail acts as a secure mail server on your local machine. Dr. Arnab Naha

Emails for Appointment Reminders, Recalls and General Announcements

If the operating system is Linux, the above will not work. An alternative is to use an email client, such as Thunderbird and the add-on, Mail Merge, as explained in this tutorial. Another alternative, available on all platforms using openEMR version >= 5.0.1, is MedEx, a commercial module.

OpenOffice or LibreOffice usually comes pre-loaded with the operating system to create the spreadsheet for the .csv file.

A stock email for an upcoming appointment day would be paired with variables such the patients' first and last names plus the patients' email addresses. The time of the appointment can be another variable. The user is free to incorporate more variables with additional columns in the spreadsheet.

This process can be used to recall patients for their annual exam or to make a general announcement, e.g., the office will be closing because the physician plans to retire.

Old emails can be quickly deleted with ctrl and shift by holding the Control key while clicking the first email to be deleted, then holding the Shift key and clicking the last email to be deleted; thus minimizing clutter in Thunderbird.

Both Thunderbird and Mail Merge are open source.

This method does not integrate emails with OpenEMR, but security is enhanced.