A comprehensive medical laboratory management system built with Flask, packaged as a Windows desktop application via PyInstaller and WebView.
Developed as a real-world laboratory management solution using Flask and SQLite.
- Python
- Flask
- SQLite
- License
Coming soon...
- Add and manage patient records (name, age, gender, ID number, doctor)
- Search existing patients instantly while adding new reports
- Full patient history — view all analyses per patient in one place
- Link new analyses to existing patient records
| Type | Description |
|---|---|
| General | Fully customizable fields |
| Clinical Chemistry | Template-based with custom fields |
| Hematology | Template-based |
| Hormones | Template-based |
| Microbiology | 4 core fields + 33 antibiotics |
| Semen Analysis | Full morphology + motility grading |
| Urine Analysis | Two-column layout |
| Stool Analysis | Core fields + parasites |
| Serology / Virology | Template-based |
| Tumor Markers | Template-based |
| Lab Report | Title + free-text content |
- Individual PDF reports per analysis
- Comprehensive PDF combining all standard analyses for one patient
- Professional header/footer with lab logo and watermark
- Arabic text support (names, comments, footer)
- Direct print via Adobe Acrobat
- Edit field names, units, and normal ranges per template
- Set result fields as Text or Dropdown with custom options
- Set normal range as Text or Dropdown (e.g.
male: 13.5,female: 12.5,child: 11.0) - Auto-fill normal range based on patient age and gender
- Monthly patient and analysis counts
- Breakdown by analysis type with visual bar chart
- Search by patient name or ID number
- Filter by month
- View, Edit, Delete, and History actions per report
- Screensaver after 15 seconds of inactivity (patient form only)
- Existing patient search with auto-fill from navbar
- Dynamic tabs for multiple simultaneous analyses
| Layer | Technology |
|---|---|
| Backend | Python / Flask |
| Database | SQLite |
| PDF Generation | ReportLab |
| Arabic Support | arabic-reshaper, python-bidi |
| Frontend | HTML, CSS, JavaScript |
| Desktop Wrapper | PyWebView |
| Packaging | PyInstaller + Inno Setup |
Lab-Management-System/
├── LapApp/ ← Application source (this repository)
│ ├── app.py # Flask app init
│ ├── config.py # Path configuration
│ ├── launcher.py # Entry point: starts Flask + opens WebView
│ ├── RLab.spec # PyInstaller spec file
│ ├── setup.iss # Inno Setup script
│ ├── AppIcon.ico # App icon
│ ├── requirements.txt
│ ├── client_config.example.py # Copy and rename to client_config.py
│ ├── models/
│ │ ├── database.py
│ │ └── schema.py
│ ├── routes/
│ │ ├── patients.py # Patient & analysis routes
│ │ ├── reports.py # Reports list & delete
│ │ ├── settings.py # Template settings
│ │ ├── stats.py # Statistics
│ │ └── doctors.py # Doctor management
│ ├── services/
│ │ ├── pdf_service.py # PDF generation engine
│ │ └── template_service.py
│ ├── templates/ # HTML templates (Jinja2)
│ └── static/
│ ├── css/
│ ├── fonts/
│ ├── js/
│ │ └── Sortable.min.js
│ └── img/
│ ├── header.png
│ └── WaterMark.png
└── LapData/ ← Auto-generated on first run (not in repo)
├── lap.db
└── pdf_reports/
└── YYYY/MM/
- Python 3.10+
- pip
# Clone the repository
git clone https://github.com/MahmoudAlQataa/Lab-Management-System.git
cd Lab-Management-System
# Create virtual environment
python -m venv venv
# Activate (Windows)
.\venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txt
# Run the app
python launcher.pyNote: On first run, a
LapData/folder will be created automatically next toLapApp/, containing the database and all generated PDF reports.
1. Check for target="_blank" in templates (breaks WebView):
Select-String -Path "templates\*.html" -Pattern 'target="_blank"'2. Build the EXE:
# From inside LapApp/
pyinstaller RLab.spec3. Build the installer:
- Open
setup.issin Inno Setup - Click Compile
- Output:
dist/RLabSetup.exe
- PDF files are saved under
LapData/pdf_reports/YYYY/MM/ - Patient names are sanitized before use in file paths (Windows-safe)
- Comprehensive PDF is generated automatically when a patient has 2+ standard analyses
- Standalone analyses (Urine, Semen, Stool, Microbiology, Lab Report) are excluded from Comprehensive PDF
- All JS libraries are bundled locally — no CDN dependencies (required for packaged app)
- Dynamic port selection at runtime avoids conflicts on client machines
This project is proprietary. All rights reserved.