Sex during pregnancy after miscarrying

Patient: I just found out that I am pregnant after having a miscarriage on the 2nd of this month. I don’t know what caused the miscarriage, but the nurse said it probably just didn’t implant. I was 5 weeks pregnant, and now I expect I am about 4 weeks. I was wondering if it was safe to have sex during my pregnancy, since I already had a miscarriage?