Hi, John. This very question came up in a Catholic medical ethics class I took a few years ago. The principle of double effect comes into play here. It states that one can participate in an act that causes an intrinsic evil if their actual intention is to bring about a greater good. (An example would be the passengers of the plane that crashed in the field on 9/11. They caused the crash, but their real intent was to prevent greater loss of life.)

In the case of giving a dying person painkilling drugs, it is justifiable from a Catholic moral perspective if the intent is not to kill but to ease their suffering. This is true even if the amount necessary turns out to be a lethal dose.

Of course, "intent" is tricky and people can talk themselves into anything, especially under stress. That's why it's good for such decisions to be made thoughtfully in dialogue with family members, doctors and pastoral care personnel. Nobody should be alone when they have to make life and death decisions.