import { ApiProperty } from '@nestjs/swagger';
import { Role } from '../../generated/prisma/enums.js';

export class CPatientMeFamilyAccountDto {
  @ApiProperty({ description: 'C 端账号 ID', example: 1 })
  id!: number;

  @ApiProperty({ description: '当前登录手机号', example: '13800002002' })
  phone!: string;

  @ApiProperty({
    description: '微信 openId',
    example: 'oAbcDefGhIjKlMn',
    nullable: true,
    type: String,
  })
  openId!: string | null;

  @ApiProperty({
    description: '客服体系用户标识',
    example: null,
    nullable: true,
    type: String,
  })
  serviceUid!: string | null;

  @ApiProperty({
    description: '最近登录时间',
    example: '2026-04-02T08:00:00.000Z',
    format: 'date-time',
  })
  lastLoginAt!: string;
}

export class CPatientMeHospitalDto {
  @ApiProperty({ description: '医院 ID', example: 1 })
  id!: number;

  @ApiProperty({ description: '医院名称', example: '珠江医院' })
  name!: string;
}

export class CPatientMeDoctorDto {
  @ApiProperty({ description: '归属医生 ID', example: 10001 })
  id!: number;

  @ApiProperty({ description: '归属医生姓名', example: '张医生' })
  name!: string;

  @ApiProperty({ description: '归属医生角色', enum: Role })
  role!: Role;
}

export class CPatientMePatientDto {
  @ApiProperty({ description: '患者 ID', example: 8 })
  id!: number;

  @ApiProperty({ description: '患者姓名', example: '张三' })
  name!: string;

  @ApiProperty({ description: '患者手机号', example: '13800002002' })
  phone!: string;

  @ApiProperty({ description: '患者身份证号', example: '440102199901010011' })
  idCard!: string;

  @ApiProperty({
    description: '住院号',
    example: 'ZY20260402001',
    nullable: true,
    type: String,
  })
  inpatientNo!: string | null;

  @ApiProperty({
    description: '项目名称',
    example: '脑积水随访项目',
    nullable: true,
    type: String,
  })
  projectName!: string | null;

  @ApiProperty({ description: '所属医院 ID', example: 1 })
  hospitalId!: number;

  @ApiProperty({ description: '归属医生 ID', example: 10001 })
  doctorId!: number;

  @ApiProperty({
    description: '建档时间',
    example: '2026-04-02T08:00:00.000Z',
    format: 'date-time',
  })
  createdAt!: string;

  @ApiProperty({ description: '所属医院', type: CPatientMeHospitalDto })
  hospital!: CPatientMeHospitalDto;

  @ApiProperty({ description: '归属医生', type: CPatientMeDoctorDto })
  doctor!: CPatientMeDoctorDto;
}

export class CPatientMeDataDto {
  @ApiProperty({
    description: '当前登录的 C 端账号信息',
    type: CPatientMeFamilyAccountDto,
  })
  familyAccount!: CPatientMeFamilyAccountDto;

  @ApiProperty({
    description: '当前手机号唯一命中的患者档案',
    type: CPatientMePatientDto,
  })
  patient!: CPatientMePatientDto;
}

export class CPatientMeResponseDto {
  @ApiProperty({ description: '业务状态码', example: 0 })
  code!: number;

  @ApiProperty({ description: '响应消息', example: '成功' })
  msg!: string;

  @ApiProperty({ description: '当前登录患者信息', type: CPatientMeDataDto })
  data!: CPatientMeDataDto;
}
