Managing your teletherapy appointments with Bloom Clinic

Anna Guerrero
7 min readAug 20, 2020

--

Bloom Clinic

It is no question that mental health is a vital part of our lives. Having a healthy mind impacts a lot of our thoughts, emotions, behaviors, actions and attitudes. When we prioritize our mental well-being, we become capable of realizing our full potential. We become free of thoughts that enslave and deprive us from growth and productivity.

Luckily, in order to make therapy more accessible and affordable, teletherapy has become an emerging and effective alternative to traditional face-to-face therapy. Teletherapy is increasingly being used by licensed therapists to hold live video call sessions with patients. The only difference it has from a regular therapy session is that it can be done remotely because all it requires is a computer and a good internet connection. In some ways, teletherapy allows first-time therapy seekers to try it out because of the relative anonymity it provides. It also may allow for lower costs as compared to an in-person session.

I decided to create a Sinatra app for a therapy clinic that would want to digitize their practice. This way, it would allow them to have a broader reach of patients, who could easily find them online and set up their appointments. I used my sister’s private practice as my inspiration. She is a licensed pyschologist and hopes to promote the need for mental health in her community. She also is working to fight against the stigmatization around getting help for mental disorders. Her practice is growing and because of the lockdowns caused by COVID-19, she had to find new ways to continue her business. Teletherapy was definitely the most lucrative option. She launched her private practice, Bloom Clinic, only a year ago and she has helped many clients discover their potential.

How it Works

The Bloom Clinic App is a Schedule Management app that can be used by patients to schedule, update and cancel their appointments. New users can also create an account with a required username, email and password. They can then login using the username and password. Users can also look up information on the licensed therapists, including their biographies and specialization, contact information and location.

Sign Up or Log In Page

The Setup

The beauty of Sinatra is that it already provides the basic structure for an application so that developers can create apps with minimal effort. What had really helped me in creating the app was the models-views-controllers design model and file directory that is typical of a Sinatra app.

File Directory

The first step was to set up the different gems I would need in the Gemfile. The most important gems included sinatra, shotgun, rake, sinatra-activerecord, capybara, and rack-flash3. The next important task was to create a config.ru file. This file establishes a connection to a database through setting up an environment. This is also where the app gets racked up. The Rakefile is another very important file because it allows access to the rake specific tasks.

A few of these tasks that are needed to add information to the database is rake db:create_migration, rake db:migrate, and rake db:seed. In the db folder, I created migrations in the subdirectory migrate in order to create the different tables: patients, therapists, and appointments. I then migrated these tables and seeded the database with initial information on each therapist. This included each therapist’s name, email, bio and location.

Model-View-Controller

This part of the app now involves creating the models for the patients, therapists and appointments. Utilizing ActiveRecord is advantageous here because it makes use of Object Relational Mapping to connect the objects created by the models to the tables in the relational database. In other words, it is the bridge between the database and the models. It also has the ability to represent the models and their data, represent associations between these models, validate models to prevent faulty data from entering the database, and perform database operations in an object-oriented fashion.

There are several associations I used among the three models:

  1. Patient has_many Appointments
  2. Therapist has_many Appointments
  3. Appointments belongs_to Patient
  4. Appointments belongs_to Therapist
  5. Patient has_many Therapists through Appointments
  6. Therapist has_many Patients through Appointments
Entity-Relationship Diagram

Then, I set up the controllers. These are where most of the action happens. Controllers use http requests to notify the model to do an action. This could be updating information in the database. In order to organize my controllers folder, I differentiated four controllers: application, patients, therapists, and appointments.

The application controller contains requests that describe how a user signs up. A patient fills out a username, email and password. Then, a new patient is stored in the database. To ensure that the password of the patient is secure when it is entered into the database, it is necessary to encrypt it. This can be done by using the gem bcrypt. Instead of storing the password as is, a hash is stored instead, which is created by bcrypt. This is a number computed by feeding a string to a hash function. Before hashing it, a random string is prepended to the password — also known as salting. Thus, the password column in the patients table is named password_digest, where it stores the salt and the actual return value of bcrypt. In ActiveRecord, adding has_secure_password to the patient model allows for this functionality.

The patients controller contains requests to login and logout of the app. It is also where a patient can see all his appointments in one page. When an existing user logs in, the password input is run through bcrypt along with the salt from the database. If there is a match, then the login is successful. This verifies that the username and password associated with the user is protected.

The therapist controller has requests to see all therapists in one page, and also to see the information of each therapist in their own separate page.

The appointments controller is the meatiest of them all. That’s because it is where all the CRUD actions — create, read, update and delete — happen. Here, the user requests to book a new appointment, read the info of an upcoming appointment, make an edit to an appointment or cancel the appointment. These actions alter the information in the relational database.

Because it is important to ensure that only the user that is logged in can be manipulating his own appointments, I included a helpers.rb file. This helper functions are used to check whether the user that logged in is using the session and this is determined by the user_id. This is a way to validate all the inputs that are put in by the user and that no other user can modify his appointments.

And finally, the views folder, is where all the HTML is kept. In short, this is the front-end user interface that the user sees and interacts with to make his requests.

The Home Page

And ta-da!! The app is a very simple schedule manager. It is meant to help patients organize their appointments.

Conclusion

When creating an app with multiple parts, it’s very important to do it one step at a time. I realized that when I focused on one controller request then its respective view, I was able to become more organized in writing out my code. Also, it is important to keep tabs of each change in the code that you make. You can do this through the shotgun command. You are able to see changes in your web application in real time.

Moving forward with this app, I think I would like to add more features — possibly for new therapists to come on as providers of therapy. Therapists can also cancel and reschedule appointments from their end. Then, the app would be more like a platform that could match therapists with patients depending on availability, need of specialization, time zone, etc. It would be interesting to also add features such as payments through the app, leaving a review, or a chat box. Other than that, it was fun to finally get a functioning Sinatra app off the ground. I learned a ton about the ins and outs of routing and in the end had extra fun with the HTML/CSS side of things. And finally, once I get around to it, you would be able to find the app on Heroku!

Github Repo: https://github.com/acg2176/bloomclinic

--

--

Anna Guerrero
0 Followers

Be who you are meant to be and you will set the world on fire. JMJ