Solution (source code)

= Solution

Put $a=\sqrt p$, $b=\sqrt{-q}$ and $\alpha=a+b$. Since $a^2-b^2=p+q$, the identity $(a+b)(a-b)=p+q$ gives
$$
a=\frac12\left(\alpha+\frac{p+q}{\alpha}\right),\qquad
b=\frac12\left(\alpha-\frac{p+q}{\alpha}\right).
$$
Thus $\mathbb Q(\alpha)=\mathbb Q(\sqrt p,\sqrt{-q})$. The latter has degree $4$: $p$ is not a square and $\mathbb Q(\sqrt p)$ is real, whereas $\sqrt{-q}$ is not real. Squaring $\alpha^2=p-q+2\sqrt{-pq}$ gives its monic degree-$4$ <minimal polynomial>
$$
\boxed{m_\alpha(T)=T^4-2(p-q)T^2+(p+q)^2.}
$$