I am trying to write the Lagrangian and Hamiltonian for the forced Harmonic oscillator before quantizing it to get to the quantum picture. For EOM $$m\ddot{q}+\beta\dot{q}+kq=f(t),$$ I write the Lagrangian $$ L=\frac{1}{2}m\dot{q}^{2}-\frac{1}{2}kq^{2}+f(t)q$$ with Rayleigh dissipation function as $$ D=\frac{1}{2}\beta\dot{q}^{2}$$ to put in Lagrangian EOM $$0 = \frac{\mathrm{d}}{\mathrm{d}t} \left ( \frac {\partial L}{\partial \dot{q}_j} \right ) - \frac {\partial L}{\partial q_j} + \frac {\partial D}{\partial \dot{q}_j}. $$
On Legendre transform of $L$, I get $$H=\frac{1}{2}m\dot{q}^{2}+\frac{1}{2}kq^{2}-f(t)q.$$$$H=\frac{1}{2m}{p}^{2}+\frac{1}{2}kq^{2}-f(t)q.$$
How do I include the dissipative term to get the correct EOM from the Hamiltonian's EOM?