At the outbreak of war Bulgakov volunteered to work for the Red Cross as a doctor. He was was sent directly to the front, where he was badly injured at least twice. To cope with his pain, he injected himself with morphine, which he used until 1918. His book Morphine, published in 1926, talks about his experience of addiction. He finished his medical studies in 1916, and started work as a civilian doctor.
At the moment all my information comes from the Wikipedia article.