Viki Graham, 46, will spend at least two months behind bars after she was charged with wounding the patient at a busy inner-city hospital.
The court was told the man suffered a skull fracture, bleeding on the brain and a seizure in the attack and was taken to intensive care in a critical condition.Â
Graham, who works part-time at a local pub, walked into Sydney's Royal Prince Alfred Hospital and spoke with a night nurse shortly after midnight on Thursday, police said.
The nurse told the woman she could not visit the ward because it was after visiting hours, prosecutors alleged in bail court on Thursday.
Graham is accused of ignoring the nurse and entering anyway.
"I just want to talk to him," she allegedly told the nurse.
When she found the victim, she drew a hammer with a pink handle from a bag and struck the 63-year-old man firmly on the right side of his head, police allege.
Acting Judge Judith Sweeney said the man had been in hospital since January.
"This was a gratuitously violent attack," the judge said.
Police said Graham tried to escape the ward after the attack but the doors had been closed.
After her arrest, the woman allegedly confessed to officers, saying: "I smashed him with a hammer".
She allegedly told police her motivation for the attack stemmed from the victim having stolen the ashes of her late brother.
The 46-year-old was charged with wounding with intent to cause grievous bodily harm, which carries a maximum penalty of 25 years in jail.
Graham was unsuccessful in her bid for bail after appearing via a video link from Newtown Police Station in a long, black waterproof coat.
Speaking outside the hospital, Sydney Local Health District chief executive Deb Willcox said the facility had designated visiting hours, but the buildings were accessible 24 hours a day.
"Our hospital is an open public building where people can gain access anytime of the day or the evening," she said.
"We do whatever we can to enable people and visitors and friends and loved ones to see the patients."
Ms Willcox said the man was well-known and liked by staff.
"By all accounts (he's) a really lovely person that the staff are very fond of," she said.
There were several other patients in beds in the same ward at the time of the attack but Ms Willcox said no one else was impacted.
Graham will appear at Downing Centre Local Court on June 4.