A rehabilitation mechanism rehabilitates the joints, muscles, and tendons of the legs of a bedridden patient in an automated manner according to a plan. A knee module can be operatively connected to the knee joint of the patient. A control module controls rehabilitation movements by way of the knee module. The knee module is a module to be arranged above the patient and the mattress, which module is supported directly or indirectly on a bed or the mattress frame, and includes a knee prosthesis which receives a knee joint of the patient, a connection element connected to the knee prosthesis, an extension arm to which the connection element is secured, and a mechanism to be actuated by the control module and which introduces a defined force into the knee prosthesis via the extension arm and the connection element to carry out rehabilitation movements according to a plan.