I know how to generate regular Pythagorean Triples given two positive integers P and Q such that $$a=2*p*q$$ $$b=p^2-q^2$$ $$c=p^2+q^2$$ where $p>q$, but I want to find scenarios where $a$ and $b$ can also be written in the format $p^2+q^2$. Specifically, I am looking for a generalized way of finding all situations where the hypotenuses of the first two triples form the legs of the third triple. $$$$ I want to be able to generate a formula for finding these special triples.
So far, I have been able to find four cases where this holds true by using the brute force method.
As you can see, the third chart shows Pythagorean triples with legs that are also hypotenuses of the previous charts. For example, the right triangle with sides (104, 153,185) corresponds to the right triangles with (40,96,104) and (72,135,153). The P and Q vales show $P_1^2+Q_1^2=2P_3Q_3$ ($10^2+2^2=2*13*4=104$), and $P_2^2+Q_2^2=P_3^2-Q_3^2$ ($12^2+3^2=13^2-4^2=153$).
I gathered this information using the highly inefficient and laborious method of inputting a table of P and Q values into Google sheets up to P and Q being less than or equal to 25. Then, I searched the data by using vlookup and countif functions, after sorting it a bit.
$$$$ I think there must be a way of simplifying this process, but it eludes me. How can I (in a much less time consuming way) generate these special Pythagorean triples where each side of the triangle is a hypotenuse of another Pythagorean triple?
Edit: While the Euclidean formula for Pythagorean triples relies on the value of $p$ and $q$ to generate legs $a$ and $b$ with hypotenuse $c$, I am looking for a generalized way of finding the special "triple triples" for lack of a better term given integer inputs $(input_1...input_k)$ that I can input into functions $$f_A(input_1...input_k)=A$$ $$f_B(input_1...input_k)=B$$ $$f_C(input_1...input_k)=C$$ Where A and B are hypotenuses of other Pythagorean triples, and (A,B,C) forms a Pythagorean triple in and of itself.