You should say where you found this, and what $q$ is.
Meanwhile, this resembles Lemma 2(ii) in WATSONWatson's Transformations of a Quadratic Form which do not increase the Class Number. The main differences are Watson has your $m=n$ and he allows your $q$ to be any positive integer, which may matter as far as a possible factor of 2. If you give more detail of why you think this is a theorem and why you care, I might put in more time.