Definitely talk to your doctor. Are you one medications ? Some medications can cause a person to retain water. So, try not to worry that your weight is going up. It's probably just water retention that should pass in a few days.
As others have already noted, don't worry about trying to diet for the time being. Listen to your doctor and make sure you eat plenty of healthy foods to nourish your body. Your body needs those extra calories to help you recover.
Once your doctor gives the all clear, then you can think about cutting calories. For now, just concentrate on getting better. that's what counts. Put away the scale and don't even think about it. Everything will be fine, try not to worry !