Cost of Goods Sold Report - hmislk/hmis GitHub Wiki
Cost of Goods Sold Report
Overview
The Cost of Goods Sold (COGS) report reconciles pharmacy stock movement for a date range and (optionally) a single department: Opening Stock + all movement rows = Closing Stock, with any mismatch shown as Variance. Each row is a category of stock movement β purchases, transfers, sales, inpatient issues, returns, and so on β each with Purchase Value, Cost Value, and Retail Value columns.
This page focuses on the two rows that cover inpatient (BHT) pharmacy movement β BHT Issue and Drug Return IP β because it is easy to assume "returns" belong wherever the original issue was counted. They don't: the report keeps all inpatient issues in one row and all inpatient returns in a separate row, regardless of which issue path the medicine originally came from.
Where to Find It
Reports β Reports β Inventory Reports tab β 4. Cost Of Good Sold, or navigate directly to reports/inventoryReports/cost_of_goods_sold.xhtml. Set a date range, optionally narrow to one Department (e.g. a single pharmacy), and click Process.
Scoping to a single department matters here: the two legs of an inpatient movement (issuing pharmacy vs. receiving/returning ward) live in different departments. A whole-hospital run nets both legs to ~0, which can hide a miscategorized row that a single-department run would expose immediately.
The Two Inpatient Pharmacy Paths
Medicines reach an inpatient (BHT) in one of two ways, and each can be returned:
| Path | Started from Inpatient Dashboard | Wiki page |
|---|---|---|
| Direct Issue | Direct Issue to BHTs (or Issue Discharge Medicines) β the pharmacist issues straight to the patient's bill, no separate request/receive step | Direct Issue to BHTs from Pharmacy |
| Request β Issue β Receive | Request from Pharmacy (ward creates a request) β pharmacy Issue Medicines against it β ward Receive Medicines from Pharmacy | Inpatient Pharmaceutical Management |
Returns mirror the same split:
| Return of⦠| How it's returned | Wiki page |
|---|---|---|
| A Direct Issue | To Return Item against the original bill β settles immediately, no separate acceptance step | Direct Issue Return to Pharmacy |
| A received Request-Issue | Ward Return Medicines to Pharmacy (porter-mediated) β pharmacy Receive to accept the return | Inward Ward Return to Pharmacy |
How the Report Categorizes Them
- BHT Issue β every inpatient issue, from both paths (direct issues and pharmacy-issues-against-a-request), net of ward medication administration consumption.
- Drug Return IP β every inpatient return, from both paths (direct-issue returns and the wardβpharmacy request-issue returns), net of any cancelled returns.
Both a direct issue's return and a request-issue's return land in Drug Return IP β never in BHT Issue β no matter which path the original medicine came out through. Historically the wardβpharmacy return leg (RETURN_MEDICINE_INWARD / ACCEPT_RETURN_MEDICINE_INWARD) was miscategorized into BHT Issue instead, inflating "issue" and understating "return" whenever the report was scoped to a single department (issue #22909); this was fixed in August 2026 and is what this page demonstrates below.
Worked Example
Verified end-to-end against a live test admission, scoped to a single pharmacy department for one day:
- Direct Issue to BHTs β 10 units issued directly to the patient.
- Direct Issue Return β 4 of those 10 units returned via To Return Item (settles immediately).
- Request from Pharmacy β pharmacy Issue Medicines against the request β ward Receive Medicines from Pharmacy β 5 units.
- Return Medicines to Pharmacy β 2 of those 5 units returned by the ward, then received/accepted by the pharmacy.
Cost of Goods Sold β summary, scoped to the issuing pharmacy
BHT Issue carries only the two issue transactions (10 + 5 units); Drug Return IP carries both return transactions (4 + 2 units) as a separate, positive-value row:

BHT Issue drill-down β only issues, no returns
Clicking into BHT Issue shows exactly the two issue bills β the Direct Issue and the Issue-on-Request β and nothing else:

Drug Return IP drill-down β both returns, from both paths
Clicking into Drug Return IP shows both returns side by side β the direct-issue return and the ward-return-to-pharmacy acceptance β each referencing its original issue bill as the Ref Doc No, with totals that reconcile exactly to the summary row:

Other Rows on This Report
The remaining rows follow the same "movement type in, movement type out" pattern for non-inpatient stock activity β GRN receipts, transfers, retail sales, stock adjustments, purchase returns, and outpatient drug returns (Drug Return Op). Each is independently drillable the same way: click the row link, then Process on the drill-down page.
Sale drill-down: PDF and Excel downloads
On the Sale drill-down (and Add to Stock Bills), after Process:
- PDF downloads a landscape report. Its header says when it was generated (date and time) and lists the filters used. Each bill shows its date and time, with one line per item and the payment breakdown underneath. A Total row at the end gives the Cost Value, Purchase Value, Net Total and MRP Value totals.
- Download saves the same rows to Excel: one row per bill item, the bill date and time on the bill's first row, and a Total row at the end.