The invention relates to a rehabilitation mechanism (30) implemented for planned, automated rehabilitation of at least the joints, muscles, and tendons of the legs (92) of a bedridden patient (90) and comprising at least:a foot module (40) for operatively connecting to the feet (94) of the bedridden patient (90),a knee module (50) for operatively connecting to the knee joints (93) of the bedridden patient (90), anda control module (60) for controlling planned rehabilitation motions of at least the joints, muscles, and tendons of the legs (92) of the bedridden patient (90) by means of the foot (40) and/or knee module (50).The invention is further characterized in that at least the knee module (50) is implemented as a module for disposing between the patient (90) and the mattress (20) and supported directly or indirectly on a bed (11) or mattress frame (21).The modular design of the rehabilitation mechanism (30) has the advantage that bedridden and particularly intensive-care patients (90) can receive planned, automated rehabilitation directly in the bed (10), wherein said bed can be implemented as a hospital bed, clinical bed, gurney, and/or intensive-care bed, without requiring high-risk transfer between beds and/or the ability to cooperatively contribute.