You might be able to reduce a few instructions by using BETWEEN instead of x >= y AND x <= z. So, ...WHEN x BETWEEN y AND z.
There seems to be an oportunity to simply write a BASE 10 to BASE 36 conversion routine. I don't know if there is a more straightforward conversion than what you've preposed here but it might be worth a thought.
Enjoy