At a micro level, the doctors have the same access as pharmacies to know prior drug usage and are the ones directing the pharmacy.
At a macro level, are the pharmacies supposed to work together to combine data sources to find the trends? That sounds like a HIPAA nightmare.
A better approach is to have a government agency watch for trends in drug usage. This is exactly what the DEA is supposed to be doing, so why aren’t they at fault.