Sure.
Its not a prison. As long as you have the legal authority to do so for a committed person.
But if you are willing to care for them now...why are they in a nursing home to start with?
well my parents have passed. my daughter works in a retirement community. she says they are all locked in there rooms and the cases in the community are now at ten with one death. I would think a lot of kids right now would have a lot more free time on their hands if they aren’t working to care for the parent or parents instead of letting them take their chances in a retirement community.