When 7-year-old Kaelyn “KK” Krawczyk underwent kidney surgery on Wednesday, her best friend was right beside her.

JJ, her 2-year-old rescue dog, accompanied young KK into the operating room to warn doctors of a life-threatening reaction she could possibly have while under anesthesia. Krawczyk suffers from mast cell activation disorder, where she is particularly susceptible to incidents of low blood pressure and trouble breathing, WTVD reports.

The terrier mix was the first canine allowed in the operating room at North Carolina’s Duke University Medical Center.

“It was kind of logical, actually,” Dr. Brad Taicher, the anesthesiologist whose idea it was to get hospital approval for JJ to be allowed in the operating room, told the News Observer. “Knowing what JJ could do, we realized that JJ was not much different from other monitors we use.”

JJ became KK’s service dog 18 months ago. He was trained at Eyes, Ears, Nose and Paws, a nonprofit in Chapel Hill, N.C. Much like a diabetic-alert dog, JJ can sense when his 7-year-old companion is about to have a life-threatening allergic reaction. If he notices something wrong, he will jump on KK’s leg, tug at her clothes and bark, WRCB TV reports.

“JJ has made it possible for us to give KK a more normal life,” KK’s mother, Michelle, said.

It’s believed that JJ and other service dogs are particularly adept at monitoring changes in human behavior, Dr. Lawrence Myers, associate professor of animal behavior at Auburn University, said.

"Dogs really, really, really are very interested in humans and pay a lot of attention to us," Myers said. "Especially the behavior of humans that they're bonded to."

The 45-minute operation “went perfectly,” Taicher said. The procedure was not performed in a sterile operating room but in a less strict procedure room. JJ was given a good bath before the operation and his trainer, Deb Cunningham, was also allowed into the room.

JJ did react when KK went to sleep and woke up, which was expected since they were times of higher stress. JJ made movements to show something was going on, but not anything serious.

“It’s like flying on an airplane,” Taicher said. “Takeoff and landing are when you’re most likely to experience a bumpy ride.”

And while the notion of a dog in an operating room might seem unsanitary, doctors were convinced the benefits of having JJ in the operating room far outweighed the risk of infection, Taicher said.

As for KK, she calls the dog “beautiful and smart.” “She's the top of my love list," KK said.