It often comes down to the context for the hug and the patient's individual preferences. There are plenty of people who can be visibly upset but prefer to avoid being physically comforted, even by close friends or family, so it's important to make a judgement based on the situation and your knowledge of the patient.