A medical is ALWAYS required for someone who is a High Risk Offender.... that is someone who gives a breath test of 88 or more, fails to supply or who has 2 convictions in 10 years.
A medical MAY WELL be required for someone who is convicted of drug driving, that is not a legal requirement but something that DVLA CAN decide to do if they wish.
A medical WILL be required if someone has their licence revoked for medical reasons before they can get it back again.
For alcohol offences it is testing for a thing called CDT, which is present in the blood, and the higher the reading, the more it indicates the larger amount of alcohol someone has been drinking in recent weeks. (No one produces 0% because it is always present to some degree even in teetotallers because of fruit juice etc producing very small readings)
For drug cases they screen for a broad spectrum of drugs in the urine sample, each with a very low threshold of producing a positive reading. If the drug detected is a prescription one, and being taken in the recommended does then that can be fine. Obviously illegal drugs detected would be a big NoNo.