Our facility tests randomly but will also test more specifically those who are suspected of substance abuse. In twenty one years, I have been tested three times total! Once on hire, twice on random call.
I think most facilities do not count pain medication as long as you have a valid prescription for it.
In my career, I’ve known three RNs who have been dismissed because of drug use.