The passing on of information by NHS bodies to the government as part of the crackdown on “health tourism” has been upheld as lawful by the High Court.

The Immigration Rules were amended in 2011 to impose sanctions on non-UK residents with unpaid NHS debts of £1,000 or more.

The sanctions include refusing individuals permission to enter or remain in the country.

These sanctions have been catching would-be immigrants who have not yet won the legal right to reside.

The court challenge was to the way NHS trusts transmit information about non-UK patients who have not paid for treatment to the health Secretary, who then passes it on to the Home Office to make sanction orders.

Four claimants, who cannot be named for legal reasons and were referred to as W, X, Y and Z, asked London’s High Court to rule that the transmission of patient details amounted to “illegal data sharing” under the immigration sanction regime.

All four had been charged, or were liable to be charged, for NHS treatment.

W’s position has changed and has limited leave to remain in the UK; X and her family are “overstayers” who are fighting legal actions to remain; Y has had his application to remain refused and is awaiting an appeal before a tribunal.

Z was refused leave to enter to see her husband on the basis that she was pregnant. She was detained but later released and gave birth in December 2011.

She was liable to pay for the maternity treatment she received, and her NHS debt of £2,550 for that treatment was notified to the Home Office. She is currently challenging a decision refusing her leave to officially enter and remain.

David Wolfe QC, representing the four, argued there was no legal power for the NHS bodies to pass on information to the health secretary, or for him to pass it on to the Home Office for a number of reasons, including the “confidential nature” of the information.

Dismissing the claim, Mr Justice Silber ruled: “The secretary of state had a statutory right to obtain information from the NHS bodies.”

The judge said allowing NHS bodies a discretion to refuse to transfer “specified limited information” about non-UK patients would “undermine the statutory purpose of the immigration sanction regime”.

The new unpaid debts rules do not apply to accident and emergency cases, family planning services or the treatment of illnesses and infections with public health implications.

Craig Keenan, an official at the Department of Health, told the court in a witness statement that financial pressures on the NHS were “exacerbated by the significant problems of health tourism” and it had become necessary to have an effective regime for charging overseas visitors for hospital treatment and recovering such charges”.