Should one say Hagomel after recovering from being sick?
The type of illness: Some Poskim rule that the blessing of Hagomel is only recited by one who recovered from a potentially life-threatening illnesses [i.e. Choli Sheyeish Bi Sakana], such as an injury in one of the inner organs and the like for which one is allowed to desecrate Shabbos, [and so is the Ashkenazi custom]. Other Poskim, however, rule the blessing is to be recited for any illness which made him bedridden, even if it is not lethal [and so is the Sephardic custom]. In this regard, it makes no difference if it is a recurring illness that comes from time to time, or not. [According to all opinions however a mere headache or stomachache, or slight fever without being bedridden, does not render one obligated to recite the blessing.]
The final directive: Practically, [Ashkenazim are] to do as follows: If the person was sick to the point that he was stuck to his bed for more than three days, then he is to say the blessing upon recovering [even if it was not a life-threatening illness]. If, however, he was not sick to the point of being stuck to his bed for three days, than the blessing is not to be recited, unless it is known to have been a potentially life-threatening illness. [Thus, if a person caught a typical flu or virus, such as a respiratory virus, Covid, or urinary virus or infection, and was sick with fever, then so long as it never reached a stage of being considered life-threatening for him, then a blessing is not to be recited if he was able to walk around, and was not stuck in bed for more than three days.]
If one was sick to the point that he was stuck to his bed for more than three days due to lack of energy, then he is to say the blessing of Hagomel upon fully recovering.
What is the definition of being stuck to one’s bed for more than three days? What if he gets up to go to the bathroom?
The intent is that in general he felt sick to the point that he felt the need to stay in bed and did not feel he has enough energy to walk around. Thus, even if he forced himself to get up to get a drink or go to the bathroom or do something temporarily, it is still considered that he was bedridden. If, however, he spent extra time in bed and stayed home from work but also spent time around the house, then he is not considered bedridden in this regard and is not to recite the blessing of Hagomel unless it was a life-threatening illness.
Should a blessing be recited if one was initially bedridden due to the illness and was able to get up from his bed prior to three days due to the help of painkillers?
Seemingly, in such a case the blessing is not to be recited.
If one was hospitalized due to his illness, must he recite the blessing of Hagomel upon recovery?
If he was stuck to his hospital bed due to lack of energy for more than three days [with exception to going to the bathroom and the like], than the blessing is to be recited. If, however, he felt good enough to walk around, than a blessing is not to be recited unless his illness was deemed life-threatening.
 See Seder Birchas Hanehnin 13:2, 5, and 6; Luach Birchas Hanehnin 12:8; Ketzos Hashulchan 65:3; Piskeiy Teshuvos 119:20
 Seder 13:5; Luach 12:11; Ateres Zekeinim 219:2; Shut Maharash Lublin 1
 Seder 13:2; Luach 12:8; Admur Basra 1:9; Michaber 219:1; Rav in Brachos 54b
 1st opinion in Seder 13:6; Luach 12:12; Rama 219:8; Tur 219 in name of Raavad
 Rama ibid
Other opinions: Some Poskim rule that even Ashkenazim should follow the opinion of the Michaber, brought next. [Bach 119, brought in M”A 119:8 that so is the custom of some; Elya Raba 119:3; P”M 119 A”A 8 that so is the custom ]
 Michaber 119:8; Tur 119 in name of Yerushalmi Brachos 4:4; Beis Yosef in name of Ramban; Rashba 1:82; Bach 119, brought in M”A 119:8 that so is the custom of some; Elya Raba 119:3; P”M 119 A”A 8 that so is the custom
 The reason: As being forced to go to one’s bed due to the illness is similar to one who must go up the steps of the courthouse for judgment. [Michaber ibid]
 Michaber ibid
 Tur 119; Mamar Mordechai 119:9; Sedei Haretz 3:10; Ikarei Hadat Y.D. 24; M”B 119:24; Kaf Hachaim 119:44
 Admur Seder 13:6; Luach ibid; Taz 119:5; Ketzos Hashulchan 65:3; Divrei Yatziv 1:87; Piskeiy Teshuvos ibid
Other opinions: Some Poskim negate this ruling, and state that the length of three days is irrelevant to the above law, and does not apply according to either opinion, is either one holds that any amount of being bedridden obligates one in the blessing of Hagomel, or one rules that the illness must be life-threatening in which case any amount of being sick obligates one in the blessing of Hagomel. [Biur Halacha 119:8 “Kegon Makah”]
 See Rama ibid
The Sephardi custom: According to the Sephardi custom, so long as he was bedridden even for a short amount of time, a blessing is recited. [Kaf Hachaim 119:46]
 The reason: As one who is bedridden for more than three days is to have others pray and arouse mercy on his behalf. [Taz ibid; See Michaber Y.D. 335]
 Ketzos Hashulchan 65 footnote 10
 See Piskeiy Teshuvos ibid footnote 108