Friends with patients is definitely a no. Everything else is basically at your discretion.
As a person, I happen to almost never send friend requests because I'm not very active on social media. As a resident, it would seem fine/appropriate to me to send friend requests to other residents. I would definitely feel weird requesting an attending. Friend requesting a med student would be really case-dependent. If I got along with a med student, I can see it being appropriate to friend request them only after the rotation was over, I've submitted my evaluation of them and I'd think twice if it was a clerkship student who I might supervise during a sub-I later.
As far as accepting, requests from residents and fellows would probably always be accepted. Same for others in the hospital that I would consider around my level on the totem pole (social workers and nurses around my age, etc.) I would probably accept a request from a med student if I didn't hate them or think it would cause an issue. A request from an attending would probably feel weird (maybe this is just the formality of my program), and I may or may not accept it depending on who it was.
As a med student, I think it would look weird to send a request to anybody except maybe a resident after your rotation was over. Accepting is pretty much entirely your choice. I think almost anybody would understand if you didn't accept their friend request because most people understand that these power dynamics can make people feel awkward. Maybe a resident you worked closely with and who you got along really well with might find it odd if you didn't accept their request but even that seems unlikely. People have different boundaries and that's fine.