Theoretically, a doctor should not be prescribing medication for people without a solid understanding of their medical history. Even though a doc may know his family and their health problems well, he would still need their chart to be able to make the appropriate decisions. Same goes for self diagnosis - in theory, one should let an outside professional make these kinds of decisions so that you can get unbiased healthcare.
HOWEVER - it happens ALL the time - and as long as it is medically sound, there are no laws preventing it. I worked as a pharmacy tech for about a year and I cannot count the number of times a doc would walk up to the window and write the script for himself or a family member right there in line. In most cases, it's probably harmless. The scripts were usually for something they had been getting for a long time (meds for blood pressure, insulin needles, etc).