Clomid

How long generally do you have to be ttc before being given clomid? And is it something your gp can give or does it have to be a fertility doc. TIA