Gateway 3381 - Audit Repository Logging for Doc Query

Modified logic to determine which hcid value should be used in the audit repo log depending on use case.