fixed bug where new $patient returns 0 for the pk if there are no rows in patient_metadata_keys.
bugfixes and test bugfixes and tests.
Merge branch 'feature/transactions' of github.com:openeyes/OpenEyes into feature/transactions