On a recent Thanksgiving, David Oshinsky made an unplanned visit to Bellevue hospital.

His nonagenarian father-in-law fell on his face and couldn’t stop bleeding. The hospital, which is the subject of Oshinsky’s new history, “Bellevue: Three Centuries of Medicine and Mayhem at America’s Most Storied Hospital” was quiet and calm on the holiday and Oshinsky says his father-in-law got good emergency room care.

But around 5 p.m., something unexpected happened. Suddenly, the room was swirling with police officers and people in orange jumpsuits. There had been a fight at Rikers, and some of the inmates had been trasferred off the island.

Oshinsky told the story on a recent tour of the hospital, shrugging his shoulders under the public entrance, where arrows on the floor depicted the well-traveled path to the emergency room. “It’s Bellevue,” he said.

A hospital that embodies New York City

For many, the name Bellevue is synonymous with the word “madhouse.”

The hospital has a well-deserved reputation for psychiatric breaks and even gritty violence. Bellevue was home to the psychiatric facilities exposed by muckraking journalist Nelly Bly in 1887, when she went undercover as a madwoman to see the facility’s supposed horrors from within. Over the years, it has welcomed countless non-faking psychotics, such as the man who shot John Lennon (36 years ago today).

In 1989, a homeless man in doctor’s scrubs raped and murdered a pathologist at the hospital.

In “Miracle on 34th Street,” Kris Kringle is sent to Bellevue under suspicion of mental illness.

But as Oshinsky’s book shows, that reputation obscures the mission of this stubbornly public institution which serves everyone regardless of indigency, immigration status or insurance. It is a place that sees it all and takes everyone, where patients, even those with serious mental issues, return again and again as a place of last resort.

Oshinsky also portrays Bellevue as a jewel of emergency care — the place where shooting victims are rushed, injured firemen saved, where Jimmy Fallon underwent 6-hour surgery on his injured finger. It was at the vanguard of the AIDS epidemic in the 1980s, and handled the city’s lone ebola case in 2014. It’s the city’s hospital.

The book details the facility’s prime role in the country’s medical history — from 18th Century origins to Civil War battlefield experience, when Bellevue doctors pushed the boundaries of surgery and care. The boundaries in those days, of course, weren’t particularly impressive.

Oshinsky retells the story of the first doctor — a Bellevue graduate — to attend to Lincoln at Ford’s Theater, who probed with his uncleaned finger for the assassin’s bullet in Lincoln’s brain. That was cutting edge at the time.

Bellevue’s history tracks the development of new procedures, from a Nobel Prize for cardiac catheterization to its checkered involvement in the use of electroshock therapy, including on children under 10.

Bellevue’s preeminence as a research facility was inextricably tied to its great resource — desperate, poor patients became experiments for progress. For Oshinsky, this is a mixed legacy but positive on balance: pioneering doctors were largely trying to do good, “not Frankenstein.”

Bellevue’s readiness to tackle NYC’s ebola case was a culmination of these experiential gains, given its battle with AIDS and quarantines for tuberculosis.

An organ that keep’s the city running

Oshinsky’s book comes at a complicated time for the city’s flagship public hospital. It, and the rest of the city’s public system, are in a deeply troubled financial position. Obamacare has been no boon for the hospital of last resort — those with insurance tend to take their money elsewhere, and federal funding meant to cover hospitals who treat the uninsured has declined. That could continue under President Trump.

Mayor Bill de Blasio has committed to bolstering the city’s public hospitals despite setbacks. De Blasio’s head of the hospital system left the position this fall just a few months after the mayor announced an overhaul. De Blasio has increased funding to the public hospitals and also worked to bolster primary care outside of them, the idea being to prevent major health issues before they become deadly, and expensive. Oshinsky sees the current mayor as a defender of the public hospital philosophy.

It’s difficult to see how the city could get by without a hospital like Bellevue — particularly for those residents of the city who are often ignored and left to fend for themselves.

In one of the hospital’s winding corridors, Oshinsky points to a sign welcoming patients to the pediatric emergency room in over 20 languages. In the I.M. Pei-designed lobby, Oshinsky says you can often find homeless New Yorkers, some of them residents of the shelter up the block. Sometimes they don’t need care; sometimes they do.

“We are the safety net,” says Oshinsky.