/**
   * Returns the number of records using the specified filter. This method always returns a non null
   * result. The ID field holds the count result (when greater or equal to zero) or the error number
   * (when less than zero).
   */
  public ims.dto.Result count() {
    ims.dto.Result reLoginResult = Connection.reLogin();
    if (reLoginResult != null)
      return new ims.dto.Result(reLoginResult.getMessage(), "DTO.Client.Go_mdt_hcps.Count");

    int result = Connection.count(serviceName, encodeNASFilter());
    if (result >= 0)
      return new ims.dto.Result(
          result,
          "No error detected. The count result is held in the ID field",
          "DTO.Client.Go_mdt_hcps.Count");

    return Connection.getLastError();
  }