The only time this actually happened to me was when I was in the hospital at age 6 having my tonsils out and my memory of it is not too clear. However, it is a BIG part of my med fet story and a staple of my play doc activity, like others have mentioned.
When I got physicals as a kid, the doctor we went to had a small office and although the bathroom was in between the four exam rooms, urine specimens were collected in metal pans in each exam room--they did not use plastic disposable cups then. When I was really little, my mother, who was acutely embarrassed by the idea of having to pee in the doctor's office, made me collect a specimen at home in a Coricidin bottle instead...so when the attractive young nurse told me she needed me to "go potty in the little pan for her" mom would promptly produce the little medicine bottle with my bright yellow urine in it from her purse. I, of course, being already excited by the strangeness of peeing somewhere other than our home toilet, and at the behest of an attractive young woman, was disappointed that I didn't get to go in the pan.
When I was 12, I was finally allowed to see the doctor without mom in the exam room with me. This time, after checking my height and weight, vitals, etc., the nurse said "I need a urine specimen (grown-up words, even) in the pan, just open the door when you're finished", after which she left the room. I distinctly remember having an erect penis and it was a little bit hard to go in the pan with it, but I managed. That year was also the first year the doctor pulled my underpants all the way down to do the hernia check, another big moment for me. Previously, during the abdominal exam he would undo my belt, unfasten and unzip my pants, then have me stand in front of him at which point my pants would slip down, and he'd do the hernia check by pulling the waistband of my underpants out and sticking his finger into my scrotum. This time, he undid my pants, but when he had me stand up and my pants dropped, he pulled my underpants down to my knees. I already had my shirt off so I was effectively naked in front of him. Again my penis was fully erect but he ignored that and did the hernia check on each side before telling me to get dressed. My inclination towards med fet was sealed with this experience.