Skip to content

About

Local-first pharmacy expiry tracker — scan images/PDFs, extract and validate batch & expiry data, organize records, and optionally export to Google Sheets.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

💊 ExpiryScanner

Local-first pharmacy expiry tracking from images & PDFs

Scan → Extract → Validate → Track → Export

ExpiryScanner is an open-source local AI system that extracts medicine, batch, and expiry information from pharmacy images and PDF documents, validates the results, keeps structured local records, and optionally exports tracking data to Google Sheets.

A credential-free, local-first reference project for extracting pharmacy inventory and expiry information from medicine images and scanned pharmacy bills.

Built from a real-world development/learning experience by Shivam Kumar.

Core problem

Real pharmacy documents are messy:

  • low-quality photographs
  • scanned PDFs without a real text layer
  • OCR substitutions
  • handwritten marks
  • wrapped invoice rows
  • different supplier layouts
  • missing fields
  • column confusion such as HSN vs batch and MRP vs rate
  • ambiguous dates

The project is designed to fail safely instead of producing plausible-looking bad inventory data.

Core fields

Priority:

  1. Item Name
  2. Batch No
  3. EXP — highest priority
  4. MFG
  5. MRP
  6. Quantity

Secondary fields may include supplier, manufacturer, pack, HSN, rate, GST, amount, deal/scheme and remarks.

Rules:

  • missing data → NA
  • uncertain core data → REVIEW
  • never invent a date
  • HSN is never batch
  • GST is never expiry
  • rate is never MRP
  • MFG is NA unless explicit evidence exists
  • human correction is the only source for persistent learning

Reference architecture

                    IMAGE / PDF
                         |
                         v
               High-resolution rendering
                         |
                         v
                OCR + spatial evidence
                         |
             +-----------+-----------+
             |                       |
             v                       v
        IMAGE FLOW              INVOICE FLOW
       direct vision          OCR/table evidence
             |                       |
             +-----------+-----------+
                         |
                         v
                 Candidate extraction
                         |
                         v
                Deterministic validator
                         |
             +-----------+-----------+
             |           |           |
           VALID       REVIEW      REJECT
             |           |
             v           v
          Outputs     Review queue
                         |
                         v
                  Human correction
                         |
                         v
                  Local learning

Result states

  • VALID — core checks pass.
  • REVIEW — missing/ambiguous data, low confidence, expired date, or processing failure.

Local models

Reference configuration:

  • qwen3-vl:2b — local vision extraction
  • llama3.1:8b — optional local text/reasoning check

The public demo does not require Google or cloud AI.

Install

git clone https://github.com/snvx7576/ExpiryScanner.git
cd ExpiryScanner

python3 -m venv .venv
source .venv/bin/activate

python -m pip install --upgrade pip
pip install -r requirements.txt

On macOS:

brew install tesseract

Install Ollama separately and pull a local vision model:

ollama pull qwen3-vl:2b

Optional:

ollama pull llama3.1:8b

CLI

Image:

python -m src.pharmacy_expiry_ai.cli image /path/to/medicine.jpg

PDF:

python -m src.pharmacy_expiry_ai.cli pdf /path/to/invoice.pdf

Watcher:

python -m src.pharmacy_expiry_ai.cli watch ./inbox

The reference watcher routes .pdf files to the PDF flow and image formats to the image flow.

Google Sheets

Optional. See:

docs/google-sheets.md

No credentials are included.

Learning

Human corrections may be stored locally as JSONL examples.

See:

docs/learning.md

Never publish private inventory, invoices, patients, addresses, tokens or API credentials.

Security

Run before every public push:

python scripts/secret_scan.py .

See SECURITY.md.

Developer

Shivam Kumar — @snvx7576

Repository: github.com/snvx7576/ExpiryScanner

Acknowledgement

This repository is the cleaned, credential-free learning/demo edition of a practical pharmacy inventory automation experiment developed by Shivam Kumar.

It is intended to help other developers build local expiry/inventory workflows while learning from the realities of noisy Indian pharmacy images and invoices.

Disclaimer

This software is an extraction/automation aid. It is not a substitute for checking the physical medicine package or source invoice, and it is not medical or regulatory advice.

License

MIT.

About

Local-first pharmacy expiry tracker — scan images/PDFs, extract and validate batch & expiry data, organize records, and optionally export to Google Sheets.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages