Community clinic purchasing & ordering - dual-track drug-and-supply ordering calculator as a single-file tool - the drug track computes from expiry and usage, the consumables track from visit volume and per-visit consumption, the two print as separate orders for two separate suppliers, the expiry-red-line shows before any quantity does, and per-visit consumption coefficients ship empty: first use must calibrate them from the clinic's own data
You are a coding agent building an internal tool for a community
clinic. Build a single-file HTML tool (HTML, CSS, JS fully inlined,
no external dependencies, no network requests, opens by double-click)
that computes order quantities for the person handling purchasing.
The tool's core structure is "dual-track": drugs on one track,
single-use consumables on the other - different algorithms, separate
outputs - because a clinic's drugs and consumables usually come from
different suppliers and need two separate orders.
Track 1 - drugs (by expiry and usage):
Item fields: name / strength-pack / unit / shelf-life days /
average daily usage over the last 【4】 weeks (hand-entered) /
current stock / on-order / delivery cycle (days) / safety days /
minimum order quantity
- Coverage days = delivery cycle + safety days
- Theoretical order = daily usage × coverage days - stock -
on-order; negatives clamp to 0 with a note "no order needed
this cycle"
- Red line (shown before anything else): items whose shelf-life
days < coverage days × 【1.2】 get the whole row flagged red
with "at this cycle the stock will expire before it's used -
shorten the delivery cycle or order smaller, more often"; the
suggested quantity only appears after the warning
Track 2 - single-use consumables (by visit volume, not by past
order size):
Item fields: name / spec / unit / shelf-life days (usually long
for consumables, but still required; blank = no red line) /
average daily patient visits over the last 【4】 weeks
(hand-entered) / per-visit consumption coefficient (how much is
consumed per visit - see the calibration flow) / current stock /
on-order / delivery cycle / safety days / pack size (units per
pack)
- Theoretical order = daily visits × per-visit coefficient ×
coverage days - stock - on-order
- Round up to whole packs and show "how much the rounding added"
- 【Key design】The per-visit coefficient has no default, and the
tool may not pre-fill any number. First use enters "calibration
mode": the user enters "total consumption of this item over the
last 【4】 weeks" and "total visits over the last 【4】 weeks,"
the tool computes the coefficient, and the user confirms it into
the item record. For uncalibrated items, the consumables order
row reads "uncalibrated - no output" and shows no estimate
whatsoever
Output area:
- Drug order (one sheet): item / suggested quantity / quantity
after minimum-order correction / covered-until date / red-line
flag - red-lined items on top
- Consumables order (a separate sheet): item / suggested quantity
/ after pack rounding / rounding surplus / covered-until date -
uncalibrated rows grouped at the bottom, marked
- Both sheets print full-page with date and buyer signature lines
- A "method notes" section: every formula and red-line rule laid
out, user-visible
Hard requirements:
- No external CDN, fonts, or icons; no network requests; data
never leaves the machine
- The item records (calibrated coefficients included) export to a
file and re-import, so re-entry is never needed
- Any input change recalculates live - no "calculate" button
- No usage forecasting, no "smart replenishment suggestions" -
the tool does arithmetic, red lines, and calibration; method
transparency is requirement number one
Prohibitions:
- Do not pre-fill any per-visit usage, daily usage, or safety-day
defaults - this clinic's consumption can only come from this
clinic's data
- Do not embed a "common community-clinic drug/consumable list" -
the catalog follows the clinical case mix; the tool does not
decide for the clinic
- The expiry red line and coverage formulas may not be buried in
an "advanced settings" menu - they are things every order run
must see
Why it is written this way
Dual-track is the tool's first design decision. Clinic purchasing inherently faces two supplier groups: drugs flow through pharmaceutical distribution, infusion sets and syringes through medical-device channels - mix the two into one calculation and either consumables get squeezed into the drug track's expiry straitjacket, or drugs get run through a per-visit-coefficient algorithm that is simply false for drugs. The more practical problem is output: a blended sheet cannot be sent to either supplier without hand-splitting. So the tool stays split from input through algorithm to output - two sheets, each with signature lines, print and go.
The consumables track's per-visit calibration is the tool's most anti-"smart" design. When an AI writes an ordering tool, its strongest impulse is pre-filling "industry-standard coefficients" - 1.2 syringes per visit and the like - but that number holds only for the "average clinic," and the average clinic does not exist: infusion share, administration habits, and pack-splitting waste differ everywhere. A pre-filled tool looks fine for two months while error quietly accumulates into chronic over-ordering or stockouts, and the user never suspects the coefficient. So calibration is a hard gate: no output without calibration. Better that the tool feels clumsy on day one than that it ships numbers built on invented bases - the same principle behind "no built-in catalog": the tool does not decide for the clinic.
The drug track's red-line logic (expiry shorter than coverage shows red before quantities) and the visible rounding surplus continue the standing lesson of short-shelf-life ordering: the more accurate the arithmetic, the harder the expiry - precision only makes the error more precise. Clinic drug volumes are small and lot sizes large, so expiry bites harder than in a pharmacy (one clinic may use only a few dozen boxes of a cold remedy a month), and the 【1.2】 red-line coefficient is an adjustable number on the page rather than buried in config, because it is precisely the parameter most often "shown to people" when purchasing negotiates delivery frequency with suppliers.
Variables
| Variable | Description |
|---|---|
| Red-line coefficient | 1.2 is the default margin; slow-turning categories can go to 1.0 for sensitivity - better a line that lights often and forces smaller frequent deliveries than silent expiry |
| Calibration window | "Last 4 weeks" is an example; clinics with strong seasonal swings get distortion on both sides if the window straddles a transition - prefer a complete recent month |
| Safety days | Unreliable suppliers get larger values, but every added day weighs on the expiry red line - the two form a tension the method notes must spell out |