A desktop application for managing medicine inventory, patient billing, doctor records, and generating printed pharmacy bills. Built with Python and Tkinter, backed by Microsoft SQL Server.
- Medicine Billing — Select medicines, set quantities, and print a formatted bill directly to a thermal/receipt printer
- Patient Billing — Generate bills for patients including consultation and service charges
- Stock Management — Add new medicines or restock existing ones; optionally update prices at the same time
- Inventory Check — View current stock levels and flag medicines that have fallen below a configurable low-stock threshold
- Doctor Management — Update consultation fees for registered doctors
- Direct Printer Support — Bills are sent to a physical printer via the Windows GDI (
pywin32), formatted for receipt-style output - Stock Validation — Prevents billing more units than available; re-validates stock at print time
- Stored Procedures — All DB writes go through SQL Server stored procedures (
increasestockquantity,decreasestockquantity,increasemedicineprice,updatedoctorfee)
- Python (Tkinter for GUI)
- Microsoft SQL Server (via
pyodbc) - pywin32 (printer access on Windows)
- Pillow (image support)
Medicine Billing/
├── main.py # Entry point, main window
├── db.py # DB connection using config.json
├── config.json # Server, database, printer config
├── requirements.txt # Python dependencies
├── ddl.sql # Table definitions
├── procedures.sql # Stored procedures and views
├── printbill.py # Bill printing via Windows GDI
├── models/
│ ├── medicine.py # Medicine queries and stored proc calls
│ └── doctor.py # Doctor queries and stored proc calls
└── views/
├── medicinebilling.py # Medicine billing window
├── patientbilling.py # Patient billing window
├── addstock.py # Add/update stock window
├── checkinventory.py # Inventory check with low-stock alerts
└── manage_doctors.py # Doctor fee management window
- Windows OS
- Python 3.x
- Microsoft SQL Server (Express or full)
- ODBC Driver 17 for SQL Server (download here)
git clone https://github.com/your-username/medicine-billing.git
cd medicine-billingpython -m venv .venv
.\.venv\Scripts\activatepip install -r requirements.txtAfter installing, run the pywin32 post-install script:
python Scripts/pywin32_postinstall.py -install
Open SQL Server Management Studio (SSMS) and run the following scripts in order:
-- 1. Create the tables
-- Run: ddl.sql
-- 2. Create stored procedures and views
-- Run: procedures.sqlEdit config.json to match your environment:
{
"server": "YOUR_SERVER_NAME\\SQLEXPRESS",
"database": "MedicineBilling",
"driver": "ODBC Driver 17 for SQL Server",
"trusted_connection": true,
"username": "",
"password": "",
"printer_name": "Your Printer Name",
"clinic_name": "Your Clinic Name",
"low_medicine_threshold": 10
}- Set
trusted_connectiontotrueto use Windows Authentication, orfalseand fill inusername/passwordfor SQL Server auth. printer_namemust exactly match the printer name in Windows Settings → Printers & Scanners.low_medicine_thresholdsets the stock level below which a medicine is flagged as low in the inventory view.
python main.pyMedicines
| Column | Type |
|---|---|
| medicineid | INT IDENTITY |
| MedicineName | VARCHAR(150) UNIQUE |
| Price | DECIMAL(10,2) |
| StockQuantity | INT |
Doctor
| Column | Type |
|---|---|
| doctorid | INT IDENTITY |
| Name | VARCHAR(50) |
| fee | INT |
- This application is Windows-only due to the use of
pywin32for printer access. - The printer must be installed and set as accessible in Windows before billing.
config.jsoncontains sensitive server info — add it to.gitignoreif forking for production use.