Doug Moore was out of town at a Florida conference on information technology in October 2015 when he was struck with terrible abdominal pain. He tried to go to an urgent care center and called several local doctors. No one could see him. So he headed to the nearest emergency room. On the way, he called his insurance company to make sure the visit would be covered.

Once he got to the Palms of Pasadena Hospital emergency room, a doctor gave him some medication and tests, and let him go. A month later, feeling better and back at home in Baton Rouge, La., Mr. Moore, 34, received an out-of-network bill from the doctor who treated him — for $1,620.

“That really makes me mad, and kind of breaks my heart,” he said.

When people go to the emergency room, they are often stunned to discover that doctors who treated them are not employed by the hospital and bill their insurance company separately. These doctors negotiate separate deals with insurance companies for payment. If the doctor and the insurance company never strike a deal, the visit is billed at much higher out-of-network rates. While the insurance company sometimes pays the higher amount, unlucky patients like Mr. Moore can be caught in the crossfire. They receive care and have no idea what it will end up costing them.

New research published in The New England Journal of Medicine on Wednesday found that more than one in five patients visiting the emergency room may face the same financial shock. The study looked at billing data from one large national insurer and found that 22 percent of the time, patients who went to a hospital covered by their plan still received a bill from a doctor who was not in the insurance company’s network. The average such bill cost more than $900, though there was a wide range; the highest was for more than $19,000. This is not the first time researchers have examined surprise medical bills, but it’s the broadest analysis to date of the problem nationwide.