ELAINE O'Hara told staff at a mental health hospital about "soliciting someone to harm her or possibly kill her," the Central Criminal Court has heard.
The jury was told she may have mentioned this to a nurse manager at St Edmundsbury Hospital "years ago".
Damien Lanagan was giving evidence in the Graham Dwyer murder trial. The jury also heard that the phone number for a man named Graham was found on a diary entry on Elaine O'Hara's laptop.
Mr Dwyer (42), of Kerrymount Close, Foxrock, is pleading not guilty to the murder of Ms O'Hara (36) at Killakee, Rathfarnham on August 22, 2012.
Ms O'Hara, a childcare assistant from Killiney, was last seen alive near Shanganagh Cemetery in Shankill that day. Her remains were found in undergrowth in the Dublin mountains on September 13, 2013.
The prosecution maintains Mr Dwyer killed her for his own sexual gratification.
Mr Lanagan told Anne Marie Lawlor BL, prosecuting, that he was on duty at St Edmundsbury Hospital, Lucan during Ms O'Hara's last stay there between July 14 and August 22, 2012.
He agreed with Ms Lawlor that Ms O'Hara could come and go as she pleased while at the hospital. She would sign herself in and out when leaving.
Mr Lanagan agreed that he had some awareness of Ms O'Hara's involvement in S&M.
"Previously, yes", he said.
He was aware that she arranged and met up with other people to engage in sexual practices. He was not aware of her self-harming while she was at the hospital in 2012.
"Years ago, she may have mentioned soliciting someone to harm her and possibly kill her," Ms Lawlor said.
"Yes," Mr Lanagan replied.
In cross-examination, Kate McCormack BL, for the defence put it to him he had said of the S&M issue in his statement: "I was aware of this through team meetings and I was aware that over the internet, she arranged and took part in strange sexual practices with strangers."
Mr Lanagan agreed.
The jury also heard a phone number for a man named Graham was found on a diary entry on Elaine O'Hara's laptop.
Detective Garda Eimear Nevin from the computer crime investigation unit said she examined a forensic copy of the hard drive of the Apple laptop.
The device had previously been handed over by Mr O'Hara's sister, Ann Charles, to gardai.
The jury was shown a screen shot of a date from Ms O'Hara's calendar app - June 30, 2011.
"Graham's phone number 083 11 03474," it noted, along with another note saying "school finished for the summer", the jury heard.
Det Gda Nevin said she used BlackLight Software to examine the Apple system and found the primary user account "was in the name Elaine O'Hara", as well the username.
She agreed with Sean Guerin SC, prosecuting, she found "one area of interest" and extracted the user profile so she could see that information on her forensic work station like Mr O'Hara would have seen it on her own laptop.
Earlier the court heard Ms O'Hara had suffered from an "obsessional" fantasy about being restrained or imprisoned since the age of around 12.
One of her treating psychiatrists, Dr Matt Murphy, said notes showed she first spoke to doctors about a "play in her head" in her teens in 1992.
Dr Murphy said he took over Ms O'Hara's care after the death of her previous psychiatrist, Professor Anthony Clare, in 2007.
He referred to Dr Clare's notes on her earlier care while giving evidence to the jury.
Dr Murphy said Ms O'Hara was first seen at St Edmundsbury Hospital by Dr Clare on August 5, 1992.
She presented with persistent obsessional thoughts or fantasies and spoke of a play in her head.
"I think it concerned being restrained or being imprisoned, she had acted out those thoughts to some degree herself," he said.
She received regular outpatient care for a time after that for a number of years and had therapy.
Her second admission was some years later, in 2000. She had been on a combination of anti-depressant medication and major tranquilisers.
There was initial uncertainty about her diagnosis and it had been thought there had been a possibility that there was an emerging psychotic illness.
As time progressed, however, the feeling was that what she was suffering from was nearer to a personality problem, Dr Murphy continued.
"I think the diagnosis that we all would have concurred with ... was borderline personality disorder," he said.
The court heard that in 2006 a letter was written from Prof Clare to Dr Margaret Griffin, a consultant endocrinologist who specialised in the treatment of gland trouble.
It remarked how physical tests, particularly on testosterone levels, did not play a role in her disturbed behaviour. The letter also referred to her "sexuality being disturbed, masculine even".
Prof Clare had also stated Ms O'Hara posed real management problems, but that it was not going to be diabetes "that determines the fate of Elaine", hence his desire "to get to the root of such disturbed behaviour".
Dr Murphy told the jury there were a number of references in charts to Elaine saying she thinks "I'd rather be a boy" or "I don't like being a girl".
"There probably would have been a sense her dress sense was not especially feminine," he added.
Dr Murphy said he admitted Ms O'Hara as an emergency on July 14, 2012 after she called the hospital and told staff she had constructed a noose and planned to hang herself.
On July 23 notes stated that Ms O'Hara was struggling with a "thought" constantly about making a noose and hanging, but she denied planning to kill herself. Another entry in the notes referred to her taking a rope from her workplace but later discarding it.
On August 8, 2012, there was a care plan review and Ms O'Hara was asked for her views.
"Mood swings are bad and I feel I am about to burst," she was noted as saying. "My chest is heavy and mixed up, as is my head. I am frustrated, I am so angry and fed up. I am fighting a losing battle."
Ms O'Hara was in much better form leading up to her discharge, Dr Murphy said, "She was probably as good as I've ever seen her. Bright, cheerful and optimistic and was planning forward in an immediate future way," he said.
"She had plans to do things and get on with her life.