private ims.dto.Result list(boolean loadAllRecords, int maxRecords) {
    DataCollection.clear();

    ims.dto.Result reLoginResult = Connection.reLogin();
    if (reLoginResult != null)
      return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Go_mdt_hcps.List");

    listInProgress = true;
    ims.dto.Result result = Connection.list(serviceName, encodeNASFilter());
    if (result != null) {
      listInProgress = false;
      if (result.getId() == -2) // NAS list empty
      return null;
      return result;
    }

    if (decodeNASMessage() == 0) {
      listInProgress = false;
      return null;
    }

    ims.dto.Result execResult = null;
    while (execResult == null && canContinueToList(loadAllRecords, maxRecords))
      execResult = nextList();

    if (execResult != null) {
      if (execResult.getId() != -3) {
        listInProgress = false;
        return execResult;
      }
    } else // NAS next list empty
    {
      listInProgress = false;
      return null;
    }

    if (!loadAllRecords || !listInProgress) {
      listInProgress = false;
      return Connection.stopList(serviceName);
    }

    listInProgress = false;
    return null;
  }
  // wdev-13343
  public ims.dto.client.Patient getCCODTOPatient(String pkey) throws DomainInterfaceException {
    if (pkey == null) throw new DomainRuntimeException("Cannot get Patient for null pkey");

    ims.dto.client.Patient patient =
        (ims.dto.client.Patient) getDTOInstance(ims.dto.client.Patient.class);
    patient.Filter.clear();
    patient.Filter.Pkey = pkey;

    Result result = patient.get();
    if (result != null) {
      if (result.getId() == -2)
        throw new DomainInterfaceException("Error Getting Patient Details for pkey = " + pkey);

      throw new DomainInterfaceException(result.getMessage());
    }

    if (patient.DataCollection.count() != 1)
      throw new DomainInterfaceException("Failed to get patient record.");

    return patient;
  }