Setting up an e-mail feed parser to refill a prescription as well as remind the user about an upcoming doctor's appointment

In this task, we will discuss setting up an LED to alert a person about an incoming e-mail to refill a prescription or when there is an upcoming doctor's appointment.

Just in case you skipped through Project 6, Raspberry Pi as a Personal Assistant, the python-feedparser tool and the python-gdata tool have to be installed:

sudo apt-get install python-feedparser
sudo apt-get install python-gdata

Note

This task is similar to the e-mail notifier we set up in Project 5, Internet of Things Example – An E-mail Alert Water Fountain. We will just discuss a minor modification to blink an LED when there is an e-mail in the inbox to refill a prescription.

Engage thrusters

  1. We will get started by checking for any new incoming e-mails:
    email = feedparser.parse(proto+username+":"+password+"@"+server+path)
  2. Let's assume the prescription refill reminder e-mail subject is called Walgreens. We will iteratively check through each entry and trigger an LED alert:
    for mail in email.entries:  
      if mail.title == "Walgreens":
        async_task = AsyncTask()
        async_task.add_callback()
        thread = Thread(target=async_task.run, args=())
        thread.start()
    • An asynchronous task can be triggered to blink an LED until the alert is acknowledged by pressing a button. The circuitry is similar to the one discussed in the previous task.
  3. This enables a person to respond to an e-mail and refill his/her prescription when necessary. This prevents a refill reminder getting buried among e-mails and enables the person to keep a tab on prescription delays.

Setting up a reminder for doctor's appointments

This is also similar to the event notifier that we discussed in Project 6, Raspberry Pi as a Personal Assistant. Let's assume that all doctor's appointments are saved in the calendar as Doctor's appointment. It is possible to prominently display all upcoming doctor's appointments as follows:

for i, an_event in enumerate(feed.entry):
  if an_event.title.text == "Doctor's appointment":
    print '	%s. %s' % (i, an_event.title.text,)

In the preceding example, we are just printing it to a console. You can perhaps make use of a display, for example, an OLED display that is controlled via a serial port, and display it at a prominent location.

Objective complete – mini debriefing

In this task, we completed the setup of an e-mail notifier to refill prescriptions and a reminder for an upcoming doctor's appointment.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.188.241