Most importantly: The employee must take the initiative to communicate these requirements to the employer before the firing event.
It appears the OP may have waited until the termination meeting with HR to communicate the medical condition. It's not clear that the OP actually requested any accommodations or leave. In fact, it's not clear that the company denied the OP anything or had any way of knowing the OP's situation leading up to the firing event, due to the OP's admitted lack of communication with the company.