  Medication errors continue to be the leading cause of avoidable patient harm
in hospitals. This paper sets out a framework to assure medication safety that
combines machine learning and safety engineering methods. It uses safety
analysis to proactively identify potential causes of medication error, based on
expert opinion. As healthcare is now data rich, it is possible to augment
safety analysis with machine learning to discover actual causes of medication
error from the data, and to identify where they deviate from what was predicted
in the safety analysis. Combining these two views has the potential to enable
the risk of medication errors to be managed proactively and dynamically. We
apply the framework to a case study involving thoracic surgery, e.g.
oesophagectomy, where errors in giving beta-blockers can be critical to control
atrial fibrillation. This case study combines a HAZOP-based safety analysis
method known as SHARD with Bayesian network structure learning and process
mining to produce the analysis results, showing the potential of the framework
for ensuring patient safety, and for transforming the way that safety is
managed in complex healthcare environments.
