(ii)such person, being a voluntary patient, has given his consent in writing or where such person (whether or not a voluntary patient) is incompetent, by reason of minority or otherwise, to give valid consent, the guardian or other person competent to give consent on his behalf, has given his consent in writing, for such research.