I wrote a combination of batch and matlab scripts to send out automatic reminder and confirmation emails and text messages. Everything is run via a master batch script, which can be set up to run automatically on a nightly basis with a scheduled task. You could also use a cron job if you want something like this to run in a server environment. This could be run from anywhere that has access to the batch script and an “Appointments” folder with the various other files and scripts required, and of course the computer needs an installation of matlab. This Appointments Folder contains scripts and files necessary for sending out automatic, nightly reminder emails, text reminders, and email confirmations for imaging and computer battery data. This documentation will explain the contents of the folder, as well as the workings of the various scripts. This solution was never implemented in my lab, and it is an imperfect solution in that someone will not receive a reminder email or text message if their email is missing from the google calendar, but it was a good solution given the limited access to the information needed. However, if I created another reminder system, I would likely not use matlab at all, and go with something run with databases and possibly php or python, or anything that works with sqlite3!
rem_email.bat This batch script is responsible for downloading necessary appointment data from a secure server, and running the matlab scripts to send out reminder and confirmation notifications. The script would have been run nightly at 4:00am to ensure that new files have been downloaded and we have the most up to date information. It basically maps a drive to download new data, runs the matlab scripts to send out reminders, deletes temporary files produced by the scripts, and then closes the mapped drive. The script is as follows:
rem Reminder Email and Text Message Script
rem Maps drive to server using login and password already setup on server
net use /user:usernamegoeshere L: servernamehere passhere
rem get updated appointment schedule and save to folder
CD /D L:/webspace/
COPY schedulename.csv Y:PathtoAppointmentsfolder
rem Run matlab send reminder email script for imaging 72 hours away, behavioral battery / imaging 24 hours away
CD /D Y:PathtoAppointmentsfolder
matlab -nosplash -nodesktop -r rem_email(1,'Computer','yes','yes','contactaddress')
matlab -nosplash -nodesktop -r rem_email(3,'Imaging','no','yes','contactaddress')
matlab -nosplash -nodesktop -r rem_email(1,'Imaging','yes','yes','contactaddress')
rem Run matlab confirmation email script for appointments made yesterday
matlab -nosplash -nodesktop -r confirmation_email('contactaddress')
rem delete imaging and computer text files, if they exist. The matlab script will delete the schedulename.csv
ECHO Y | DEL imaging.txt
ECHO Y | DEL computer.txt
ECHO Y | DEL schedulename.csv
rem Close mapping of drive
CD /D C:/
net use /delete L:
schedulename.csv: Is scheduling information for people that make clinic appointments. Since everyone who is signed up for a battery or imaging appointment has had a clinical appointment, this is a reliable source to extract participant info (Name, Email, Phone, permission to text, phone carrier) for the imaging and computer appointments. We download this from our appointment system with a Sikuli script, and it gets saved onto another server, which we map to to download an up to date copy before running the reminder scripts
somename.mat must be in the same folder these scripts run from, as it includes sending credentials that are loaded on spot as opposed to being hardcoded into the file.
rem_email.m Takes in the following arguments: rem_email(days,cal,sendtxt,sendemail,contactemail)
This script depends on the imaging and computer calendars to be formatted with the participant first and last name in the Title (Summary) field, and the appointment information copied from the clinical calendar into the description field the following format:
Name: Jane Doe
Phone: (999) 999-9999
E-mail: jane.doe@duke.edu
The script works as follows:
So the rem_email.bat file can send out different combinations of reminder emails and texts simply by running this script multiple times with various configuations, as is done if you look at the batch code above.
confirmation_email.m Takes in the following arguments: confirmation_email(contactemail)
This script works in the same basic manner as rem_email.m, except that it is hard coded to download the imaging and computer calendar, and then send out only reminder emails to subjects with appointments that were just created in the past 24 hours (new appointments that should be confirmed). It figures out this detail by reading in the CREATED field from the calendar text files, which contains the date and time of when the event was created on the calendar. Output goes to CONFIRMATION_LOG.txt, and in case of error, the contactemail is notified.
These are new scripts, of course, and should be checked regularly for successful runs, and in the case of error, troubleshooted! In the long run I am hoping these will provide an easy and reliable toolset for sending reminder emails and text messages to participants, and doing away with missed appointments!