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.
- 𧬠Object-Oriented Design: Implements OOP principles (encapsulation, inheritance, polymorphism) in
hospital.pyforPatient,Doctor, andAppointmentclasses. - π CRUD Operations: Full Create, Read, Update, Delete functionality for patients, doctors, and appointments, managed in
manager.pywith JSON storage. - π¨ Rich CLI Menu: Uses the
richlibrary to create a colorful and formatted menu inmain.pyfor intuitive navigation. - π¨ Custom Exception Handling: Defines custom exceptions (
InvalidAgeError,InvalidDateError,InvalidGenderError) inexceptions.pyfor robust input validation. - πΎ JSON Data Persistence: Stores data in
patients.json,doctors.json, andappointments.jsonfor lightweight, portable storage. - π¨ Custom Color Module: Uses
color.pyfor consistent ANSI color styling, especially for error messages. - π Activity Logging: Tracks operations and errors in
logs/hospital.logusing Pythonβsloggingmodule. - β‘ Dependency Management: Utilizes
uvfor fast and reliable dependency installation. - π User-Friendly Prompts: Intuitive input handling with clear error messages in
main.py.
| 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 |
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
- 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
-
Clone the repository:
git clone https://github.com/Muhammad-Fraooq/hospital_management_system.git cd hospital_management_system -
Set up a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Run the application:
python main.py
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.
-
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 -
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. -
Checking Logs:
- View
logs/hospital.logfor detailed records of operations and errors.
- View
- 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
richfor menus - Modular code organization
- Portfolio Project: Showcase professional Python skills with real-world applicability.
We welcome contributions to enhance the HMS! To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -m "Add your feature"). - Push to your branch (
git push origin feature/your-feature). - Open a Pull Request with a clear description.
Please follow the Contributor Covenant Code of Conduct.
Have questions or ideas? Letβs connect!
- π¨βπ» Name : Muhammad Farooq
- π§ Email: Email
- πΌ LinkedIn: LinkedIn
- π» GitHub: GitHub
- π Portfolio: Muhammad Farooq
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.