You can express P4 coordinates in the P1P2P3 vector basis.
x4 = x1 + A * (x2 - x1) + B * (x3 - x1)
y4 = y1 + A * (y2 - y1) + B * (y3 - y1)
This is easy-to-solve linear equation system. You have to find A and B coefficients, then use them to calculate z-coordinate
z4 = z1 + A * (z2 - z1) + B * (z3 - z1)