GATEWAY-3180 subtask GATEWAY-3374: Patient Discovery - code and unit tes...

...ts complete.

Deferred is complete - comment and merge at will.