Doctor told me no sex for 4 weeks..

Doctor told me no sex for 4 weeks.. Does this mean no masterbation either?? She said no sex because sperm can affect the meds that I am on..