IntraHealth - Fixed problems with: location filter, calculations and small refactoring.

In the PR fixes for cases:
http://manage.dimagi.com/default.asp?122052#693040
http://manage.dimagi.com/default.asp?122079#693042
http://manage.dimagi.com/default.asp?122887#694623
http://manage.dimagi.com/default.asp?122986#695212
:warning: