issue cannot enroll patient in a program more than once TRUNK-3483 and 4322 solution

I have addressed the both tickets in this pull request. Because both of them are much related.