This paper analyzes the first integrals and exact solutions of mathematical models of epidemiology via the partial Lagrangian approach by replacing the three first-order nonlinear ordinary differential equations by an equivalent system containing one second order equation and a first-order equation. The partial Lagrangian approach is then utilized for the second-order ODE to construct the first integrals of the underlying system.We investigate the SIR and HIV models.We obtain two first integrals for the SIR model with and without demographic growth. For the HIV model without demography, five first integrals are established and two first integrals are deduced for the HIV model with demography. Then we utilize the derived first integrals to construct exact solutions
to the models under investigation. The dynamic properties of these models are studied too. Numerical solutions are derived for SIR models by finite difference method and are compared with exact solutions.