Pythagorean type diophantine equation. 
How to find all solutions to
$$ a^2+b^2+c^2+d^2=e^2+2$$
where all variables $a$ to $e$ are positive integers and $e^2 \equiv 1 \mod 8$

I tried using parameterization similar to pythagoras equation, but no success so far. Any help will be appreciated.
Thanks!
 A: For such equations, you can use the standard approach. 
One approach is to use equations Pell.  For the beginning will talk about a more simple way.
I. Eq.1 
$$a^2+b^2+c^2+d^2=(2q+1)^2+2$$
Solutions have the form:
$$a=x + k$$
$$b=x + p$$
$$c=x + s$$
$$d=x - z+1$$
$$q=x$$
where,
$$x = -1 -z+ (z^2 - k p - k s - p s),\quad z = k+p+s$$
for any $k,p,s$. 
II. Eq.2 
$$a^2+b^2+c^2+d^2=(4q+1)^2+2$$
Solutions have the form:
$$a=2(y + k)$$
$$b=2(y + p)+1$$
$$c=2(y + s)+1$$
$$d=2(y - z)-1$$
$$q=y$$
where,
$$y = -k + 2z + 2(z^2 - k p - k s - p s),\quad z = k+p+s$$ 
for any $k,p,s$.
III. Eq.3 
$$a^2+b^2+c^2+d^2=(8q+1)^2+2$$
Solutions have the form:
$$a=16k^2+4p^2+4s^2+8pk+8ks+4ps+2s+2p-1$$
$$b=16k^2+4p^2+4s^2+8pk+8ks+4ps+4s+4p+8k$$
$$c=16k^2+4p^2+4s^2+8pk+8ks+4ps+4s+6p+4k+1$$
$$d=16k^2+4p^2+4s^2+8pk+8ks+4ps+6s+4p+4k+1$$
$$q=4k^2+p^2+s^2+2pk+2sk+ps+s+p+k$$
$k,p,s$ - integers asked us.
A: Now will show you a different approach. For,
$$a^2+b^2+c^2+d^2=(2q+1)^2+2$$
One can use the Pell equation,
$$x^2-ry^2=1$$
where,
$$r =k^2+(t^2+p^2+s^2)+(t+p+s)^2$$ 
for any $k,t,p,s$. Let,
$$u = x-2(t+p+s)y,\quad w = x-(t+p+s)y$$
Then solutions are,
$$a=2\, k\, u\, y$$
$$b=q - 2\, t\, u\, y + 1$$
$$c=q - 2\, p\, u\, y + 1$$
$$d=q - 2\, s\, u\, y + 1$$
$$q=2\,u\,w$$
And another solution:
$$a=2k(2(t+p+s)y-x)y$$
$$b=2y((p+s)x+(2(t^2+2(p+s)t+ps)-k^2)y)+1$$
$$c=2y((t+s)x+(2(p^2+2(t+s)p+ts)-k^2)y)+1$$
$$d=2y((p+t)x+(2(s^2+2(p+t)s+pt)-k^2)y)+1$$
$$q=2y((t+p+s)x+(2(tp+ts+ps)-k^2)y)$$
Be aware that if the ratio of the Pell equation $r$ - fold the square, can be reduced. In the formula, too, should be reduced.
