By now, you’ve probably heard about the desperate shortage of nurses and aides in nursing homes and long-term care facilities. This workforce crisis not only hurts their residents, it also is creating severe backups in hospitals, putting both patients and the facilities themselves at risk and increasing health care costs.

As those staffing shortages course through the entire health care system, they are creating a multi-level domino effect. Here is a simplified version of what is happening:

If you go to the local hospital emergency department these days, expect to wait. And wait. And wait. Delays in treatment have been a problem for years but they got much worse in the recent months of the Covid-19 pandemic.

There are lots of reasons. One is the staff shortages in the EDs themselves. Another is limited staff elsewhere in the hospital. When a medicine unit is short-staffed, it cannot take those ED patients, even if it has empty beds. And patients spend hours, or sometimes even days, in the ER. Waiting for a bed.

But there is another, less obvious, reason why there often are no available beds in hospitals: They are filled with patients who have nowhere else to go. And a big reason for that is the shortage of nurses and aides in long-term care facilities and home health agencies.

Here is the problem: It is illegal (to say nothing of irresponsible) for a hospital to discharge a patient to an environment that is unsafe. Yet, hospitals often can’t find a place that will take a post-acute patient.  Testing and treatment may be complete, but it still may be impossible to release them because there is no place for them to go.

Many are patients who normally would be discharged directly from the ED without ever being admitted to the hospital. In many cases, the ED team has addressed their acute issue but their condition requires some level of post-discharge care.

But with no one to provide that care, they are stuck in the ED. Many are left laying on gurneys in a hallway while social workers frantically try to find a safe environment where they can be discharged, whether at home with an aide, or in a skilled nursing or assisted living facility.

Short-staffed nursing homes won’t take them, especially if they have complex needs. In some parts of the country, especially in rural areas, there no longer are nursing homes within a reasonable distance of a patient’s home.

The problem is similar with less complicated patients who could go home with help. They too are stuck in the hospital because home health agencies don’t have the staff to care for them. One agency told me it has to turn down about 20 percent of its referrals because it can’t find staff.

It is exactly the same problem for patients who are admitted to the hospital. They too may stay for far longer than medically necessary simply because there is no place for them to go. And they are taking up a bed that otherwise would be available for the next patient.

You might think hospitals would be happy to have patients filling their beds. But they often are not. Medicare will pay a hospital only a fixed amount for a patient’s care, depending on their specific condition. If a patient stays longer than expected, Medicare may stop paying. In addition, a hospital’s Medicare quality score is based, in part, on lengths of stay. The longer patients remain hospitalized the worse it looks, and the less the facility may be paid.

Finally, good hospitals much prefer to care for patients with more complex needs than having a bed filled by someone who does not need hospital care but can’t find anyplace else to go.

Behind all of this is the labor shortage itself. Hospitals, nursing homes, and home health agencies all are competing for the same nurses and aides. And that is driving up wages for all providers. Hospitals tell me they now are paying as much as $250 an hour for a Registered Nurse hired through an agency. The middleman gets about one-third.

Make no mistake, staying extra days in a hospital is bad for patients who may run greater risks of infections. With family visits still limited, they also suffer more severely from isolation. And those family members may be less effective advocates.

For the many hospitals living on the financial edge, this combination of higher labor costs and longer lengths of stay could be fatal. It may to community hospitals selling out to distant health systems or for-profit chains, or even closing.

Considering the time it takes to train a new nurse and the ongoing fallout from the pandemic, it likely will be years before the current nursing shortage abates. Until it does, regulators, payers, and facilities  themselves will have to find new ways to manage patients through their hospital stays and get them discharged in timely and safe ways.