I'm thinking his refusal to give the prescription back is what got him fired. There is no reason to keep a prescription, and certainly it is illegal to do so.
As for why he didn't fill the prescription, I would assume he just wanted to make sure it was the right prescription for the right patient, errors since as the wrong person's name being put on a prescription due happen. Then again, generally doctors who do gender reassignment, that is their specialty, so the prescribing doctor should have been a clue as to what was going on (but maybe he wasn't familiar with the doctor?)
Overall, I have a feeling communication from both the patient and the pharmacist was pretty poor, leading to this bad scenario. And the commentators on-line who think pharmacists don't have a right to ask someone what they are using a prescription for are just stupid (although it probably would have went better if the pharmacist took the patient aside and said something like "the doctor ordered a medication for you that is used to normalize female hormones, but our profile says you are a male, I just want to check that this is the correct medication that you are to receive" Then this would give the patient the chance to say "that's incorrect, I'm female" (or something", and then the pharmacist could say "OK, I will correct your profile.")