---
title: "Pharmacy Billing"
description: "How pharmacy billing works in NICE HMS — enabling the pharmacy ledger, managing pharmacy items with batch tracking, the four pharmacy voucher types, the pharmacist role, and stock tracking."
date: 2026-07-19
lastModified: 2026-10-21
category: "pharmacy"
author: "Dr. Umesh Bilagi"
beta: false
---

## Overview

Pharmacy in NICE HMS is an **accounting channel** within the Accounts module, not a standalone module with its own pages. There is no dedicated "Pharmacy" sidebar menu — pharmacy users access everything through **Accounts**.

Pharmacy transactions use the same forms as other billing workflows (invoice, purchase, debit note, credit note) but with pharmacy-specific voucher types, print headers, and the `accountHeaderPharmacyUrl` letterhead. The **pharmacist** role is restricted to pharmacy voucher types only.

## Enabling Pharmacy Billing

Before using pharmacy billing, enable it in organization settings:

1. **Admin → Organization → Settings**
2. Toggle **Pharmacy Billing** to ON.
3. This creates a PHARMACY ledger account for the organization.

The pharmacy toggle is at the organization level. Once enabled, the **Pharmacy** card appears on the Accounts landing page (`/admin/accounts`) with two links: **Purchase** and **Debit Note**.

## Separate Pharmacy Accounting

Pharmacy transactions run on their own voucher types (`_P`) and post to the dedicated **PHARMACY** ledger account, so they are naturally kept apart from the hospital's other books. Sales (INVOICE_P), purchases (PURCHASE_P), and returns (CREDIT_NOTE_P / DEBIT_NOTE_P) roll up into one self-contained ledger rather than mixing with OPD, IPD, or Lab revenue.

This separation matters in two common arrangements:

- **Independent booking** — the pharmacy is billed and reconciled on its own, without its figures merging into the hospital's general accounts.
- **Outsourced pharmacy with revenue sharing** — when an external operator runs the pharmacy, the separate `_P` ledger keeps its sales and purchases in clear view, so the hospital can keep a watchful eye on pharmacy activity and on the revenue that sharing is based on.

The separation is ledger-level — there is still no separate "pharmacy module"; everything lives inside Accounts.

## Pharmacy Items

Pharmacy items (medicines, consumables) are created through **Item Management** (Accounts → Masters → Items), not through a separate pharmacy inventory page. See [Item Management](/docs/item-management) for the full item creation form.

Key configuration for pharmacy items:

| Setting | Value |
|---------|-------|
| **Category** | Pharmacy |
| **Sub Category** | Pharmacy |
| **Purchasable** | TRUE (can be bought from vendors) |
| **Saleable** | TRUE (can be sold to patients) |

### Batch Tracking

Medicines can be tracked by batch through the `batchMaster` table. Each batch record stores:

| Field | Description |
|-------|-------------|
| **Batch** | Batch number |
| **Expiry Date** | Expiration date |
| **Manufacturing Date** | Date of manufacture |
| **Item** | Linked item ID |

Batch tracking applies to all inventory items, not just pharmacy. During purchase entry, batch details are recorded so that stock is tracked per batch.

A purchase line may be saved **without** a batch (for example a non-inventory item); it is stored with no batch. If you do attach a batch, it must have a name — the Set Batch button stays disabled until you type or select one, so an unnamed batch is never saved.

## Pharmacy Voucher Types

Four voucher types handle pharmacy transactions. They use the same UI components as their non-pharmacy counterparts but are routed through pharmacy-specific APIs and print with pharmacy headers:

| Voucher Type | Purpose | Counterpart |
|-------------|---------|-------------|
| **INVOICE_P** | Sale of medicines to a patient | INVOICE |
| **CREDIT_NOTE_P** | Return/refund for pharmacy sale | CREDIT_NOTE |
| **PURCHASE_P** | Purchase of stock from a vendor | PURCHASE |
| **DEBIT_NOTE_P** | Return of stock to a vendor | DEBIT_NOTE |

### Access

| Transaction | Access Path |
|-------------|-------------|
| **Patient sale (invoice)** | Accounts → Pharmacy → use the general **Invoice** link with `vouchertype=INVOICE_P` |
| **Vendor purchase** | Accounts → Pharmacy → **Purchase** (`/admin/accounts/bill/create?vouchertype=PURCHASE_P`) |
| **Purchase return** | Accounts → Pharmacy → **Debit Note** (`/admin/accounts/bill/create?vouchertype=DEBIT_NOTE_P`) |

### Form Fields

The purchase and invoice forms are the same as the generic bill and invoice forms (see [Bill Transaction](/docs/bill-transaction) and [Purchase](/docs/purchase)). The voucher type parameter determines:
- Which API endpoint handles the transaction
- Which accounts (Dr/Cr) are available
- Which letterhead appears on the printed document

### Pharmacist Role Restrictions

The **pharmacist** role can only create pharmacy-tagged vouchers. The create-purchase API rejects pharmacists for non-pharmacy purchase types:

```typescript
if (user.role == "pharmacist" && type != "PURCHASE_P" && type != "DEBIT_NOTE_P") {
  throw new Error("forbidden");
}
```

Similarly, the create-invoice API restricts pharmacists to `INVOICE_P` and `CREDIT_NOTE_P` types only.

## Stock Tracking

Stock levels for pharmacy items are tracked through the shared stock system alongside hospital-category items. The stock is calculated from purchase and invoice voucher quantities.

### Current Stock Report

**Sidebar → MIS Reports → Stock → Current** (`/admin/mis-reports/stock/current/0?category=Pharmacy`)

Filter by `category=Pharmacy` to view only pharmacy items. The report shows current stock levels per item with batch-wise breakdown.

### Expiry Tracking

The `batchMaster` table stores expiry dates per batch. An `expiryStock()` function queries batches approaching expiry, but there is no dedicated expiry alerts page — use the batch master data to identify items nearing expiration.

### Physical Stock Adjustment (Set Stock)

Use **Physical Stock** vouchers (`PHYSICAL_POSITIVE` / `PHYSICAL_NEGATIVE` types) to adjust stock levels for physical verification corrections, wastage, or damage. This is a shared inventory feature, not pharmacy-specific.

**How to set stock for an item:**

1. Open **MIS Reports → Stock → Current** (use `category=Pharmacy` for pharmacy items).
2. Click **Set Stock** on the item's row. The popup shows the item name and its **current stock**.
3. Click **Add Row** and fill a row: **New quantity**, and optionally a **Batch** with Manufacturing/Expiry dates.
4. Click **Set Stock**.

**Setting stock to 0 is allowed** — enter `0` as the new quantity to zero out an item.

**The batch is optional.** A physical count corrects the item's overall stock, so a row does not need a batch — pick one only if you want to attribute the count to a batch. A row is valid once its item details have loaded; until then it shows "Item details are still loading…" and the Set Stock button stays blocked. On success the popup closes and the report refreshes; on failure the popup stays open with the reason shown.

**Multiple batches:** Set Stock works on the item as a whole, not per batch. If an item has batch A (10) and batch B (5), the popup shows the combined **15**, and saving re-bases the item to whatever quantities you enter. To keep both batches, add a row for each (for example 8 and 4 → 12); if you enter only one row, the other batch's quantity is not carried over. Per-batch quantities are not tracked separately.

## Counter sales without an encounter

A patient coming back for a refill has no open encounter. If the organization allows it, the **Counter Sales** menu (`/admin/counter-sales`) bills them anyway:

1. Turn on **Allow pharmacy counter sales without an encounter** in organization settings, then log in again.
2. Open **Sidebar → Counter Sales** and search by UHID, mobile or name — or press **New patient** to register one and come straight back.
3. Press **Pharmacy sale**, pick the items and save. The voucher is a normal `INVOICE_P` credited to the Pharmacy ledger; stock is deducted, and the bill prints with **Counter sale** in place of an encounter.

Collect the money on the same screen: pick the **Payment mode** (Cash / Digital / Bank) and the **Payment account** before saving. The receipt is written with the invoice in one transaction, for the full bill — a counter sale cannot be left unpaid. A cash payment must use your own cash drawer, so an admin may need to create **Cash Access** for you first.

The **Consultant** field is optional: leave it blank to attribute the sale to the hospital (**Hospital / direct** in MIS), or enter a doctor. Counter sales never create an encounter and are not shared to ABDM. See [Counter Sales](/docs/counter-sales).

## Printing

Pharmacy vouchers automatically use the pharmacy-specific letterhead:

- Printed headings show: **INVOICE (Pharmacy)**, **CREDIT NOTE (Pharmacy)**, **PURCHASE (Pharmacy)**, or **DEBIT NOTE (Pharmacy)**
- The letterhead image uses `accountHeaderPharmacyUrl` from organization uploads (see [Printing and Letter Pad Header](/docs/printing-and-set-up-of-letter-pad-header))

The invoice component detects the `_P` suffix in the voucher type and switches to the pharmacy header automatically.

## FAQ

**Q: Where do I find the pharmacy menu?**
A: There is no separate pharmacy menu. Go to **Sidebar → Accounts**. If pharmacy billing is enabled in organization settings, a **Pharmacy** card appears with Purchase and Debit Note links. For patient sales, use the general Invoice link with a pharmacy item.

**Q: How do I add new medicines to the pharmacy?**
A: Use **Accounts → Masters → Items** (see [Item Management](/docs/item-management)). Set the category to "Pharmacy" and mark it as purchasable and saleable.

**Q: Can I track medicine expiry dates?**
A: Yes. Batch tracking records manufacturing and expiry dates for each batch of medicine. Use the batch master data to identify items approaching expiry.

**Q: What can a pharmacist user do?**
A: A user with the pharmacist role can create and edit pharmacy vouchers (INVOICE_P, CREDIT_NOTE_P, PURCHASE_P, DEBIT_NOTE_P), create receipts/payments, and view MIS reports. They cannot create non-pharmacy transactions.

**Q: Does pharmacy billing work differently from regular billing?**
A: The forms are identical. The difference is the voucher type suffix (`_P`), which routes through pharmacy-specific accounting and uses the pharmacy letterhead for printed documents.

**Q: How do I dispense medicines against a prescription?**
A: There is no dedicated dispensing interface. Create a pharmacy invoice (INVOICE_P) for the patient with the prescribed medicines as line items. Stock is reduced automatically when the invoice is saved.

**Q: How do I zero out an item's stock?**
A: Open **Set Stock** on the item (MIS Reports → Stock → Current), click **Add Row**, set **New quantity** to `0`, and save. A quantity of 0 is valid, and a batch is not required.

**Q: Why can't I submit the Set Stock form?**
A: Add at least one row, and wait for each row's item details to load (a row briefly shows "Item details are still loading…"). A batch is optional, so a missing batch will not block the form.

**Q: Is there integration with the ABDM Drug Registry?**
A: Not currently. A medication resolver integration is planned but not yet implemented.
