This API provides endpoints for booking, managing, and viewing healthcare appointments.
The API was built using the following frameworks and tools:
- FastAPI: A modern, fast, web framework for building APIs with Python 3.7+ based on standard Python type hints.
- Alembic: A database migration tool for SQLAlchemy, allowing you to manage changes to your database schema over time.
- PostgreSQL: A powerful, open-source relational database management system.
- SQLAlchemy: A SQL toolkit and Object-Relational Mapping (ORM) library for Python.
Method: POST
Endpoint: /appointments
Description: Create a new appointment.
Method: PUT
Endpoint: /appointments/{appointment_id}
Description: Update an existing appointment.
Method: GET
Endpoint: /appointments
Description: View a list of appointments based on filters (patient_id, doctor_id, date range, etc.).
Method: DELETE
Endpoint: /appointments/{appointment_id}
Description: Cancel an existing appointment.
Method: POST
Endpoint: /users
Description: Register a new user account.
Method: POST
Endpoint: /login
Description: Log in and receive an access token for API interactions.
Method: POST
Endpoint: /doctors
Description: Register a new doctor account.
Method: POST
Endpoint: /clinics
Description: Register a new clinic.
Method: GET
Endpoint: /doctors/{doctor_id}/schedules
Description: View the availability schedule of a specific doctor.
Method: GET
Endpoint: /doctors
Description: View a list of all doctors.
Method: GET
Endpoint: /clinics
Description: View a list of all clinics.
Method: POST
Endpoint: /patients
Description: Register a new patient.
Method: GET
Endpoint: /patients
Description: View a list of all registered patients.
- Clone this repository:
git clone https://github.com/DavidDanso/healthcare-booking-appointment-api.git
cd healthcare-booking-appointment-api
- Set up a virtual environment to isolate project dependencies:
On Windows
python -m venv venv
On macOS and Linux
python3 -m venv venv
2.1. Activate the virtual environment:
On Windows
venv\Scripts\activate
On macOS and Linux
source venv/bin/activate
- Install FastAPI with all dependencies or install all the packages in the requirements.txt file:
pip install fastapi[all]
pip install -r requirements.txt
- Run the API using uvicorn:
uvicorn app.main:app --reload
- Access the API documentation by visiting the following URL in your browser:
http://127.0.0.1:8000/docs
- Create a PostgreSQL database.
- Create a file named .env in the project directory and add the following configuration:
DATABASE_HOSTNAME = localhost
DATABASE_PORT = 5432
DATABASE_PASSWORD = your_database_password
DATABASE_NAME = your_database_name
DATABASE_USERNAME = your_database_username
SECRET_KEY = your_secret_key
ALGORITHM = HS256
ACCESS_TOKEN_EXPIRE_MINUTES = 60
Replace your_database_password, your_database_name, your_database_username, and your_secret_key with appropriate values.
You can learn more about FastAPI by watching the tutorial series on YouTube:
DavidDanso - davidkellybrownson@gmail.com