· margin

How Attergo Computes Margin, and Why Unknown Cost Shows Nothing

The exact formula, why every value is an integer number of cents, and why a fill with no acquisition cost on file shows no margin rather than a confident zero.

If you are going to act on a number, you are entitled to know how it was made. This is the whole of the margin calculation, including the parts that are inconvenient to explain.

The formula

For a single fill:

revenue = payer paid + patient pay - known post-adjudication fees
margin  = revenue - acquisition cost for the dispensed quantity

Three things in that are worth stating explicitly.

Patient pay is revenue. The copay is money the pharmacy receives. Excluding it would understate margin on every fill with cost sharing, which is most of them.

Fees are subtracted, not netted somewhere else. Any post-adjudication amount the platform knows about is money the pharmacy does not keep, so it comes out of revenue before the comparison to cost. Fees that surface later, on the remittance, are reconciliation work: that is Attergo Billing’s territory, reading the same event stream, which is why the two products share one data model instead of two competing versions of your revenue.

Cost is for the quantity dispensed, not for the package you bought.

Everything is an integer number of cents

No floating point value enters or leaves the calculation. Money is held as an integer count of minor units from ingestion to display.

This is not fastidiousness. Margin is a subtraction of two nearly equal numbers, which is precisely where binary floating point is proportionally worst. The familiar demonstration is that 8.115 multiplied by 100 and rounded comes out as 811 in most languages rather than 812, because the stored value was never exactly 8.115. An error of one cent is meaningless on a single line and is not meaningless across a month of fills, particularly when the whole claim is that we can tell you a fill lost $2.14.

The rule is enforced by a build check rather than by good intentions. A money column typed as a float, or a money value parsed through a float, fails the build.

Scaling a package price to a fill

Wholesaler invoices price a package. A fill dispenses a quantity.

cost for this fill = round(package cost x dispensed quantity / package quantity)

The rounding happens once, at the end. Scaling with a decimal and rounding on every line accumulates error in one direction across a month. A package quantity of zero or less returns no cost rather than an error or an infinity, because a bad reference file should degrade to “we do not know” and not to a number.

The cost basis ladder

A margin is only as trustworthy as the cost it was computed against, and cost quality varies enormously. So every result carries the basis it used and a confidence level, and both appear on screen next to the number.

BasisWhat it isConfidence shown
InvoiceYour own wholesaler invoice for that exact NDCHigh
OverrideA human entered it deliberately, and it is attributableHigh
Invoice, similarYour invoice for a different package size of the same drug, scaledMedium
NADACThe CMS national benchmarkLow
UnknownWe have nothingNone, and no margin is computed

A NADAC-based margin is labelled as indicative, in those words, on the fill. That matters because NADAC is easy to mistake for your cost. It is a survey of retail community pharmacy invoice prices that excludes mail order and specialty pharmacies, it does not include rebates or off-invoice discounts received after the invoice is paid, and since the December 2024 updates CMS has calculated monthly generic rates using a three-month moving average to damp volatility caused by fluctuating survey participation. It is a reasonable benchmark and a poor substitute for your invoice, and a system that quietly uses one as the other is producing confident fiction.

A margin scaled from a different package size is also labelled, with the reason, because it is arithmetic on a fact rather than the fact itself.

Why an unknown cost produces no margin rather than zero

This is the decision we get asked about most, so here is the reasoning in full.

If we have no acquisition cost for an NDC, the arithmetically convenient move is to treat the cost as zero. Margin then equals revenue, the fill reports as pure profit, the dashboard is complete, and every number has a value in it.

It is also the most dangerous available answer. A missing cost is not evidence of a free drug. Treating it as zero means the fills we know least about are exactly the fills that look best, and the error runs in the direction of hiding losses rather than raising false alarms. A pharmacy reading that report would conclude its worst-documented products were its most profitable ones.

So the calculation returns no margin. Specifically:

  • Revenue is still reported, because we do know what came in.
  • Cost, margin and margin percentage are all null. Not zero, not estimated.
  • The fill is not marked underwater, because we genuinely do not know whether it is.
  • The fill is flagged for attention with a reason of “no cost”, so it appears in a work queue rather than disappearing from the report.
  • The note shown on screen says that no acquisition cost is on file for this NDC and that importing a wholesaler invoice will produce a margin.

The consequence you should expect in week one of a pilot is a meaningful number of fills showing no margin. That is the system reporting the truth about your cost data rather than the system failing, and the fix is invoice coverage, not a better guess.

Percentage is of revenue, not of cost

Margin percentage is margin divided by revenue, to one decimal place. “We made twelve percent on that fill” is universally understood as margin over what came in, and expressing it over cost would produce a different number that nobody means.

When revenue is zero, the percentage is null rather than an error or an infinity. That case is real: a reversal, or a claim that paid nothing. Where revenue is zero and cost is known, the note says the fill was reimbursed nothing and the full acquisition cost is a loss, which is the accurate description.

Two thresholds, either of which can flag

A fill is flagged when it loses money, and also when it makes too little to be worth doing. Those are different tests and both apply.

The absolute test catches a real loss. The percentage test catches the thin one. The default percentage floor is five percent, and the reason both exist is that neither works alone: five percent on a $900 specialty fill is $45 and perfectly acceptable, while five percent on a $4 generic is twenty cents and not worth the label. Percentage catches what absolute misses, and the reverse. Thresholds are per tenant, so a pharmacy with a different view can set its own.

The boundaries of the number

  • Point-in-time, by design. The fill-level margin states what was known at adjudication. Comparing the promise against what a remittance actually paid is reconciliation, and it belongs to Attergo Billing on the same event stream, not inside this number where it would blur what the counter decision was based on.
  • Fill economics, not contract economics. Whether you are meeting a generic effective rate guarantee across a book of business is a different calculation on a different time horizon, and Attergo Intelligence reports it at that horizon.
  • Computed from what the events carry. A fee no system transmitted is not in the number, which is precisely why the basis and note travel with every figure.

The wider platform is eight products on one event spine: Margin, Billing, Audit, Authorizations, Inventory, Compliance, Intelligence, and Integrations, which is the spine. Each number stays inside its honest boundary, and the products compose because the boundaries are exact.

How to check our arithmetic

Do not take any of the above on trust. In a pilot, this is the exercise that settles it.

  1. Pick ten fills across a range: a cheap generic, a brand, one with a large copay, a reversal, and something with no invoice on file.
  2. For each, write down what you believe the pharmacy received and what you believe the drug cost, from your own records.
  3. Compare against the fill detail, which shows revenue, cost, the basis, the confidence and any note.
  4. Where the numbers differ, the cause is almost always one of three things: a fee we did not know about, a cost basis that is NADAC rather than your invoice, or a package-size mismatch on the invoice match.

All three are visible on the screen, which is the point of showing the basis. A disagreement you can trace in four minutes is a product working correctly. A number you cannot take apart is not worth having, whoever produced it.

See this analysis run on your own claims.

Attergo prices every fill, verifies every encounter and holds the evidence, in real time, on your data.