The HSE seemed to have tried to "shoehorn" Miss D into an X-case situation although it had no evidence that she was ever suicidal, Mr Justice McKechnie said.
While it would "perhaps be unfair" to criticise the HSE for seeking to create an X-case scenario, he said he was "most surprised" at the absence of any recorded decision of the HSE on the most crucial aspect of the case - what course of action would be in the best interests of the welfare of the girl.
In his judgment, the judge was very critical of the actions of the HSE in dealing with Miss D's situation. He said the position of the HSE had changed significantly, "some would say dramatically", during the case.
The HSE had initially told Miss D she could not travel for an abortion without its consent and that if she tried, she could be restrained, by force if necessary, but that claim was not pursued during the court hearing.
The actions of a HSE social worker in telling gardaí that Miss D must be prevented from travelling were without foundation in law, the judge said.
The HSE had later made the argument that a District Court order was required before Miss D could travel, he said. If it believed so, it should have made a District Court application early on.
The judge said the HSE was effectively "riding two horses with a firm grip on both" and, either way, it had control over the destiny of Miss D.
However, what it was crucially required to do but had failed to do, was address its statutory duty to establish what course of action was in her best interests. If it took the view it was in her best interests to travel for an abortion, it should have said so.
It seemed that the HSE had tried to "shoehorn" Miss D into an X case situation and it was to Miss D's great credit that she did not perjure herself in that regard and say she was suicidal, Mr Justice McKechnie said.
The HSE position underwent a significant change during the court hearing last week and it took steps last weekend to apply to the District Court. It was to be commended for actively pursuing that solution, albeit it did so late in the day, he added.
He said he must comment on the "unacceptable" failure to disclose until later in the court hearing that the HSE had contacted the Passport Office after Miss D told a social worker she intended applying for a passport.