Something similar happened with my elderly father. His dementia came on fairly suddenly and he ended up having a urinary-tract infection. It caused him to be somewhat dillusional and incoherent. They treated him with the proper antibiotics and he got better in no time.
I was diagnosed with congested heart failure 6 years ago, and it appears your father has a similar condtion. What is happening the heart has weak contradtility, and it is unable to pump into circulation the amount of blood oxygen received from the lungs. This backs up the blood into the lungs and peripherals and fluids leak into the tissues.
With the output of blood/oxygen at a lower than normal, the brain as well as the heart, and peripherals will not receive an adequate supply. When I was in the hospital for CHF my oxygen level was low and required repiratory oxygen supply. It took a few days to get the oxygen level to normal. The brain demands at least 20% of the body’s oxygen supply, when it doesn’t get this supply it can lead to issues such as sleep problems, poor concentration, forgetfulness, mood swings, restlessness, depressive thoughts and low drive.
Hope this helps you understand.