Euthanasia and pain relief
It's not euthanasia to give a drug in order to reduce pain, even though the drug causes the patient to die sooner. This is because the doctor's intention was to relieve the pain, not to kill the patient. This argument is sometimes known as the Doctrine of Double Effect