Skip to content

MahmoudAlQataa/Lab-Management-System

Repository files navigation


🏥 Laboratory Management System

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.


Badges

  • Python
  • Flask
  • SQLite
  • License

✨ Features

📸 Screenshots

Coming soon...

📋 Patient Management

  • 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

🔬 Analysis Support

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

📄 PDF Generation

  • 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

⚙️ Template Settings

  • 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

📊 Statistics

  • Monthly patient and analysis counts
  • Breakdown by analysis type with visual bar chart

🗂️ Reports Page

  • Search by patient name or ID number
  • Filter by month
  • View, Edit, Delete, and History actions per report

🖥️ UI / UX

  • Screensaver after 15 seconds of inactivity (patient form only)
  • Existing patient search with auto-fill from navbar
  • Dynamic tabs for multiple simultaneous analyses

🛠️ Tech Stack

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

📁 Project Structure


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/


🚀 Getting Started (Development)

Prerequisites

  • Python 3.10+
  • pip

Installation

# 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.py

Note: On first run, a LapData/ folder will be created automatically next to LapApp/, containing the database and all generated PDF reports.


📦 Building the Desktop App (Windows)

Prerequisites

Steps

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.spec

3. Build the installer:

  • Open setup.iss in Inno Setup
  • Click Compile
  • Output: dist/RLabSetup.exe

📌 Notes

  • 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

📄 License

This project is proprietary. All rights reserved.


About

Flask-based Laboratory Management System for managing patients, laboratory tests, and generating PDF reports.

Topics

Resources

Stars

Watchers

Forks

Releases

Used by

Contributors

Languages