/**
 * ASL模块类型定义
 * 标题摘要初筛 MVP阶段
 */

// ==================== 筛选项目相关 ====================

export interface PicoCriteria {
  population: string;      // P: 研究人群
  intervention: string;    // I: 干预措施
  comparison: string;      // C: 对照
  outcome: string;         // O: 结局指标
  studyDesign: string;     // S: 研究设计类型
}

export interface ScreeningConfig {
  models: string[];        // 使用的模型，如 ["deepseek-chat", "qwen-max"]
  temperature: number;     // 温度参数，建议0
  maxRetries?: number;     // 最大重试次数
}

export interface CreateScreeningProjectDto {
  projectName: string;
  picoCriteria: PicoCriteria;
  inclusionCriteria: string;
  exclusionCriteria: string;
  screeningConfig?: ScreeningConfig;
}

// ==================== 文献相关 ====================

export interface LiteratureDto {
  pmid?: string;
  title: string;
  abstract: string;
  authors?: string;
  journal?: string;
  publicationYear?: number;
  doi?: string;
}

export interface ImportLiteratureDto {
  projectId: string;
  literatures: LiteratureDto[];
}

// ==================== LLM筛选相关 ====================

export interface PicoJudgment {
  P: 'match' | 'partial' | 'mismatch';
  I: 'match' | 'partial' | 'mismatch';
  C: 'match' | 'partial' | 'mismatch';
  S: 'match' | 'partial' | 'mismatch';
}

export interface PicoEvidence {
  P: string;
  I: string;
  C: string;
  S: string;
}

export interface LLMScreeningOutput {
  judgment: PicoJudgment;
  evidence: PicoEvidence;
  conclusion: 'include' | 'exclude' | 'uncertain';
  confidence: number;  // 0-1
  reason: string;
}

export interface DualModelScreeningResult {
  literatureId: string;
  
  // DeepSeek结果
  deepseek: LLMScreeningOutput;
  deepseekModel: string;
  
  // Qwen结果
  qwen: LLMScreeningOutput;
  qwenModel: string;
  
  // 冲突检测
  hasConflict: boolean;
  conflictFields?: string[];  // ['P', 'I', 'conclusion']
  
  // 最终决策（无冲突时自动设置，有冲突时为pending）
  finalDecision?: 'include' | 'exclude' | 'pending';
}

// ==================== 筛选任务相关 ====================

export interface StartScreeningTaskDto {
  projectId: string;
  taskType: 'title_abstract' | 'full_text';
}

export interface ScreeningTaskProgress {
  taskId: string;
  status: 'pending' | 'running' | 'completed' | 'failed';
  totalItems: number;
  processedItems: number;
  successItems: number;
  failedItems: number;
  conflictItems: number;
  estimatedEndAt?: Date;
}

// ==================== 审核工作台相关 ====================

export interface ConflictReviewDto {
  resultId: string;
  finalDecision: 'include' | 'exclude';
  exclusionReason?: string;
}

export interface BatchReviewDto {
  projectId: string;
  reviews: ConflictReviewDto[];
}



