/** * Retrospective Validation Framework * * Provides tools for validating the treatment recommendation system against * real patient outcomes. Essential for: * - Model performance assessment * - Calibration checking * - Concordance analysis with actual treatments * - Outcome correlation studies * - Continuous quality improvement * * IMPORTANT: All patient data used for validation must be properly de-identified * or used with appropriate IRB approval and patient consent. */ import { EventEmitter } from 'events'; export interface ValidationPatient { id: string; demographics: { ageAtDiagnosis: number; gender: 'male' | 'female'; ethnicity?: string; }; diagnosis: { cancerType: string; histology?: string; stage: string; diagnosisDate: Date; biomarkers?: { name: string; value: string | number; status?: string; }[]; genomicAlterations?: { gene: string; alteration: string; }[]; msiStatus?: 'MSI-H' | 'MSI-L' | 'MSS'; tmbValue?: number; pdl1Score?: number; hrdStatus?: boolean; }; treatment: { regimen: string; drugs: string[]; setting: string; startDate: Date; endDate?: Date; cycles?: number; doseModifications?: boolean; }; outcomes: { bestResponse?: 'CR' | 'PR' | 'SD' | 'PD' | 'NE'; responseDate?: Date; progressionDate?: Date; deathDate?: Date; lastFollowUpDate: Date; causeOfDeath?: 'disease' | 'treatment' | 'other' | 'unknown'; toxicities?: { name: string; grade: number; date?: Date; }[]; }; ecogAtBaseline?: number; priorLines?: number; } export interface SystemRecommendation { patientId: string; recommendedRegimen: string; recommendedDrugs: string[]; predictions: { responseRate: number; pfsMonths: number; osMonths: number; toxicityRisk: number; }; matchingBiomarkers: string[]; confidenceScore: number; timestamp: Date; } export interface ValidationResult { patientId: string; concordance: { regimenMatch: boolean; partialMatch: boolean; matchedDrugs: string[]; }; outcomeComparison: { predictedResponse: number; actualResponse?: 'CR' | 'PR' | 'SD' | 'PD' | 'NE'; responseCorrect?: boolean; predictedPFS: number; actualPFS?: number; pfsDifference?: number; predictedOS: number; actualOS?: number; osDifference?: number; predictedToxicityRisk: number; actualGrade3PlusToxicity: boolean; }; clinicalBenefit: { objectiveResponse: boolean; diseaseControl: boolean; durableBenefit: boolean; }; } export interface CohortAnalysis { cohortId: string; description: string; patientCount: number; dateRange: { start: Date; end: Date; }; demographics: { medianAge: number; ageRange: [number, number]; genderDistribution: { male: number; female: number; }; stageDistribution: Record; }; concordance: { fullConcordance: number; partialConcordance: number; noConcordance: number; concordanceByBiomarker: Record; }; predictionAccuracy: { responseAccuracy: number; responseSensitivity: number; responseSpecificity: number; responseAUC?: number; pfsCIndex: number; pfsCalibration: number; osCIndex: number; osCalibration: number; toxicityAccuracy: number; toxicityAUC?: number; }; clinicalImpact: { objectiveResponseRate: number; diseaseControlRate: number; medianPFS: number; medianOS: number; concordantVsDiscordant: { concordantORR: number; discordantORR: number; concordantMedianPFS: number; discordantMedianPFS: number; pValue?: number; }; }; subgroupAnalyses: { subgroup: string; patientCount: number; concordance: number; responseAccuracy: number; medianPFS: number; }[]; } export declare class RetrospectiveValidationService extends EventEmitter { private validationCohorts; private systemRecommendations; private validationResults; constructor(); /** * Load a validation cohort */ loadCohort(cohortId: string, patients: ValidationPatient[]): void; /** * Load system recommendations for comparison */ loadRecommendations(recommendations: SystemRecommendation[]): void; /** * Run validation for a cohort */ runValidation(cohortId: string): Promise; /** * Validate a single patient */ private validatePatient; /** * Assess concordance between recommendation and actual treatment */ private assessConcordance; /** * Check if two drug names refer to the same drug */ private drugsMatch; /** * Calculate PFS in months */ private calculatePFS; /** * Calculate OS in months */ private calculateOS; /** * Assess if response prediction was accurate */ private assessResponseAccuracy; /** * Compute cohort-level analysis */ private computeCohortAnalysis; /** * Calculate concordance index (C-index) */ private calculateCIndex; /** * Calculate calibration score (0-1, higher is better) */ private calculateCalibration; /** * Calculate median of an array */ private calculateMedian; /** * Calculate concordance by biomarker subgroup */ private calculateConcordanceByBiomarker; /** * Perform subgroup analyses */ private performSubgroupAnalyses; /** * Calculate response accuracy for a subgroup */ private calculateSubgroupResponseAccuracy; /** * Validate and de-identify patient data */ private validateAndDeidentify; /** * Generate validation report */ generateReport(analysis: CohortAnalysis): string; /** * Export validation results */ exportResults(cohortId: string, format: 'json' | 'csv'): string; } export default RetrospectiveValidationService; //# sourceMappingURL=retrospectiveValidator.d.ts.map