Pooing Nightmare

I have a problem with Joshua, he's 2 and a half and will not poo, AT ALL. He seems to have lost the ability to push out a poo. It's an ongoing problem, been back and forth to docs for about a year but nothing seems to help. He leaks poo into his pants but just tries to hold it as long as possible until I have to intervene with medication to MAKE him poo. It's very unpleasant for us both and I feel I have tried everything. He has a good healthy diet, I talk to him about it, try not to get frustrated but don't know what else to do. Any words of wisdom or advise would be greatfully received.Thanks Beccs