do you ever go into starbucks for a coffee and wonder about people sitting there all day long setting up shop? Turns out one man was a doctor serving up something else and it wasn't coffee until a big... See More
do you ever go into starbucks for a coffee and wonder about people sitting there all day long setting up shop? Turns out one man was a doctor serving up something else and it wasn't coffee until a big sting, and the tape he can't erase. Debra roberts with the video and the embattled doctor talking only to 20/20. Reporter: With the green mermaid beckoning, it's where the world goes for its daily fix --of caffeine that is. But it's also the place where an ambitious doctor in orange county, california was caught on tape, offering a different kind of fix: Writing prescriptions for painkillers. You would meet and treat patients at starbucks? Yes, I would. I would. I mean, it's pretty much the american dream being your own boss, you know? Reporter: But his dreams were doomed by what he thought was a clever way to finance a solo practice. A medical director by day, and at night he began treating patients for pain management at the modern day office for the office-less. How do you even set up a practice in a coffee house? I-- I realize that sounds a little strange. I mean, the patients would provide me medical records. I would listen to their heart, i would listen to their lungs. You would pull out your stethoscope and examine them -- I would take blood pressure -- in the starbucks? Yes, I was doing that. Did you make an arrangement with starbucks? Did you pay any rent? I did not. I did not. Reporter: Dr. Yee wasn't just poaching on private property. He was doling out prescriptions for the most powerful and addictive painkillers like oxycontin in exchange for fistfuls of cash. How would they pay you? Was it under the table kind of? Generally speaking, yes. It would be maybe inside of a coffee cup. But don't you see how that looks a little shady? You know you're examining--they're handing you money under the table. I understand, I understand. Reporter: His practice at starbucks soon commanded $600 for an initial visit, but patients kept coming. A third of them in their 20s. One of those eager patients was derek rosas who was coping with an old lacrosse injury. I found out that he was going to see dr. Yee a lot at starbucks. Reporter: Derek's mom, tammy wondered why her 20-year-old son needed such potent painkillers. I would find empty bottles of prescriptions in his car. What were the drugs? Oxycontin was the one that he used a lot of. That he got from dr. Yee. Although there were many legitimate pain patients, there were a smaller percentage of what would be call professional patients and we even would call them professional junkies. Reporter: Dr. Yee says he had his own system in place to weed out problem patients, even hiring a drug counselor. But some patients slipped through the cracks. They don't teach you this in medical school. They don't teach you anything about what happens on the streets. But they teach you ethics, and is it ethical to meet a patient in a coffee house? Well, I believe it was. Reporter: Dr. Yee may have thought so but the dea did not. This is the first time that i heard of a doctor usin' a food establishment to conduct his business. With hidden cameras rolling, they launched an elaborate sting operation into dr. Yee's practice. It was very important that the agents obtain as much evidence as possible to show, again, that this wasn't a one-time event. We wanted to show a pattern. In this undercover video, being seen for the first time on national television, dr. Yee meets with an agent posing as a patient with no idea he's being watched. Smoke cigarettes? No, not cigarettes. Okay. Any recreational drugs I should be aware of? That you should be aware of? Not really?. Okay. I'll take that on a need-to-know basis. Cavalier! Flippant! Dr. Yee is more friend than physician. I was kinda laughing and joking at the same time, but to me that's a bit of trying to maintain patient rapport. Reporter: The agent left with prescriptions for 60 oxycontin, 60 xanax and 120 roxicodone. And dr. Yee pocketed $400. On another night, a different agent makes an appointment at starbucks. I used to have a heroin addiction for five years. On and off and then I smoked, so -- Reporter: A patient admitting to being a heroin addict. Shocking, but not enough to stop dr. Yee from writing scripts for 60 roxicodone and 60 xanax for the hefty price of $600. Why would you write her a prescription knowing that she has a history of heroin addiction? There are some people that --if they're not able to get access to their pain meds -- that result to other ways of treating it. And sometimes it's heroin, so that's one way I rationalized it. Reporter: By september of 2011, with business booming, dr. Yee had moved away from the foaming lattes to his own office space. That's where a dea informant uncovered the most jaw-dropping abuse of that overused prescription pad: Requesting drugs, not just for herself, but for a friend who wasn't even there. She is in school. She can't make it. She is getting sick so she asked me if I could get the script for her. You want to do hers first? Yeah. Can we do hers first? Reporter: Astoundingly she walks out with everything she wanted, but not before dr. Yee tried to cover his tracks. Just between you and me? We met, you know. Totally. All good. I got you. Dr. Yee wasn't concerned about the fact that the patient was not sitting before him. His only concern was the money. Reporter: And the money was rolling in, sometimes as much as $5000 a night. But the prescription business would soon have devastating consequences for, derek rosas. During his four years as a patient of dr. Yee, he had become addicted. The last thing he texted me was "i love you mom" and he went to bed that night and didn't wake up. What was the cause of death? Accidental. Mixing this pill and this pill and this pill with beer. Do you think dr. Yee knew that he was dealing with an addict? Yes. Of course. Reporter: Dr. Yee was never charged in derek rosas' death and denies he ever knew he was an addict. I'm very, very, very, very regretful that anybody had to die. Did you ever deny a patient a prescription if they came to you wanting a narcotic? Do you remember ever saying, "no, not this time?" I don't remember. I believe it might have happened, but I can't recall specifically. Reporter: After eight months of watching dr. Yee, the dea had seen enough. He was arrested and charged with 56 counts of prescribing controlled substances without a legitimate medical purpose. A doctor caught on video meeting with patients at a coffeehouse. Reporter: Just weeks ago, facing trial and a possibly life behind bars, dr. Yee pleaded guilty to seven counts. A judge sentenced him to 11 years in a federal prison. What's the difference between his actions and the actions of a drug dealer on the street corner? There is no difference. He's a drug dealer that just so happened to operate at a starbucks. Dr. Yee begins serving his sentence this january. Would you ever see a doctor at starbucks, tweet us. Next you'll hear about the young woman the videos of her wildly
This transcript has been automatically generated and may not be 100% accurate.