refactor SQL report to allow more modular use of code
Merge pull request #667 from dimagi/refactorsqlreport

refactor SQL report to allow more modular use of code