Detaining patients for unpaid bills is illegal: High court