Sinatra Portfolio Project
Published: 2020-11-23 04:34:51

As a student at Flatiron bootcamp's software engineering program, students are required to produce five standalone portfolio projects. After I research on project ideas that I can work on, I decided on developing a Sinatra based web application to manage patient and staff information at a hospital. In the web application,  a patient and staff can sign up, log in, and schedule appointments with a practitioner. In addition, the staff can register a new patient to the hospitals database and retrieve patients data for scheduling appointments. On the other hand, the practitioner can enter diagnosis and prescription data for a given patient. The patient can also write, edit or delete comments for a practitioner after the patient visited the given practitioner. 

Before I started coding the project, I draw a schematics of the different interfaces that the final product must have. In addition, I wrote details of the interactions between the interfaces on the schematics. I then created the file structure for the web app. I used the MVC architecture in organizing these files as shown below. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/j2mcnw4nnxngvzis984k.png)

<h2>Controllers</h2>

When I created six controllers to implement CRUD routes. The application controller defines the configurations for the app. Two helper methods were defined in the application_controller to authorize users access relevant data to the particular user. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b6t3btezk21pcqwtkawp.png)
The second controller manages the routes for creation of appointments by either the staff or patient. The comments_controller provides the routes to manage comment that a patient can create, edit or delete. The patient and staffs controllers are created to control the routes for the interaction of a patient and staff. The last controller defines routes for sign up and log in of users. 

<h2>Models</h2>

For the project, I created six models. The models are user, staff, patient, prescription, comment and appointments. Migrations were done for each of these models.  
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7e8jwc1p0zpc6vvc2lt8.png)

<h2> Views </h2>

As the last component of the MVC architecture, views create the forms and content that users of the web application interact with. In this project, I created five sets of views to render appointments, comments, patients, staffs, and users related content and forms. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/uwz04qd9m0o0wamtm80j.png)

<h2> How does the app work? </h2>

A patient gets registered by a staff in the hospital before they can sign up to the patient portal. Once the patients information is registered to the hospital's database, they can sign up to the patient portal. Based on the patient's full name and date of birth, the patient gets authorized to create a user account. Once the user account is created, the patient can schedule appointment with a practitioner from the list provided. In addition, the patient is able to view the list of old and upcoming appointments. Once they are seen by the practitioner, the patient can write comment about the practitioner.  
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/e1qec26kzb6mv4wuspui.png)

As to the staff, the staff can create user accounts which give them access to a search field to find the patient to schedule appointments for. They can also update the patients data. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/p6wctssmcqnb0ob7ek4p.png)

The practitioner has access to the interface where they can search for a patient using the patients name and enter data about diagnosis and prescriptions to a patient at the end of the visit. The practitioner is also able to view the comments posted.