Skip to content

πŸ₯ Hospital Management System powered by Python and OOP design. πŸ’» CLI-based interface to manage patients, doctors, and staff. πŸ“‚ Structured data stored persistently using JSON files. 🧩 Modular, maintainable code with custom exceptions and logging.

License

Notifications You must be signed in to change notification settings

Muhammad-Fraooq/hospital_management_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🩺 CLI-Based Hospital Management System

Python License Status Platform Contributions Dependencies

Welcome to the CLI-Based Hospital Management System (HMS), a powerful and modular command-line application built in Python to streamline hospital operations. Designed for small clinics and educational purposes, this system enables efficient management of patients, doctors, and appointments through a vibrant, user-friendly terminal interface. The menu is styled using the rich library for colorful and formatted display, ensuring an engaging user experience.

This project demonstrates professional software engineering practices, including Object-Oriented Programming (OOP), custom exception handling, JSON-based data persistence, and activity logging, making it an excellent learning resource for developers and a practical tool for hospital management.


🌟 Key Features

  • 🧬 Object-Oriented Design: Implements OOP principles (encapsulation, inheritance, polymorphism) in hospital.py for Patient, Doctor, and Appointment classes.
  • πŸ“ CRUD Operations: Full Create, Read, Update, Delete functionality for patients, doctors, and appointments, managed in manager.py with JSON storage.
  • 🎨 Rich CLI Menu: Uses the rich library to create a colorful and formatted menu in main.py for intuitive navigation.
  • 🚨 Custom Exception Handling: Defines custom exceptions (InvalidAgeError, InvalidDateError, InvalidGenderError) in exceptions.py for robust input validation.
  • πŸ’Ύ JSON Data Persistence: Stores data in patients.json, doctors.json, and appointments.json for lightweight, portable storage.
  • 🎨 Custom Color Module: Uses color.py for consistent ANSI color styling, especially for error messages.
  • πŸ“œ Activity Logging: Tracks operations and errors in logs/hospital.log using Python’s logging module.
  • ⚑ Dependency Management: Utilizes uv for fast and reliable dependency installation.
  • πŸ”’ User-Friendly Prompts: Intuitive input handling with clear error messages in main.py.

πŸ›  Technologies Used

Technology Purpose
Python 3.10+ Core programming language
Rich Colorful and formatted CLI menu
JSON Lightweight data storage
Logging Module Activity and error logging
UV Dependency management
Custom Modules hospital.py, manager.py, main.py, color.py, exceptions.py

πŸ“‚ Project Structure

hospital_management_system/
β”œβ”€β”€ main.py               # CLI menu, user inputs, and try-except error handling
β”œβ”€β”€ hospital.py          # OOP classes (Patient, Doctor, Appointment) with OOP principles
β”œβ”€β”€ manager.py           # CRUD operations and JSON data management
β”œβ”€β”€ color/
β”‚   └── color.py         # ANSI color codes for styling (e.g., error messages)
β”œβ”€β”€ exceptions/
β”‚   └── exceptions.py    # Custom exceptions (InvalidAgeError, InvalidDateError, InvalidGenderError)
β”‚   └── main.py    # Custom error (validate_gender, validate_doctor_age, validate_patient_age, validate_date)
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ hospital-data.json    # hospital data storage
β”œβ”€β”€ logs/
β”‚   └── hospital.log          # Activity and error logs
β”œβ”€β”€ README.md            # Project documentation

πŸš€ Getting Started

πŸ“‹ Prerequisites

  • Python: Version 3.10 or higher
  • Git: For cloning the repository
  • UV: For dependency management (optional but recommended)
  • Virtual Environment: To isolate dependencies
  • Terminal/CLI: For running the application

πŸ“¦ Installation

  1. Clone the repository:

    git clone https://github.com/Muhammad-Fraooq/hospital_management_system.git
    cd hospital_management_system
  2. Set up a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Run the application:

    python main.py

πŸ–₯ Usage

Launch the application with python main.py to access an interactive CLI menu styled with rich for a colorful and engaging experience. Navigate using numeric inputs to manage hospital operations.

Example Workflow

  1. Main Menu:

    ==================================================
    ╔═ πŸ₯ Welcome to the Hospital Management System ═╗
    β•‘ 1. βž• Add (Patient/Doctor)                     β•‘
    β•‘ 2. πŸ“… Book Appointment                         β•‘
    β•‘ 3. πŸ“‹ Show All Appointments                    β•‘
    β•‘ 4. πŸ” Search (Patient/Doctor)                  β•‘
    β•‘ 5. βš™οΈ  Settings (Patient/Doctor)                β•‘
    β•‘ 6. ❌ Cancel Appointment                       β•‘
    β•‘ 7. πŸšͺ Exit                                     β•‘
    β•šβ•β•β•β•β•β•β•β• Press a number to continue... ═════════╝
    ==================================================
    
    Enter your choice: 1
    
  2. Adding a Patient (with custom error handling):

    Enter patient name: Alice Smith
    Enter patient age: 25
    Enter patient gender (M/F/O): F
    Enter patient condition: Asthma
    [SUCCESS] Patient Alice Smith added successfully!
    

    Invalid Input Example:

    Enter patient age: -5
    [ERROR] InvalidAgeError: Age cannot be negative.
    
  3. Checking Logs:

    • View logs/hospital.log for detailed records of operations and errors.

🎯 Use Cases

  • Small Clinics: Manage patient records, doctor schedules, and appointments efficiently in a lightweight CLI application.
  • Educational Tool: Learn and practice:
    • Object-Oriented Programming (OOP) principles
    • Custom exception handling
    • JSON-based data persistence
    • CLI interface design with rich for menus
    • Modular code organization
  • Portfolio Project: Showcase professional Python skills with real-world applicability.

🀝 Contributing

We welcome contributions to enhance the HMS! To contribute:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/your-feature).
  3. Commit your changes (git commit -m "Add your feature").
  4. Push to your branch (git push origin feature/your-feature).
  5. Open a Pull Request with a clear description.

Please follow the Contributor Covenant Code of Conduct.


πŸ“¬ Contact

Have questions or ideas? Let’s connect!


πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.


πŸ‘¨β€πŸ’» Crafted with passion by a GIAIC student on the journey to becoming a world-class Agentic AI Engineer.

About

πŸ₯ Hospital Management System powered by Python and OOP design. πŸ’» CLI-based interface to manage patients, doctors, and staff. πŸ“‚ Structured data stored persistently using JSON files. 🧩 Modular, maintainable code with custom exceptions and logging.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages