export interface RoleQuery {
  roleName?: string;
  status?: RoleModel['status'];
}

export interface RoleModel {
  roleId: string;
  roleName: string;
  status: '0' | '1';

  createTime: string;
  createBy: string;
  updateTime: string;
  updateBy: string;

  roleSort?: number;
  menuIds?: string[];
}

export interface UserModel {
  userId: string;
  userName: string;
  nickName?: string;
  phonenumber?: string;
  jobnumber?: string;

  roles?: any[];
  dept?: Record<string, any>;

  appletImg: string;
}

export type UserQuery = Partial<UserModel> & { branch?: string };

export interface TagQuery {
  tagId?: string;
  name?: string;
  status?: '0' | '1';
  types?: ('1' | '2')[];

  parentId?: string;
  parentIds?: string[] | string;
}

export interface TagModel {
  id: string;
  name: string;
  status: '0' | '1';
  type: '1' | '2';
  category: string;
  tagId?: string;
  parentId?: string;
  parentName?: string;

  disabled?: boolean;
  editable?: boolean;
  deletable?: boolean;
}

export function fromTag(data: Record<string, any>): TagModel {
  return Object.assign(data, {
    updateTime: data.updateTime ?? data.createTime,
    category: {1: '系统标签', 2: '个人标签'}[data.type as number],
    editable: data.isEdit?.toUpperCase() === 'Y',
    deletable: (data.isDelete ?? data.isEdit)?.toUpperCase() === 'Y',
    parentId: data.parentId === 0 ? void 0 : data.parentId,
    disabled: data.status === '1',
  }) as unknown as TagModel;
}

export interface PlanModel {
  id: string;
  name: string;
  department: string; //科室
  frequency?: number;
  institutions: string; //机构
  founder: string; //创建人
  time: string; //创建时间
  patient: string; //筛选病人
  progress: '0' | '1' | '2'; //计划状态
  status: '0' | '1'; //启用状态
  label?: string;
  enabled: boolean;
  tagIds: string[] | string;
  filter: {
    tagId:string;
    tagIds: string[] | string;
    tagNames: string[] | string;
    departments: string[] | string;
    doctors: string[] | string;
  };
}

export type PlanQuery = Partial<PlanModel>;

export interface OrganizationModel {
  id: string; //组织id
  name: string; //组织名称
  appId: string; //小程序id
  appSecret: string; //小程序密钥
  insId: string; //机构id
  insName: string; //机构名称
  createTime: string; //创建时间
  createBy: string; //创建人
  remark: string; //备注
}

export type OrganizationQuery = Partial<OrganizationModel>;

export interface InstitutionModel {
  id: string; //机构id
  name: string; //机构名称
  orgId:string; //组织id
  orgName:string; //组织名称
  parentId: string; //上级机构id
  parentName: string; //上级机构名称
  status:string; //状态
  createTime: string; //创建时间
  createBy: string; //创建人
}

export type InstitutionQuery = Partial<InstitutionModel>;