One option might be to have a mechanism enforcing adherence to a strict professional code. Another option might be to prohibit those particular activities completely.

In my first example, both approaches are used, depending upon the country and ethical code adopted. Several countries adopting a strict Islamic code will prohibit male doctors from examining female patients at all. On the other hand, many Western countries use a version of the Hippocratic oath, with penalties for departing from it.

In my second and third examples, prohibition is not feasible (although if you are a pacifist, you might argue that prohibition was feasible in the third example).

But what about the fourth example, the one which makes this post relevant

Log in with your credentials

Forgot your details?