import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { EmptyStringToUndefined } from '../../common/transforms/empty-string-to-undefined.transform.js';
import { IsInt, IsOptional, IsString, Max, Min } from 'class-validator';

export class PatientQueryDto {
  @ApiPropertyOptional({
    description: '患者名称、手机号、住院号、医生、医院或手术名称关键字',
    example: 'VPS',
  })
  @IsOptional()
  @IsString({ message: 'keyword 必须为字符串' })
  keyword?: string;

  @ApiPropertyOptional({ description: '医院编号', example: 1 })
  @IsOptional()
  @EmptyStringToUndefined()
  @Type(() => Number)
  @IsInt({ message: 'hospitalId 必须为整数' })
  @Min(1, { message: 'hospitalId 必须大于 0' })
  hospitalId?: number;

  @ApiPropertyOptional({ description: '医生编号', example: 1 })
  @IsOptional()
  @EmptyStringToUndefined()
  @Type(() => Number)
  @IsInt({ message: 'doctorId 必须为整数' })
  @Min(1, { message: 'doctorId 必须大于 0' })
  doctorId?: number;

  @ApiPropertyOptional({ description: '页码', example: 1, default: 1 })
  @IsOptional()
  @EmptyStringToUndefined()
  @Type(() => Number)
  @IsInt({ message: 'page 必须为整数' })
  @Min(1, { message: 'page 最小值为 1' })
  page?: number = 1;

  @ApiPropertyOptional({
    description: '每页条数',
    example: 20,
    default: 20,
  })
  @IsOptional()
  @EmptyStringToUndefined()
  @Type(() => Number)
  @IsInt({ message: 'pageSize 必须为整数' })
  @Min(1, { message: 'pageSize 最小值为 1' })
  @Max(100, { message: 'pageSize 最大值为 100' })
  pageSize?: number = 20;
}
