One of my sims who had two sons and had one die of sunlight went and tried for a girl and got triplet boys instead. I got pissed, exited the game without saving and went back in and played another house instead. Luckily she had a single girl while I was playing the other house. So it really is random and you can just save just before your sim goes into labour and exit without saving if you don't get what you wanted.