I have written piecewise functions, so I would assume you can work with piecewise equations. I have not tried this.
Just recently I wrote a function defined piecewise over five intervals, and then proceeded to differentiate it multiple times with no difficulties at all. Actually, I started with a single function. My composite function was zero is the first interval, the single function translated into the second interval, set a nonzero constant in the third interval, used my original function translated and mirrored for the fourth interval, and zero in the fifth interval.
It took a while to figure out how to do it, but once I tried a test case or two, then I saw how things worked and it was easy to set up the main problem. One of the very nice things about it all is that if you want to try something, just try it. If it does not work, you can wipe those lines out and try something else.