added `unique` valdiation that takes patient_id parameter. #411

Supports unique('patient_id') rule on a validation in settings, added
two tests.

Fixed potential bug where db was undefined in
transitions.registration.setId().