My dd had similar issues, after a lot of worry, we have achieved a lot with psychology type approach. First we considered our language/body language. With hindsight we were always pestering her - have you poo'd, do you need a poo etc. So we just backed right off (despite it being hard to ignore the crossed leg, red face, gripping furniture etc) we just completely ignored it. And if accident happened neutral totally and just matter of fact clean up.
Then started toilet time. Chose a time of day she was most likely to fight the urge (after dinner for us), and just sat her on the loo with some fun toys. Again no poo talk etc, just sitting together, playing quietly. We have a little table next to the toilet so we could put toys there etc. We have a clock nearby so if no action in 10 mins we stop. Blowing bubbles or whistles is good as you can't blow and hold in poo!
Eventually this paid off. Hard thing is not jumping for joy when she finally did a poo! Again just neutral and matter of fact expression - she still looks at me for reassurance mid poo, and I just keep calm expression, no stress nor excitement.
Really worked for us, hope this is helpful to consider alongside the medication issues etc. I think we are more managing the situation than changing it, eg in our home with this routine all goes well, but if we go away anywhere she generally witholds again. But making small steps of progress all the time, dd poo'd at my sisters house a few weeks back, would have been unthinkable a few months ago!