Timely detected medication error: Prescribing or dispensing?

Timely detected medication error: Prescribing or dispensing?