/**
   * This calls the unsecured web service for this method.
   *
   * @param body The message to be sent to the web service.
   * @param assertion The assertion information to go with the message.
   * @return The response from the web service.
   * @throws PatientDiscoveryException
   */
  @AdapterDelegationEvent(
      beforeBuilder = PRPAIN201305UV02EventDescriptionBuilder.class,
      afterReturningBuilder = PRPAIN201306UV02EventDescriptionBuilder.class,
      serviceType = "Patient Discovery",
      version = "1.0")
  public PRPAIN201306UV02 respondingGatewayPRPAIN201305UV02(
      PRPAIN201305UV02 body, AssertionType assertion) throws PatientDiscoveryException {
    String url = null;
    PRPAIN201306UV02 response = new PRPAIN201306UV02();
    String sServiceName = NhincConstants.PATIENT_DISCOVERY_ADAPTER_SERVICE_NAME;

    try {
      if (body != null) {
        LOG.debug("Before target system URL look up.");
        url = oProxyHelper.getAdapterEndPointFromConnectionManager(sServiceName);
        LOG.debug(
            "After target system URL look up. URL for service: " + sServiceName + " is: " + url);

        if (NullChecker.isNotNullish(url)) {
          RespondingGatewayPRPAIN201305UV02RequestType request =
              new RespondingGatewayPRPAIN201305UV02RequestType();
          request.setAssertion(assertion);
          request.setPRPAIN201305UV02(body);
          request.setNhinTargetCommunities(null);

          ServicePortDescriptor<AdapterPatientDiscoveryPortType> portDescriptor =
              new AdapterPatientDiscoveryServicePortDescriptor();
          CONNECTClient<AdapterPatientDiscoveryPortType> client =
              CONNECTClientFactory.getInstance()
                  .getCONNECTClientUnsecured(portDescriptor, url, assertion);

          response =
              (PRPAIN201306UV02)
                  client.invokePort(
                      AdapterPatientDiscoveryPortType.class,
                      "respondingGatewayPRPAIN201305UV02",
                      request);
        } else {
          throw new PatientDiscoveryException(
              "Failed to call the adapter web service (" + sServiceName + ").  The URL is null.");
        }
      } else {
        throw new PatientDiscoveryException(
            "Failed to call the web service (" + sServiceName + ").  The input parameter is null.");
      }
    } catch (Exception e) {
      LOG.error(
          "Failed to call the web service ("
              + sServiceName
              + ").  An unexpected exception occurred.  "
              + "Exception: "
              + e.getMessage(),
          e);
      throw new PatientDiscoveryException(e.fillInStackTrace());
    }

    return response;
  }
  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;
  }