A comprehensive web-based patient record management system built with Flask and SQLite. This system allows healthcare facilities to efficiently manage patient information, including personal details, medical history, and emergency contacts.
- Patient Registration: Complete patient intake form with validation
- Patient Records Management: View, search, and filter patient records
- Responsive Design: Works seamlessly on desktop and mobile devices
- Data Validation: Comprehensive form validation and error handling
- Search & Filter: Search by name, phone, or patient ID with gender and blood type filters
- Emergency Contacts: Store emergency contact information for each patient
- Medical Information: Track allergies, medications, and medical history
- Secure Database: SQLite database with proper data integrity
| Frontend | Backend | Database |
|---|---|---|
| HTML, CSS | Python (Flask) | SQLite3 |
- Python 3.7 or higher
- Flask framework
- SQLite (included with Python)
-
Clone the repository
git clone https://github.com/yourusername/hospital-patient-record-system.git cd hospital-patient-record-system -
Create a virtual environment (recommended)
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install flask
-
Run the application
python app.py
-
Access the application Open your browser and navigate to
http://localhost:5000
hospital-patient-record-system/
β
βββ app.py # Main Flask application
βββ hospital.db # SQLite database (created automatically)
βββ templates/
β βββ patient_form.html # Patient registration form
β βββ patients.html # Patient records view
β βββ home.html # Dashboard (you'll need to create this)
βββ static/
β βββ styles.css # CSS styles (you'll need to create this)
βββ README.md # This file
The system uses SQLite with the following patient table structure:
CREATE TABLE patients (
patient_id INTEGER PRIMARY KEY,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
date_of_birth DATE NOT NULL,
gender TEXT NOT NULL,
blood_type TEXT,
marital_status TEXT,
phone TEXT NOT NULL,
email TEXT,
address TEXT NOT NULL,
city TEXT NOT NULL,
state TEXT NOT NULL,
zip_code TEXT NOT NULL,
emergency_name TEXT NOT NULL,
emergency_relation TEXT NOT NULL,
emergency_phone TEXT NOT NULL,
primary_doctor TEXT,
insurance_provider TEXT,
policy_number TEXT,
allergies TEXT,
medications TEXT,
medical_history TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);- Navigate to the "Add Patient" page
- Fill in all required fields (marked with *)
- Enter a unique Patient ID
- Complete personal, contact, emergency, and medical information
- Click "Add Patient" to save the record
- Go to "View Records" page
- Use the search bar to find specific patients
- Filter by gender or blood type using dropdown menus
- View comprehensive patient information in the table
- Patient ID (must be unique)
- First Name & Last Name
- Date of Birth
- Gender
- Phone Number
- Complete Address (Address, City, State, ZIP Code)
- Emergency Contact Information (Name, Relationship, Phone)
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Dashboard home page |
| GET/POST | /patient_form |
Patient registration form |
| GET | /patients |
View all patient records |
Create a .env file in the root directory for production settings:
SECRET_KEY=your-super-secret-key-here
DEBUG=False
DATABASE_PATH=hospital.db- Change the default
secret_keyin production - Set
DEBUG=Falsein production environment - Consider using environment variables for sensitive configuration
- Implement user authentication for production use
The application runs in debug mode by default:
app.run(debug=True, host='0.0.0.0', port=5000)The database is automatically initialized when you first run the application. To reset the database:
- Stop the application
- Delete
hospital.dbfile - Restart the application
- User authentication and role-based access
- Patient appointment scheduling
- Medical report generation
- Data export functionality (PDF, CSV)
- Advanced search with date ranges
- Patient visit history tracking
- Integration with medical devices
- Backup and restore functionality
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Database Error: Patient ID already exists
- Each patient must have a unique Patient ID
- Check existing records before adding new patients
Form Validation Errors
- Ensure all required fields (marked with *) are filled
- Check date format for Date of Birth field
- Verify phone numbers are in correct format
Application Won't Start
- Check Python version (3.7+ required)
- Verify Flask is installed:
pip show flask - Ensure no other application is using port 5000
To view/edit the database directly, you can use SQLite browser tools:
- DB Browser for SQLite
- Command line:
sqlite3 hospital.db
For support and questions:
- Open an issue on GitHub
- Check the documentation
- Review common troubleshooting steps above
- Add patient search and filters
- Export reports (PDF/Excel)
- Role-based login (admin, doctor, receptionist)
- Appointment tracking and billing module
This project would not have been possible without the valuable guidance and real-world insights provided by Ayesha Asalam (https://www.linkedin.com/in/a-aslam/). Her knowledge of hospital operations helped shape the structure and logic of the system, especially in ensuring the practical flow of patient data handling.
Thank you for your contribution to making this project more realistic and impactful.
Made with β€οΈ for healthcare professionals
This system is designed to help healthcare facilities manage patient records efficiently and securely.

