If it is expected that it will not be possible to distinguish the gender of that person after performing the operation and he or she will not be able to marry, the operation should not be carried out in this case as it will be pointless. The operation should be delayed until it is possible to expect that the gender will be identifiable. This is based on the Hadith of the Prophet (peace be upon him) in which he said:
Your blood, your property, your honor, and your person (i.e., bodies) are as inviolable to one another...
May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.