Empowering Kenyans with drug price transparency at the point of purchase.
Smart Pharmacy Checker is a web-based system that allows users to verify whether they are being overcharged for medication by comparing pharmacy prices against the official Ministry of Health (MOH) Kenya benchmark prices. The system recommends nearby cheaper pharmacies, supports barcode and QR code scanning, and provides a structured overcharge reporting workflow.
Built as a Final Year Project at Multimedia University of Kenya, Faculty of Computing and Information Technology.
Dashboard showing "Welcome back, [username] 👋", two animated circular rings (🚩 Reports Made in red, Unsuccessful Reports), the search input with Search and 📷 Scan buttons below
- 🔍 Drug search — real-time autocomplete from 700+ MOH benchmark drugs
- 📷 Barcode and QR scanning — scan via webcam or upload an image file
- 💰 Overpayment calculator — computes KES overcharge amount and percentage vs MOH price
- 🏪 Pharmacy recommendations — sorted by cheapest price first, then nearest distance
- 🗺️ Travel time estimates — walking, motorbike, and car for each pharmacy
- 📍 Pharmacy profiles — photo gallery, Google Maps location bubble, drug price
- 🚩 Overcharge reporting — multi-drug structured reports backed by receipt photos
- 🖨️ QR and barcode generation — printable sheet for all drugs, individual downloads
- ⚙️ Admin pharmacy management — create, edit, delete pharmacies with CSV price upload
- 📊 User activity tracking — persistent drugs searched and reports made counters
- 📱 Fully responsive — sidebar on desktop, bottom nav bar on mobile
Sign Up Simple sign up that requires name,password and password confirm field
Autocomplete in Action TO eliminate user errors in typing the drug name
Camera Mode — QR
Barcode scanning
Overpayment module --select quantity,then see the overpayment
Overpayment module result dislay --select quantity,Enter the Price charged,Calculates and Displays the price
Recommendations page showing at least two pharmacy cards each with cover photo, pharmacy name, 📍 location bubble, price badge, distance in km, and the three travel time rows (🚶 Walking / 🏍️ Motorbike / 🚗 Car). Arrow pointing to "Tap for details →"
Pharmacy Detail Modal
Once the pharmacy profile is clicked...it expands to show more pharmacy details and more photo glossary
Report form showing the pharmacy name field with autocomplete, at least two drug entry cards open each with drug name autocomplete, category radio buttons, amount and price fields, and the receipt upload section at the bottom
just click the QR code sheet
ADMIN FEATURES CREATE A SUPER USER IN THE TERMINAL AND THEN LOG IN AS AN ADMIN TO ACCESS THIS FEATURES. USE THE COMMAND: PYTHON MANAGE.PY CREATESUPERUSER
Manage List
Manage Pharmacies page showing pharmacy cards with cover photos, name, location description, drug count, and Edit / Delete buttons. Add Pharmacy button prominent at top right
Create Pharmacy Form
Create pharmacy form showing the location section — coordinates entered, the blue 📍 geocode bubble showing the resolved place name with ✓ badge, and the 🗺️ View on Google Maps button below
Edit Pharmacy
Edit pharmacy form showing the existing photos thumbnails (cover labelled), the location geocode bubble, and the CSV upload warning banner
Mobile Bottom Navigation
Any page viewed on a narrow mobile viewport showing the dark bottom navigation bar with 🔍 Search, 🏪 Pharmacies, 🚩 Report, 📷 QR icons and labels — active icon highlighted in blue
| Layer | Technology |
|---|---|
| Backend framework | Python 3.12, Django 4.2 |
| Database | SQLite via Django ORM |
| Frontend | Bootstrap 5.3, Vanilla JavaScript ES6 |
| Barcode scanning | html5-qrcode 2.3.8 (CDN) |
| QR code generation | qrcode[pil] |
| Barcode generation | python-barcode[images] |
| Reverse geocoding | OpenStreetMap Nominatim (free, no API key) |
| Image processing | Pillow |
smart_pharmacy/
├── manage.py
├── requirements.txt
├── data/
│ └── moh_benchmark.csv # MOH drug price seed data (700+ drugs)
│
├── smart_pharmacy/ # Project config
│ ├── settings.py
│ └── urls.py
│
├── accounts/ # Authentication app
│ ├── views.py
│ ├── urls.py
│ └── templates/accounts/
│ └── signup.html
│
├── drugs/ # Core drug logic app
│ ├── models.py # Drug, UserActivity
│ ├── views.py
│ ├── utils.py # Overpayment formula
│ ├── urls.py
│ ├── management/commands/
│ │ └── import_moh_csv.py
│ └── templates/drugs/
│ ├── search.html
│ ├── quantity_select.html
│ ├── price_entry.html
│ ├── result.html
│ └── qr_sheet.html
│
├── pharmacies/ # Pharmacy logic app
│ ├── models.py # Pharmacy, PharmacyImage, PharmacyDrug,
│ │ # OverchargeReport, OverchargeReportItem
│ ├── views.py
│ ├── utils.py # Haversine + travel time
│ ├── urls.py
│ └── templates/pharmacies/
│ ├── home.html
│ ├── recommendations.html
│ ├── report_form.html
│ ├── report_success.html
│ ├── manage.html
│ ├── create.html
│ ├── edit.html
│ └── delete_confirm.html
│
├── static/
│ └── css/main.css
│
├── media/ # Uploaded files — gitignored
│ ├── pharmacy_images/
│ └── receipts/
│
└── templates/
├── base.html
└── registration/
└── login.html
- Python 3.10 or higher
- pip
- Git
git clone https://github.com/yourusername/smart-pharmacy.git
cd smart-pharmacy# Windows
python -m venv venv
venv\Scripts\activate
# macOS / Linux
python -m venv venv
source venv/bin/activatepip install -r requirements.txtpython manage.py makemigrations
python manage.py migratepython manage.py createsuperuserpython manage.py import_moh_csv data/moh_benchmark.csvExpected output:
Done. Created: 113 Updated: 0 Skipped: 0
python manage.py runserverVisit http://localhost:8000
⚠️ Always uselocalhostnot127.0.0.1— the barcode scanner camera requires a secure context whichlocalhostsatisfies automatically.
- Go to Search Drug
- Click 📷 Scan
- Select the Camera tab
- Choose QR Code or Barcode mode
- Hold the code inside the corner guide frame
- Click 📷 Scan
- Select the Upload tab
- Choose a photo of the QR code or barcode
- Click 🔍 Scan Uploaded Code
Visit /drugs/qr-sheet/ to see all drugs with their QR codes rendered. Each drug has a unique code in the format SMARTPHARMA_DRUG_{id}. Print the sheet or display it on a second screen for testing.
MOH Total = moh_price_per_unit × quantity
Overcharge = user_total_price − MOH Total
Overcharge % = (Overcharge ÷ MOH Total) × 100
If the result is zero or negative — no overcharge is reported.
Only staff users can manage pharmacies.
- Log in as staff
- Click ⚙️ Manage in the sidebar
- Click Add Pharmacy
- Fill in name, coordinates (right-click on Google Maps to copy), description, and photos
- Upload the pharmacy drug price CSV
drug_name,strength,price_per_unit
Paracetamol,500mg,5.50
Ibuprofen,400mg,8.00
Amoxicillin,500mg,16.00Drug names must match the MOH benchmark list exactly (case-insensitive). Unmatched rows are skipped and reported.
| Role | Permissions |
|---|---|
| Regular User | Search drugs, view recommendations, submit overcharge reports, view QR codes |
| Staff / Admin | All of the above plus manage pharmacies, import data, review reports |
Promote a user to staff:
python manage.py shell -c "
from django.contrib.auth.models import User
u = User.objects.get(username='yourname')
u.is_staff = True
u.save()
print('Done')
"| Feature | Implementation |
|---|---|
| Distance calculation | Haversine formula (great-circle distance in km) |
| Pharmacy sorting | Cheapest price first, nearest distance as tiebreaker |
| Reverse geocoding | OpenStreetMap Nominatim — no API key required |
| Map links | Google Maps URL with pharmacy coordinates |
| Model | Purpose |
|---|---|
Drug |
MOH benchmark catalogue — name, category, unit, price, barcode |
UserActivity |
Persistent per-user drugs searched and reports submitted count |
Pharmacy |
Pharmacy profile — name, GPS coordinates, description, location text |
PharmacyImage |
Multiple photos per pharmacy with cover flag |
PharmacyDrug |
Junction table — pharmacy-specific price per drug |
OverchargeReport |
Report header — pharmacy, receipt image, status |
OverchargeReportItem |
One row per drug in a report — name, amount, unit, price charged |
Django==4.2.13
Pillow==10.3.0
qrcode[pil]
python-barcode[images]
This project was developed as an academic final year project at Multimedia University of Kenya. All rights reserved.
DENNIS MUTHAMA
Registration Number: CIT-227-075/2022
Faculty of Computing and Information Technology
Multimedia University of Kenya
- Ministry of Health Kenya — drug pricing benchmark data
- OpenStreetMap Nominatim — free reverse geocoding
- html5-qrcode — open source barcode scanning library
- Bootstrap — responsive UI components
- Multimedia University of Kenya — academic supervision and support
Smart Pharmacy — Because every Kenyan deserves to know if they are being overcharged.