Lets say that an individual who is about to engage in sex can cause harm to himself or the other person in the act whether that is physically or through contracting diseases, is having sex then deemed haram?
If a person knows that he/she has some STD, then it is not permissible for such a person to have sex or get married. However, if the sexual partner also already has the same disease, then it might be permissible. All, assuming that the sexual partner in question is spouse of the subject.
And Allah knows the best.