This is true.
Most people are surprised to hear that the lab can tell the difference between hydrocodone and oxycodone, but they can.
The metabolism of each opioid leaves traces of metabolites and other chemical byproducts. By assaying the levels of these substances in the blood or urine, the lab can determine, with some degree of certainty, which particular medication you're using -- codeine, oxycodone, morphine, hydromorphone, etc.