import {
  IsInt,
  IsNotEmpty,
  IsObject,
  IsOptional,
  IsString,
  Max,
  MaxLength,
  Min,
} from 'class-validator';

/**
 * Cases are identified by a patient CODE, never a name (section 35).
 * Clinical fields (MR etiology, NYHA, EF, STS, anatomy) live in `meta` so the
 * content team can extend the form without a schema change.
 */
export class CreateCaseDto {
  @IsString()
  @IsNotEmpty()
  @MaxLength(255)
  title!: string;

  @IsOptional()
  @IsString()
  description?: string;

  @IsOptional()
  @IsString()
  @MaxLength(128)
  patientCode?: string;

  @IsOptional()
  @IsInt()
  @Min(0)
  @Max(130)
  age?: number;

  @IsOptional()
  @IsString()
  @MaxLength(16)
  sex?: string;

  @IsOptional()
  @IsObject()
  meta?: Record<string, any>;

  /** Present only for cases a learner creates in the mobile app. */
  @IsOptional()
  @IsString()
  @MaxLength(128)
  anonymousSessionId?: string;
}
