The High Court has refused to order that the HIV status of a young man can be disclosed to a young woman with whom it is believed he may be having unprotected sex.
In the case, which is believed to be one of the first of its kind, the court concluded that the circumstances did not justify the breach of patient confidentiality.
The judgment was delivered last month but was published online yesterday evening.
The action was taken by the Child and Family Agency.
The young man is under 18 and has been in the agency's care for a number of years.
He has had HIV since birth.
The Child and Family Agency (CFA) wanted to be able to disclose his status to a young woman who is also under 18.
It believes he has been having unprotected sex with this young woman - this is denied by the young man who says they are very good friends.
In its ruling, the High Court found that the CFA had not established on the balance of probabilities that the young man was having sexual intercourse with the young woman.
Mr Justice Michael Twomey ruled that even if the woman was willing to have unprotected sex with the young man, and assume the risks associated with that, then the low risk of HIV in such circumstances, and the fact that HIV was not a terminal illness, could not justify breaching a patient's right to confidentiality, which should only be breached in exceptional circumstances.
In his ruling, Mr Justice Twomey said the case was "unprecedented in Irish courts" since an order was being sought to breach patient confidentiality for the benefit of a third party.
The case raised the issue of how exceptional the circumstances must be for a doctor to breach this confidentiality.
The judge also referred to the significant factual dispute between the sides.
He said the doctors in the case had been advised that there was a risk the teenager - known as A in the judgment - was having unprotected sex with the young woman - referred to as B.
But the young man says she is a very good friend and denies they have ever had sex or that she is his girlfriend.
He says there is therefore no basis for his HIV status to be disclosed to her.
The young woman is unaware of these proceedings.
The judge said the CFA had failed to establish on the balance of probabilities that A was having sex with B, let alone that they were having unprotected sex.
He said the court concluded on this basis, that there was no risk of the young woman contracting HIV and no basis for the breach of patient confidentiality.
But, he said, even if the two young people were having sex, the medical evidence was that HIV was a significant, chronic and lifelong condition but not a terminal condition.
The judge said this meant it was not a "very serious harm" that would justify breaching patient confidentiality.
He also found the risk of contracting HIV through sexual intercourse was very low - around 0.04% - and that the risk could be reduced by the use of condoms.
He also found that even if the two were having unprotected sex, the young woman would be undertaking an activity which she should know carried a risk of contracting sexually transmitted diseases, one of which is HIV.
In that legal sense, he ruled she would not be an "innocent third party".
The judge said the public interest in ensuring that patients can have absolute confidence in revealing their most private medical and personal information to doctors, without fear of disclosure to third parties superseded the right of the young woman to be warned that she risked contracting HIV, if she engaged in unprotected sex with the young man.
Mr Justice Twomey said the proceedings were supported by well intentioned doctors who had B's interests at heart.
But he said the court was aware of the consequences the order being sought would have for all medical professionals.
In particular, if an order was granted giving a medical professional the right to breach confidentiality where a patient had a sexually transmissible disease, it would carry with it a responsibility to decide if sexual partners of the patient needed to be notified.
And there could also be a liability for medical professionals who failed to breach patient confidentiality, if harm came to someone else as a result.
The judge said he was concerned for the young woman's welfare but he had to balance that concern with the public interest in ensuring that patients with any kind of serious communicable disease could continue to have the confidence to seek medical assistance without concerns that their private condition might be revealed to third parties without their consent, except in the most exceptional circumstances.
Mr Justice Twomey said he found the teenager in this case to be a convincing witness who was described as very honest by his social worker.
He had kept his HIV status as a secret and personal matter for many years.
He told the court he planned to disclose it to the person he plans to settle down with, when that time came and claimed if it was disclosed before then, his life would be ruined.
He had difficulty coming to terms with the fact that he had this disease.
The judge said that despite the young man's honesty, it was not inconceivable that he would lie about being in a sexual relationship with the young woman, to ensure his status was not disclosed without his consent.
But he said the court was of the view that he was probably not having unprotected sex with her, as the young man was fully aware of the seriousness of the HIV virus and the stigma attached to it.
It was not alleged that the teenager would transmit the virus maliciously or by deceit to the young woman and he had "obvious regard" for her.
Mr Justice Twomey said this order, which was being sought for the first time in the Irish courts, raised the possibility that if it was granted, in similar cases in the future, the court would be involved in determining in a civil case whether two consenting adults are having sex.
He expressed "some unease" at ordering the Child and Family Agency or doctors that they are entitled to disclose patient information based on what they believe is going on behind closed bedroom doors, between two consenting people, who were as close to adulthood as makes no difference.
He said the court could not ignore the consequences of such an order for future cases.