Hospitals in California are so swamped by the coronavirus pandemic that the state has ordered those with room to accept patients from others that are out of intensive care beds.

The public health order issued Tuesday night could result in patients being shipped to Northern California from Southern California and the agricultural San Joaquin Valley, where 14 counties were immediately ordered to delay nonessential “and non-life threatening” surgeries in order to provide beds.

The order, which will last at least three weeks, also applies to any county where ICU capacity to treat COVID-19 patients is bottoming out.

“If we continue to see an alarming increase of COVID-19 patient admissions at hospitals statewide, some facilities may not be able to provide the critical and necessary care Californians need, whether those patients have COVID-19 or another medical condition,” said Dr. Tomás J. Aragón, the state’s public health officer.

The order could be a bellwether for California, where officials have warned that some hospitals may have to start rationing care if an expected post-holiday surge in COVID-19 cases overwhelms the health care system.

For much of the year, the nation’s most populous state did the right things to avoid a catastrophe. But now the virus is raging and California remains at or near the top of the list of states with the most newly confirmed cases per capita. Even with vaccines now being administered, albeit slowly, it is expected to take many more weeks to quell the contagion.

Martin Luther King Jr. Community Hospital in Los Angeles, where patients are being housed in its former gift shop, a chapel, tents and hallways, had more COVID-19 patients on Tuesday than its total capacity. The hospital, which serves a largely Black and Latino population in the south part of the city, has a capacity of 131 patients but was treating 215 patients, 135 of them with COVID-19, said Jeff Stout, the interim chief nursing and operating officer.

The hospital was emblematic of the worsening situation in Los Angeles County, the nation’s most populous with about 10 million residents.

A COVID-19 surge has created a shortage of oxygen and led to a directive to ambulance crews in the county to stop transporting patients they can’t revive in the field.

Dr. Marc Eckstein, medical director and emergency medical services commander of the Los Angeles Fire Department, said transporting someone without a pulse gives families false hope, takes the ambulance out of service, exposes workers to COVID-19 and requires decontaminating the vehicle.

“To be clear, we’re not asking first responders to decide who lives and who dies,” Eckstein said. “These are people who are clinically dead.”

Los Angeles continues to see hospitalizations rise day after day, setting a new record Tuesday with almost 8,000 hospitalized and more than a fifth of those in ICU. The county, which accounts for a quarter of California’s 40 million residents, has more than 40% of the state’s 27,000 coronavirus deaths.

Long Beach on Tuesday reported another 18 deaths and a record 573 people hospitalized in the five facilities that serve the area.

Meanwhile Community Hospital, shuttered for two and a half years due to seismic concerns, admitted its first patient Tuesday in a long-running bid to reopen under a new operator. For now the facility has total capacity for 51 patients, including 11 in its intensive care unit.

Some hospitals have had to close their doors at times because they’ve become so overwhelmed, leaving ambulances waiting up to eight hours and diverting others to different emergency rooms.

Stout said Martin Luther King hospital was finalizing its crisis standards of care, which are guidelines for rationing treatment when staff, medicine and equipment are in short supply.

“We’re not there yet,” Stout said. “Every day, every hour we’re trying to avoid going into crisis care. The ultimate goal with crisis care is never to get there.”

The state on Tuesday formally requested that 500 federal medical personnel be deployed in California to help staff hospitals and skilled nursing homes after learning that the USNS Mercy Hospital ship, which docked off Los Angeles earlier in the year for overflow patients, was in dry dock and would not be returning.

In the San Joaquin Valley, Fresno County’s top doctor said he was watching what’s happening in L.A. County “very closely” as he prepares for a seemingly inevitable surge stemming from people who ignored social distancing rules to gather for Christmas and New Year’s Eve celebrations.

“I’m very worried that we are going to see an uptick in the number of hospitalizations and deaths related to gathering that happened over the holidays,” said Dr. Rais Vohra, the county public health department’s interim health officer.Vohra said the county hopes to “scale up an army of vaccinators” to get as many people immunized as quickly as possible, starting with hospital staff, but one hurdle will be convincing people to get the vaccine.

There are some polls that show about 50% of people in the county “aren’t ready for the vaccine at this time” and are waiting to see if there are any side effects, said Joe Prado, community health division manager for Fresno County.

Associated Press reporter Christopher Weber contributed to this report.