public MCCIIN000002UV01 processPatientDiscoveryAsyncReqError(
      PRPAIN201305UV02 request, PRPAIN201306UV02 response, AssertionType assertion, String errMsg) {
    MCCIIN000002UV01 ack = HL7AckTransforms.createAckErrorFrom201305(request, errMsg);

    AsyncMessageProcessHelper asyncProcess = createAsyncProcesser();

    // Add a new inbound PD request entry to the local deferred queue
    boolean bIsQueueOk =
        asyncProcess.addPatientDiscoveryRequest(
            request, assertion, AsyncMsgRecordDao.QUEUE_DIRECTION_INBOUND);

    // check for valid queue entry
    if (bIsQueueOk) {
      bIsQueueOk =
          asyncProcess.processAck(
              assertion.getMessageId(),
              AsyncMsgRecordDao.QUEUE_STATUS_REQRCVDERR,
              AsyncMsgRecordDao.QUEUE_STATUS_REQRCVDERR,
              ack);
    } else {
      String ackMsg =
          "Deferred Patient Discovery processing halted; deferred queue repository error encountered; "
              + errMsg;

      // Set the error acknowledgement status
      // fatal error with deferred queue repository
      ack = HL7AckTransforms.createAckErrorFrom201305(request, ackMsg);
    }

    return ack;
  }
  public MCCIIN000002UV01 addPatientDiscoveryAsyncReq(
      PRPAIN201305UV02 request, AssertionType assertion, NhinTargetCommunitiesType targets) {
    MCCIIN000002UV01 resp = new MCCIIN000002UV01();
    RespondingGatewayPRPAIN201305UV02RequestType unsecureRequest =
        new RespondingGatewayPRPAIN201305UV02RequestType();
    unsecureRequest.setAssertion(assertion);
    unsecureRequest.setNhinTargetCommunities(targets);
    unsecureRequest.setPRPAIN201305UV02(request);

    // Audit the incoming Nhin 201305 Message
    PatientDiscoveryAuditLogger auditLogger = new PatientDiscoveryAuditLogger();
    AcknowledgementType ack =
        auditLogger.auditEntityDeferred201305(
            unsecureRequest,
            unsecureRequest.getAssertion(),
            NhincConstants.AUDIT_LOG_INBOUND_DIRECTION,
            NhincConstants.AUDIT_LOG_RESPONSE_PROCESS);

    // ASYNCMSG PROCESSING - RSPPROCESS
    AsyncMessageProcessHelper asyncProcess = createAsyncProcesser();
    String messageId = assertion.getMessageId();
    boolean bIsQueueOk =
        asyncProcess.processMessageStatus(messageId, AsyncMsgRecordDao.QUEUE_STATUS_RSPPROCESS);

    // check for valid queue entry
    if (bIsQueueOk) {
      resp = addPatientDiscoveryAsyncReq(unsecureRequest);

      asyncProcess.processAck(
          messageId,
          AsyncMsgRecordDao.QUEUE_STATUS_RSPSENTACK,
          AsyncMsgRecordDao.QUEUE_STATUS_RSPSENTERR,
          resp);
    } else {
      String ackMsg =
          "Deferred Patient Discovery response processing halted; deferred queue repository error encountered";

      // Set the error acknowledgement status
      // fatal error with deferred queue repository
      resp = HL7AckTransforms.createAckErrorFrom201305(request, ackMsg);
    }

    // Audit the responding Acknowledgement Message
    ack =
        auditLogger.auditAck(
            resp,
            unsecureRequest.getAssertion(),
            NhincConstants.AUDIT_LOG_OUTBOUND_DIRECTION,
            NhincConstants.AUDIT_LOG_ENTITY_INTERFACE);

    return resp;
  }