Sorry you have to have surgery, but hopefully you will be feeling much better afterward.
Your doctor is half right
... rapid loss of a significant amount of weight can lead to the development of gallstones, but it's usually in relation to a lowFAT diet. I explained this in detail to another member a few months ago, please
click here to read it.
There is no need for you to stop low-carbing up to the time of your surgery. In fact, if you were to suddenly stop eating fats, that might stimulate the formation of more stones, since the bile would just sit in the gall bladder, and sediment would collect ...
However, I would suggest you try to eat mostly monounsaturated fats, such as olives and olive oil, avocadoes, nuts and nut oils .... and limit saturated fats from cheese and red meats. The reason I suggest this is because the MONO fats are simpler to digest, requiring less bile to break down the single (mono) fatty acid chain. Don't go totally lowFAT.
You might up the carbs a little, in the form of veggies and maybe some lowcarb fruits -- berries, melon, kiwi. The fiber would be good for the gut. Don't worry about ketosis for now. After the surgery, focus on getting your strength back, and try to consume the most nutritious foods, including carbs, if that's all there is (hospital food leaves a lot to be desired
) .. then you can safely resume low-carbing -- and ketosis -- afterward, when you're feeling stronger.
All the best ... and keep us posted how you're doing...
Doreen