Gateway 3249

* Created new module for DocQueryErrorsCodes
* Refactored Fanout to move the condition when there are not matching patients to closer to generation of the error