It isn’t easy to ruffle my friend of 30 years, one of the best gastroenterologists in Boston, a town known for top-notch medicine. But he was ruffled when he told the story of giving a patient anesthesia and performing a medically unnecessary procedure—only he hadn’t known it was unnecessary because the patient’s electronic health record, or EHR, didn’t function as promised.

If you’ve heard of EHRs, you know that many doctors consider them a pain in the neck. Not much is said, however, about the harm EHRs can cause to patients....