Skip to content

PrajwalDataScientist/REST-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API

A Flask-based RESTful API for managing a hospital database, including patient profiles, disease records (Heart Disease, Lung Infection, Hypertension), and billing information. Built with Flask-SQLAlchemy for ORM and Flask-RESTful for API endpoints, with an OpenAPI 3.0 specification for easy testing.

Features

  • Patient Management: CRUD operations for user records (name, age, email, etc.).
  • Disease Tracking: Manage records for Heart Disease, Lung Infection, and Hypertension with specific metrics.
  • Billing System: Track patient admissions, discharges, and billing amounts.
  • Relationships: One-to-many links between users and disease/billing records.
  • API Documentation: OpenAPI 3.0 YAML (openapi.yaml) for Postman/Swagger UI.
  • Testing: Supports curl, Postman, and Swagger UI.

Tech Stack

  • Backend: Flask, Flask-SQLAlchemy, Flask-RESTful
  • Database: SQLite (configurable for PostgreSQL/MySQL)
  • Documentation: OpenAPI 3.0 (YAML)
  • Environment: Python 3.8+

Setup

Prerequisites

  • Python 3.8+
  • Git
  • Postman (for testing)

Installation

  1. Clone the Repository:

    git clone https://github.com/yourusername/Hospital-Management-API.git
    cd Hospital-Management-API
  2. Create Virtual Environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install Dependencies:

    pip install flask flask-sqlalchemy flask-restful
  4. Run the Application:

    python app.py
    • Server runs at http://127.0.0.1:5000.
    • SQLite database (database.db) is auto-created.

Testing

  1. Import API Specification:

    • In Postman, click Import > File > Select openapi.yaml.
    • Set environment variable baseUrl to http://127.0.0.1:5000.
    • Test endpoints (e.g., POST /api/users).
  2. Sample Request (POST /api/users):

    {
        "name": "Prajwal",
        "age": 30,
        "number": "1258963",
        "gmail": "prajwal@gmail.com",
        "gender": "Male",
        "disease": "Heart Disease"
    }
  3. Curl Commands:

    • See api_curl_commands.md for examples.

API Endpoints

Resource Method Endpoint Description
Users GET /api/users List all users
POST /api/users Create user
GET /api/users/{id} Get user by ID
PATCH /api/users/{id} Update user
DELETE /api/users/{id} Delete user
Heart Diseases GET /api/heart_diseases List records
POST /api/heart_diseases Create record
GET /api/heart_diseases/{id} Get record
PATCH /api/heart_diseases/{id} Update record
DELETE /api/heart_diseases/{id} Delete record
Lung Infections GET /api/lung_infections List records
POST /api/lung_infections Create record
GET /api/lung_infections/{id} Get record
PATCH /api/lung_infections/{id} Update record
DELETE /api/lung_infections/{id} Delete record
Hypertension GET /api/hypertensions List records
POST /api/hypertensions Create record
GET /api/hypertensions/{id} Get record
PATCH /api/hypertensions/{id} Update record
DELETE /api/hypertensions/{id} Delete record
Billing GET /api/billings List records
POST /api/billings Create record
GET /api/billings/{id} Get record
PATCH /api/billings/{id} Update record
DELETE /api/billings/{id} Delete record

Database Schema

  • Users: Stores patient data (id, name, age, number, gmail, gender, disease, current_date).
  • HeartDisease: Tracks heart disease records (user_id, test_date, result).
  • LungInfection: Tracks lung infection records (user_id, test_date, result).
  • Hypertension: Tracks blood pressure records (user_id, test_date, systolic, diastolic).
  • Billing: Manages billing (user_id, joined_date, disease, discharge_date, amount).

Generate the ERD using DBDiagram.io with the provided DBML in api_curl_commands.md.

Project Structure

Hospital-Management-API/
├── app.py                 # API routes and resources
├── database_schema.py     # Database models and setup
├── openapi.yaml           # OpenAPI 3.0 specification
├── api_curl_commands.md   # Curl command examples
├── README.md              # Project documentation
└── database.db            # SQLite database (auto-generated)

Contributing

  1. Fork the repo.
  2. Create a feature branch (git checkout -b feature/YourFeature).
  3. Commit changes (git commit -m 'Add YourFeature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a Pull Request.

License

Free to use...!

Contact

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages