My now-deceased cat, Sophie, used to poop (but not pee) outside of the box. It roughly coincided with the period in which her thyroid became hyperactive. I don't know if it was a physical or emotional response. Even after we got her thyroid under control, she only used the box semi-regularly. Thankfully, she at least limited her "surprises" to our unfinished basement. She never pooped upstairs, bless her heart. While I didn't enjoy cleaning up after her, I sort of took it in stride. I always did wonder why she was fine using the box to pee in, but not too poop. Maybe it did have to do with her urgency to do the latter but not the former. I don't know.

If you haven't already, I would get a fresh round of bloodwork done to see, in particular, how her thyroid and kidneys are doing.