Foster care home stays, court rules