← Back to the lab

Data

Medicine supply digital twin (13/14): which data prevent a plan from being manipulated

An alert rule only works if the data it needs exists. Detection probability with several rules, the cost of false alarms and why, by Bayes' theorem, more alerts doesn't always mean more control.

By ·

Before buying, the fictional system builds an annual needs plan: each unit proposes how much of each item it needs, a regional office reviews and a central office approves. It’s a process with many hands, and at each one someone could move the figures: a unit that inflates its order, a review that rubber-stamps everything without looking, a change after sign-off.

The twin doesn’t ask who’s honest. It asks something more useful for whoever designs the platform: what data must it keep so these behaviours get noticed?

Behaviours, rules and data

The twin seeds the simulated plan with actors showing known behaviours and tests alert rules against them. Each rule needs certain data; if the platform doesn’t keep it, the rule can’t run.

RuleWhat it detectsData it needsSensitivity ss
R1Orders over 1.5× what it usedactual consumption per unit0.95
R2Orders with over 6 months of stockstock and expiry0.90
R3Orders for a unit that isn’t operatingstatus of each unit0.95
R4Orders items outside its care levelcatalogue by care level0.95
R5Approved hundreds of requests in minutesreview time per request0.70
R6Changed the plan after sign-offsealed audit log0.95
R7Raised what the unit had requestedsealed audit log0.90

Sensitivity is how often the rule catches the behaviour when it exists and the data is there. It isn’t 1, because actors protect themselves too: they approve slowly, attach justifications, spread the increase around.

Several rules on the same behaviour

One behaviour can trigger more than one rule. Inflating the order, for example, can be caught by R1 (comparing against consumption) or R2 (if the unit also had stock to spare). If the rules fail independently, the behaviour goes unseen only if all of them fail:

P(detect)=1−∏i∈active rules(1−si)P(\text{detect}) = 1 - \prod_{i \in \text{active rules}} (1 - s_i)

The design question, then, isn’t which rule is cleverest, but which data is missing. In the aid, tick and untick the data sets and watch detection of each behaviour switch on or off. With only two of six data sets, average detection is 27 %; with all six, 91 %.

The cost of false alarms

Every rule also errs the other way: it flags honest requests. A unit that really did open a new service orders more than the year before, and R1 flags it. If each rule wrongly flags a share ff of honest requests, with nn active rules the share of honest requests flagged by at least one is

1−(1−f)n1 - (1 - f)^n

With f=1 %f = 1\ \% and 7 rules, 1−0.997=6.8 %1 - 0.99^7 = 6.8\ \% of honest requests fall under suspicion.

Bayes: of the flagged ones, how many are real?

What matters to whoever reviews an alert is the probability that the flagged request really was manipulated. If prevalence (the share of manipulated requests) is π\pi, Bayes’ theorem gives the positive predictive value:

PPV=P(manipulated∣flagged)=s πs π+ftot (1−π)\text{PPV} = P(\text{manipulated} \mid \text{flagged}) = \frac{s\,\pi}{s\,\pi + f_{\text{tot}}\,(1 - \pi)}

That’s why the twin measures both at once: what’s stopped in time and what’s wrongly accused. More data helps in both directions, because a rule with good data can be stricter: a unit that ordered more, but whose patient list grew and whose new service is registered, has no reason to be flagged.

The twin in Planning › Plan integrity (“Planeación › Integridad del plan”): switch the platform’s data on or off and see which behaviors get detected. (Interface in Spanish.) · Open full screen

What the twin delivers

This module’s output isn’t a list of culprits: the data is synthetic. It’s a list of data and fields the platform must create from the start (actual consumption, stock, unit status, review times, a log that can’t be edited) and the quantitative case for why each one is worth what it costs to keep.

What comes next

The last post brings everything together. A control tower that looks at the whole chain with a traffic light per link and answers the hard question: when the patient doesn’t get their medicine, whose failure is it?