How can I avoid use of drugs and patterns if I have been a hard drug user being a teenager?

Drug use in past. You have to be frank with any doctor you see that you used hard drugs in the past and are not using it any more and let the physician decide what the best treatment will be for your condition.Be open and frank and there is nothing to hide.All information is always confidential.
Keep your distance. From them. As you seem to be aware, your problems as a teenager mean you are more susceptible, so i would advise either complete abstinence from any mood-altering substances that you do not absolutely need, or keeping them to the absolute minimum. You need also to develop a good emotional support system, have things you do in life that you enjoy, and have good coping skills for stress etc.