@erosolaraijs/cure 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +321 -26
  2. package/dist/bin/cure.js +114 -1
  3. package/dist/bin/cure.js.map +1 -1
  4. package/dist/capabilities/clinicalTrialMatchingModule.d.ts +150 -0
  5. package/dist/capabilities/clinicalTrialMatchingModule.d.ts.map +1 -0
  6. package/dist/capabilities/clinicalTrialMatchingModule.js +436 -0
  7. package/dist/capabilities/clinicalTrialMatchingModule.js.map +1 -0
  8. package/dist/capabilities/cureValidationFramework.d.ts +195 -0
  9. package/dist/capabilities/cureValidationFramework.d.ts.map +1 -0
  10. package/dist/capabilities/cureValidationFramework.js +577 -0
  11. package/dist/capabilities/cureValidationFramework.js.map +1 -0
  12. package/dist/capabilities/emergencyOncology.d.ts +97 -0
  13. package/dist/capabilities/emergencyOncology.d.ts.map +1 -0
  14. package/dist/capabilities/emergencyOncology.js +1824 -0
  15. package/dist/capabilities/emergencyOncology.js.map +1 -0
  16. package/dist/capabilities/index.d.ts +11 -0
  17. package/dist/capabilities/index.d.ts.map +1 -1
  18. package/dist/capabilities/index.js +22 -0
  19. package/dist/capabilities/index.js.map +1 -1
  20. package/dist/capabilities/multimodalOncologyModule.d.ts +149 -0
  21. package/dist/capabilities/multimodalOncologyModule.d.ts.map +1 -0
  22. package/dist/capabilities/multimodalOncologyModule.js +701 -0
  23. package/dist/capabilities/multimodalOncologyModule.js.map +1 -0
  24. package/dist/capabilities/palliativeCareModule.d.ts +216 -0
  25. package/dist/capabilities/palliativeCareModule.d.ts.map +1 -0
  26. package/dist/capabilities/palliativeCareModule.js +1160 -0
  27. package/dist/capabilities/palliativeCareModule.js.map +1 -0
  28. package/dist/capabilities/precisionMedicineModule.d.ts +151 -0
  29. package/dist/capabilities/precisionMedicineModule.d.ts.map +1 -0
  30. package/dist/capabilities/precisionMedicineModule.js +758 -0
  31. package/dist/capabilities/precisionMedicineModule.js.map +1 -0
  32. package/dist/capabilities/specialPopulationsModule.d.ts +126 -0
  33. package/dist/capabilities/specialPopulationsModule.d.ts.map +1 -0
  34. package/dist/capabilities/specialPopulationsModule.js +574 -0
  35. package/dist/capabilities/specialPopulationsModule.js.map +1 -0
  36. package/dist/capabilities/survivorshipManagement.d.ts +178 -0
  37. package/dist/capabilities/survivorshipManagement.d.ts.map +1 -0
  38. package/dist/capabilities/survivorshipManagement.js +983 -0
  39. package/dist/capabilities/survivorshipManagement.js.map +1 -0
  40. package/dist/capabilities/treatmentSequencing.d.ts +140 -0
  41. package/dist/capabilities/treatmentSequencing.d.ts.map +1 -0
  42. package/dist/capabilities/treatmentSequencing.js +1689 -0
  43. package/dist/capabilities/treatmentSequencing.js.map +1 -0
  44. package/dist/capabilities/universalHealthFramework.d.ts +108 -0
  45. package/dist/capabilities/universalHealthFramework.d.ts.map +1 -0
  46. package/dist/capabilities/universalHealthFramework.js +615 -0
  47. package/dist/capabilities/universalHealthFramework.js.map +1 -0
  48. package/dist/compliance/hipaa.d.ts.map +1 -1
  49. package/dist/compliance/hipaa.js +7 -16
  50. package/dist/compliance/hipaa.js.map +1 -1
  51. package/dist/tools/index.d.ts +31 -0
  52. package/dist/tools/index.d.ts.map +1 -0
  53. package/dist/tools/index.js +1373 -0
  54. package/dist/tools/index.js.map +1 -0
  55. package/package.json +3 -2
  56. package/src/bin/cure.ts +130 -1
  57. package/src/capabilities/clinicalTrialMatchingModule.ts +600 -0
  58. package/src/capabilities/emergencyOncology.ts +1945 -0
  59. package/src/capabilities/index.ts +181 -0
  60. package/src/capabilities/multimodalOncologyModule.ts +873 -0
  61. package/src/capabilities/palliativeCareModule.ts +1438 -0
  62. package/src/capabilities/precisionMedicineModule.ts +952 -0
  63. package/src/capabilities/specialPopulationsModule.ts +711 -0
  64. package/src/capabilities/survivorshipManagement.ts +1213 -0
  65. package/src/capabilities/treatmentSequencing.ts +1878 -0
  66. package/src/capabilities/universalHealthFramework.ts +739 -0
  67. package/src/compliance/hipaa.ts +7 -15
  68. package/src/tools/index.ts +1628 -0
@@ -0,0 +1,600 @@
1
+ /**
2
+ * Clinical Trial Matching Engine
3
+ *
4
+ * ╔═══════════════════════════════════════════════════════════════════════════════╗
5
+ * ║ CLINICAL TRIAL MATCHING - CONNECTING PATIENTS TO NOVEL THERAPIES ║
6
+ * ╠═══════════════════════════════════════════════════════════════════════════════╣
7
+ * ║ This module provides: ║
8
+ * ║ - Biomarker-to-trial mapping ║
9
+ * ║ - Eligibility criteria assessment ║
10
+ * ║ - Trial phase and mechanism matching ║
11
+ * ║ - Geographic and logistical feasibility ║
12
+ * ║ - Basket, umbrella, and platform trial navigation ║
13
+ * ╚═══════════════════════════════════════════════════════════════════════════════╝
14
+ */
15
+
16
+ // ═══════════════════════════════════════════════════════════════════════════════
17
+ // CLINICAL TRIAL DEFINITIONS
18
+ // ═══════════════════════════════════════════════════════════════════════════════
19
+
20
+ export interface ClinicalTrial {
21
+ nctId: string;
22
+ title: string;
23
+ phase: TrialPhase;
24
+ status: TrialStatus;
25
+ trialType: TrialType;
26
+ sponsor: string;
27
+ conditions: string[];
28
+ interventions: TrialIntervention[];
29
+ eligibilityCriteria: EligibilityCriteria;
30
+ locations: TrialLocation[];
31
+ biomarkerRequirements: BiomarkerCriterion[];
32
+ primaryEndpoint: string;
33
+ estimatedEnrollment: number;
34
+ studyStartDate: string;
35
+ estimatedCompletionDate: string;
36
+ }
37
+
38
+ export type TrialPhase = 'Early Phase 1' | 'Phase 1' | 'Phase 1/2' | 'Phase 2' | 'Phase 2/3' | 'Phase 3' | 'Phase 4';
39
+ export type TrialStatus = 'Recruiting' | 'Active, not recruiting' | 'Enrolling by invitation' | 'Not yet recruiting' | 'Completed' | 'Suspended' | 'Terminated' | 'Withdrawn';
40
+ export type TrialType = 'Interventional' | 'Basket' | 'Umbrella' | 'Platform' | 'Expanded Access';
41
+
42
+ export interface TrialIntervention {
43
+ type: 'Drug' | 'Biological' | 'Device' | 'Radiation' | 'Procedure' | 'Combination';
44
+ name: string;
45
+ mechanism: string;
46
+ targetedPathway?: string;
47
+ novelty: 'First-in-class' | 'Next-generation' | 'Combination' | 'New indication';
48
+ }
49
+
50
+ export interface EligibilityCriteria {
51
+ ageRange: { min: number; max: number };
52
+ gender: 'All' | 'Male' | 'Female';
53
+ performanceStatus: { scale: 'ECOG' | 'Karnofsky'; maxValue: number };
54
+ priorTherapyRequirements: PriorTherapyRequirement[];
55
+ organFunctionRequirements: OrganFunctionRequirement[];
56
+ exclusionCriteria: string[];
57
+ inclusionCriteria: string[];
58
+ }
59
+
60
+ export interface PriorTherapyRequirement {
61
+ requirement: 'Required' | 'Allowed' | 'Excluded';
62
+ therapyType: string;
63
+ details: string;
64
+ }
65
+
66
+ export interface OrganFunctionRequirement {
67
+ organ: string;
68
+ parameter: string;
69
+ requirement: string;
70
+ }
71
+
72
+ export interface TrialLocation {
73
+ facility: string;
74
+ city: string;
75
+ state: string;
76
+ country: string;
77
+ status: 'Recruiting' | 'Not yet recruiting' | 'Completed';
78
+ contactName?: string;
79
+ contactPhone?: string;
80
+ contactEmail?: string;
81
+ }
82
+
83
+ export interface BiomarkerCriterion {
84
+ biomarker: string;
85
+ requirement: 'Required' | 'Preferred' | 'Excluded';
86
+ testMethod: string[];
87
+ details?: string;
88
+ }
89
+
90
+ // ═══════════════════════════════════════════════════════════════════════════════
91
+ // TRIAL MATCHING CRITERIA
92
+ // ═══════════════════════════════════════════════════════════════════════════════
93
+
94
+ export interface PatientTrialProfile {
95
+ cancerType: string;
96
+ histology: string;
97
+ stage: string;
98
+ biomarkers: PatientBiomarker[];
99
+ priorTherapies: string[];
100
+ currentLine: number;
101
+ age: number;
102
+ performanceStatus: number;
103
+ organFunction: OrganFunctionStatus;
104
+ location: { country: string; state?: string; city?: string };
105
+ willingToTravel: boolean;
106
+ maxTravelDistance?: number; // miles
107
+ preferences: TrialPreferences;
108
+ }
109
+
110
+ export interface PatientBiomarker {
111
+ name: string;
112
+ status: 'Positive' | 'Negative' | 'Unknown';
113
+ value?: string | number;
114
+ method?: string;
115
+ }
116
+
117
+ export interface OrganFunctionStatus {
118
+ renalFunction: 'Normal' | 'Mild impairment' | 'Moderate impairment' | 'Severe impairment';
119
+ hepaticFunction: 'Normal' | 'Mild impairment' | 'Moderate impairment' | 'Severe impairment';
120
+ cardiacFunction: 'Normal' | 'Reduced' | 'Severely reduced';
121
+ bonemarrowFunction: 'Normal' | 'Reduced';
122
+ }
123
+
124
+ export interface TrialPreferences {
125
+ preferredPhases: TrialPhase[];
126
+ acceptPlaceboArm: boolean;
127
+ preferLocalTrials: boolean;
128
+ interestedMechanisms: string[];
129
+ }
130
+
131
+ export interface TrialMatch {
132
+ trial: ClinicalTrial;
133
+ matchScore: number;
134
+ matchDetails: MatchDetail[];
135
+ eligibilityStatus: 'Likely Eligible' | 'Possibly Eligible' | 'Likely Ineligible' | 'Need More Info';
136
+ barriers: string[];
137
+ nextSteps: string[];
138
+ }
139
+
140
+ export interface MatchDetail {
141
+ criterion: string;
142
+ status: 'Met' | 'Not Met' | 'Partial' | 'Unknown';
143
+ explanation: string;
144
+ }
145
+
146
+ // ═══════════════════════════════════════════════════════════════════════════════
147
+ // TRIAL DATABASE (REPRESENTATIVE EXAMPLES)
148
+ // ═══════════════════════════════════════════════════════════════════════════════
149
+
150
+ export const TRIAL_DATABASE: ClinicalTrial[] = [
151
+ // EGFR-mutant NSCLC Trials
152
+ {
153
+ nctId: 'NCT04816214',
154
+ title: 'Amivantamab + Lazertinib vs Osimertinib in EGFR-Mutant NSCLC (MARIPOSA)',
155
+ phase: 'Phase 3',
156
+ status: 'Active, not recruiting',
157
+ trialType: 'Interventional',
158
+ sponsor: 'Janssen',
159
+ conditions: ['NSCLC', 'EGFR-mutant'],
160
+ interventions: [
161
+ { type: 'Combination', name: 'Amivantamab + Lazertinib', mechanism: 'EGFR-MET bispecific + EGFR TKI', novelty: 'Combination' }
162
+ ],
163
+ eligibilityCriteria: {
164
+ ageRange: { min: 18, max: 99 },
165
+ gender: 'All',
166
+ performanceStatus: { scale: 'ECOG', maxValue: 1 },
167
+ priorTherapyRequirements: [
168
+ { requirement: 'Excluded', therapyType: 'Prior EGFR TKI', details: 'No prior EGFR TKI for metastatic disease' }
169
+ ],
170
+ organFunctionRequirements: [
171
+ { organ: 'Renal', parameter: 'CrCl', requirement: '≥50 mL/min' },
172
+ { organ: 'Hepatic', parameter: 'AST/ALT', requirement: '≤3x ULN' }
173
+ ],
174
+ exclusionCriteria: ['Active brain metastases', 'Prior EGFR TKI', 'Interstitial lung disease'],
175
+ inclusionCriteria: ['EGFR exon 19 del or L858R', 'Metastatic NSCLC', 'Treatment-naive']
176
+ },
177
+ locations: [
178
+ { facility: 'MD Anderson Cancer Center', city: 'Houston', state: 'TX', country: 'USA', status: 'Recruiting' },
179
+ { facility: 'Memorial Sloan Kettering', city: 'New York', state: 'NY', country: 'USA', status: 'Recruiting' }
180
+ ],
181
+ biomarkerRequirements: [
182
+ { biomarker: 'EGFR exon 19 del or L858R', requirement: 'Required', testMethod: ['NGS', 'PCR', 'ctDNA'] }
183
+ ],
184
+ primaryEndpoint: 'Progression-free survival',
185
+ estimatedEnrollment: 1074,
186
+ studyStartDate: '2021-05',
187
+ estimatedCompletionDate: '2025-12'
188
+ },
189
+ // HER2+ Breast Cancer Trials
190
+ {
191
+ nctId: 'NCT04784715',
192
+ title: 'Trastuzumab Deruxtecan vs Physician Choice in HER2-low Breast Cancer (DESTINY-Breast06)',
193
+ phase: 'Phase 3',
194
+ status: 'Recruiting',
195
+ trialType: 'Interventional',
196
+ sponsor: 'Daiichi Sankyo',
197
+ conditions: ['Breast Cancer', 'HER2-low'],
198
+ interventions: [
199
+ { type: 'Biological', name: 'Trastuzumab Deruxtecan', mechanism: 'HER2-directed ADC', novelty: 'New indication' }
200
+ ],
201
+ eligibilityCriteria: {
202
+ ageRange: { min: 18, max: 99 },
203
+ gender: 'All',
204
+ performanceStatus: { scale: 'ECOG', maxValue: 1 },
205
+ priorTherapyRequirements: [
206
+ { requirement: 'Required', therapyType: 'Prior endocrine therapy', details: 'For HR+ patients' },
207
+ { requirement: 'Allowed', therapyType: 'Prior chemotherapy', details: '1-2 prior lines allowed' }
208
+ ],
209
+ organFunctionRequirements: [
210
+ { organ: 'Cardiac', parameter: 'LVEF', requirement: '≥50%' }
211
+ ],
212
+ exclusionCriteria: ['HER2-positive (IHC 3+)', 'History of ILD', 'Uncontrolled brain mets'],
213
+ inclusionCriteria: ['HER2-low (IHC 1+ or 2+/FISH-)', 'HR+ or HR-', 'Metastatic breast cancer']
214
+ },
215
+ locations: [
216
+ { facility: 'Dana-Farber Cancer Institute', city: 'Boston', state: 'MA', country: 'USA', status: 'Recruiting' }
217
+ ],
218
+ biomarkerRequirements: [
219
+ { biomarker: 'HER2-low', requirement: 'Required', testMethod: ['IHC', 'FISH'] }
220
+ ],
221
+ primaryEndpoint: 'Progression-free survival',
222
+ estimatedEnrollment: 850,
223
+ studyStartDate: '2021-03',
224
+ estimatedCompletionDate: '2026-06'
225
+ },
226
+ // KRAS G12C Trials
227
+ {
228
+ nctId: 'NCT04685135',
229
+ title: 'Sotorasib + Anti-EGFR in KRAS G12C CRC (CodeBreaK 300)',
230
+ phase: 'Phase 3',
231
+ status: 'Recruiting',
232
+ trialType: 'Interventional',
233
+ sponsor: 'Amgen',
234
+ conditions: ['Colorectal Cancer', 'KRAS G12C'],
235
+ interventions: [
236
+ { type: 'Combination', name: 'Sotorasib + Panitumumab', mechanism: 'KRAS G12C inhibitor + anti-EGFR', novelty: 'Combination' }
237
+ ],
238
+ eligibilityCriteria: {
239
+ ageRange: { min: 18, max: 99 },
240
+ gender: 'All',
241
+ performanceStatus: { scale: 'ECOG', maxValue: 1 },
242
+ priorTherapyRequirements: [
243
+ { requirement: 'Required', therapyType: 'Prior chemotherapy', details: '1-2 prior lines for metastatic disease' }
244
+ ],
245
+ organFunctionRequirements: [],
246
+ exclusionCriteria: ['Prior KRAS G12C inhibitor', 'Symptomatic brain mets'],
247
+ inclusionCriteria: ['KRAS G12C mutation', 'Metastatic CRC', 'Prior fluoropyrimidine, oxaliplatin, irinotecan']
248
+ },
249
+ locations: [
250
+ { facility: 'Multiple sites', city: 'Various', state: 'Various', country: 'USA', status: 'Recruiting' }
251
+ ],
252
+ biomarkerRequirements: [
253
+ { biomarker: 'KRAS G12C', requirement: 'Required', testMethod: ['NGS', 'PCR'] }
254
+ ],
255
+ primaryEndpoint: 'Overall survival',
256
+ estimatedEnrollment: 160,
257
+ studyStartDate: '2021-01',
258
+ estimatedCompletionDate: '2025-06'
259
+ },
260
+ // Basket Trial Example
261
+ {
262
+ nctId: 'NCT02465060',
263
+ title: 'NCI-MATCH: Targeted Therapy Directed by Genetic Testing (Basket Trial)',
264
+ phase: 'Phase 2',
265
+ status: 'Active, not recruiting',
266
+ trialType: 'Basket',
267
+ sponsor: 'NCI',
268
+ conditions: ['Solid Tumors', 'Lymphoma'],
269
+ interventions: [
270
+ { type: 'Drug', name: 'Multiple targeted agents', mechanism: 'Various - based on molecular alteration', novelty: 'First-in-class' }
271
+ ],
272
+ eligibilityCriteria: {
273
+ ageRange: { min: 18, max: 99 },
274
+ gender: 'All',
275
+ performanceStatus: { scale: 'ECOG', maxValue: 1 },
276
+ priorTherapyRequirements: [
277
+ { requirement: 'Required', therapyType: 'Prior standard therapy', details: 'Progressed on standard options' }
278
+ ],
279
+ organFunctionRequirements: [],
280
+ exclusionCriteria: ['Matched targeted therapy previously received'],
281
+ inclusionCriteria: ['Actionable genomic alteration', 'No standard treatment options']
282
+ },
283
+ locations: [
284
+ { facility: 'ECOG-ACRIN Network Sites', city: 'Multiple', state: 'Multiple', country: 'USA', status: 'Recruiting' }
285
+ ],
286
+ biomarkerRequirements: [
287
+ { biomarker: 'Actionable mutation per NCI-MATCH arms', requirement: 'Required', testMethod: ['NGS'] }
288
+ ],
289
+ primaryEndpoint: 'Overall response rate',
290
+ estimatedEnrollment: 6000,
291
+ studyStartDate: '2015-08',
292
+ estimatedCompletionDate: '2025-12'
293
+ },
294
+ // Immunotherapy Combination
295
+ {
296
+ nctId: 'NCT03899610',
297
+ title: 'Nivolumab + Relatlimab vs Nivolumab in Melanoma (RELATIVITY-047)',
298
+ phase: 'Phase 3',
299
+ status: 'Active, not recruiting',
300
+ trialType: 'Interventional',
301
+ sponsor: 'Bristol-Myers Squibb',
302
+ conditions: ['Melanoma'],
303
+ interventions: [
304
+ { type: 'Combination', name: 'Nivolumab + Relatlimab', mechanism: 'Anti-PD-1 + Anti-LAG-3', novelty: 'First-in-class' }
305
+ ],
306
+ eligibilityCriteria: {
307
+ ageRange: { min: 18, max: 99 },
308
+ gender: 'All',
309
+ performanceStatus: { scale: 'ECOG', maxValue: 1 },
310
+ priorTherapyRequirements: [
311
+ { requirement: 'Excluded', therapyType: 'Prior anti-PD-1/PD-L1', details: 'No prior checkpoint inhibitor' }
312
+ ],
313
+ organFunctionRequirements: [],
314
+ exclusionCriteria: ['Active autoimmune disease', 'Prior immunotherapy'],
315
+ inclusionCriteria: ['Unresectable or metastatic melanoma', 'Treatment-naive for metastatic disease']
316
+ },
317
+ locations: [
318
+ { facility: 'Multiple sites', city: 'Various', state: 'Various', country: 'USA', status: 'Recruiting' }
319
+ ],
320
+ biomarkerRequirements: [],
321
+ primaryEndpoint: 'Progression-free survival',
322
+ estimatedEnrollment: 714,
323
+ studyStartDate: '2019-04',
324
+ estimatedCompletionDate: '2024-12'
325
+ },
326
+ // CAR-T Trial
327
+ {
328
+ nctId: 'NCT04503278',
329
+ title: 'Cilta-cel vs Standard of Care in Multiple Myeloma (CARTITUDE-4)',
330
+ phase: 'Phase 3',
331
+ status: 'Active, not recruiting',
332
+ trialType: 'Interventional',
333
+ sponsor: 'Janssen',
334
+ conditions: ['Multiple Myeloma'],
335
+ interventions: [
336
+ { type: 'Biological', name: 'Ciltacabtagene autoleucel (Cilta-cel)', mechanism: 'BCMA-directed CAR-T', novelty: 'Next-generation' }
337
+ ],
338
+ eligibilityCriteria: {
339
+ ageRange: { min: 18, max: 99 },
340
+ gender: 'All',
341
+ performanceStatus: { scale: 'ECOG', maxValue: 1 },
342
+ priorTherapyRequirements: [
343
+ { requirement: 'Required', therapyType: 'Prior lenalidomide and PI', details: '1-3 prior lines including lenalidomide and a PI' }
344
+ ],
345
+ organFunctionRequirements: [
346
+ { organ: 'Cardiac', parameter: 'LVEF', requirement: '≥45%' },
347
+ { organ: 'Pulmonary', parameter: 'O2 sat', requirement: '≥92% on room air' }
348
+ ],
349
+ exclusionCriteria: ['Prior BCMA-targeted therapy', 'Active CNS involvement', 'Uncontrolled infection'],
350
+ inclusionCriteria: ['Relapsed/refractory MM', 'Lenalidomide-refractory', '1-3 prior lines']
351
+ },
352
+ locations: [
353
+ { facility: 'Multiple academic centers', city: 'Various', state: 'Various', country: 'USA', status: 'Recruiting' }
354
+ ],
355
+ biomarkerRequirements: [],
356
+ primaryEndpoint: 'Progression-free survival',
357
+ estimatedEnrollment: 400,
358
+ studyStartDate: '2020-06',
359
+ estimatedCompletionDate: '2026-01'
360
+ },
361
+ // Pediatric Trial
362
+ {
363
+ nctId: 'NCT03155620',
364
+ title: 'Larotrectinib in Pediatric Solid Tumors with NTRK Fusion (SCOUT)',
365
+ phase: 'Phase 1/2',
366
+ status: 'Recruiting',
367
+ trialType: 'Basket',
368
+ sponsor: 'Bayer',
369
+ conditions: ['Pediatric Solid Tumors', 'NTRK Fusion'],
370
+ interventions: [
371
+ { type: 'Drug', name: 'Larotrectinib', mechanism: 'TRK inhibitor', novelty: 'First-in-class' }
372
+ ],
373
+ eligibilityCriteria: {
374
+ ageRange: { min: 0, max: 21 },
375
+ gender: 'All',
376
+ performanceStatus: { scale: 'Karnofsky', maxValue: 50 },
377
+ priorTherapyRequirements: [
378
+ { requirement: 'Allowed', therapyType: 'Prior therapy', details: 'No limit on prior therapies' }
379
+ ],
380
+ organFunctionRequirements: [],
381
+ exclusionCriteria: ['Prior TRK inhibitor', 'Primary CNS tumor'],
382
+ inclusionCriteria: ['NTRK gene fusion', 'Relapsed or refractory solid tumor', 'Age ≤21']
383
+ },
384
+ locations: [
385
+ { facility: "Children's Hospital of Philadelphia", city: 'Philadelphia', state: 'PA', country: 'USA', status: 'Recruiting' },
386
+ { facility: 'Texas Childrens Hospital', city: 'Houston', state: 'TX', country: 'USA', status: 'Recruiting' }
387
+ ],
388
+ biomarkerRequirements: [
389
+ { biomarker: 'NTRK1/2/3 fusion', requirement: 'Required', testMethod: ['NGS', 'FISH', 'IHC'] }
390
+ ],
391
+ primaryEndpoint: 'Overall response rate',
392
+ estimatedEnrollment: 150,
393
+ studyStartDate: '2017-07',
394
+ estimatedCompletionDate: '2025-12'
395
+ }
396
+ ];
397
+
398
+ // ═══════════════════════════════════════════════════════════════════════════════
399
+ // TRIAL MATCHING ENGINE
400
+ // ═══════════════════════════════════════════════════════════════════════════════
401
+
402
+ export class ClinicalTrialMatchingEngine {
403
+ private trials: ClinicalTrial[] = TRIAL_DATABASE;
404
+
405
+ findMatchingTrials(patient: PatientTrialProfile): TrialMatch[] {
406
+ const matches: TrialMatch[] = [];
407
+
408
+ for (const trial of this.trials) {
409
+ if (trial.status === 'Withdrawn' || trial.status === 'Terminated') continue;
410
+
411
+ const matchResult = this.evaluateTrialMatch(patient, trial);
412
+ if (matchResult.matchScore > 0) {
413
+ matches.push(matchResult);
414
+ }
415
+ }
416
+
417
+ return matches.sort((a, b) => b.matchScore - a.matchScore);
418
+ }
419
+
420
+ private evaluateTrialMatch(patient: PatientTrialProfile, trial: ClinicalTrial): TrialMatch {
421
+ const matchDetails: MatchDetail[] = [];
422
+ const barriers: string[] = [];
423
+ let score = 0;
424
+
425
+ // Check cancer type match
426
+ const cancerMatch = trial.conditions.some(c =>
427
+ c.toLowerCase().includes(patient.cancerType.toLowerCase()) ||
428
+ patient.cancerType.toLowerCase().includes(c.toLowerCase())
429
+ );
430
+ if (cancerMatch) {
431
+ score += 30;
432
+ matchDetails.push({ criterion: 'Cancer type', status: 'Met', explanation: 'Cancer type matches trial conditions' });
433
+ } else {
434
+ matchDetails.push({ criterion: 'Cancer type', status: 'Not Met', explanation: 'Cancer type does not match' });
435
+ }
436
+
437
+ // Check biomarker requirements
438
+ for (const bioReq of trial.biomarkerRequirements) {
439
+ const patientBiomarker = patient.biomarkers.find(b =>
440
+ b.name.toLowerCase().includes(bioReq.biomarker.toLowerCase()) ||
441
+ bioReq.biomarker.toLowerCase().includes(b.name.toLowerCase())
442
+ );
443
+
444
+ if (bioReq.requirement === 'Required') {
445
+ if (patientBiomarker?.status === 'Positive') {
446
+ score += 25;
447
+ matchDetails.push({ criterion: `Biomarker: ${bioReq.biomarker}`, status: 'Met', explanation: 'Required biomarker is positive' });
448
+ } else if (patientBiomarker?.status === 'Negative') {
449
+ score -= 50;
450
+ barriers.push(`Required biomarker ${bioReq.biomarker} is negative`);
451
+ matchDetails.push({ criterion: `Biomarker: ${bioReq.biomarker}`, status: 'Not Met', explanation: 'Required biomarker is negative' });
452
+ } else {
453
+ matchDetails.push({ criterion: `Biomarker: ${bioReq.biomarker}`, status: 'Unknown', explanation: 'Biomarker status not tested' });
454
+ }
455
+ } else if (bioReq.requirement === 'Excluded') {
456
+ if (patientBiomarker?.status === 'Positive') {
457
+ score -= 50;
458
+ barriers.push(`Excluded biomarker ${bioReq.biomarker} is positive`);
459
+ matchDetails.push({ criterion: `Biomarker: ${bioReq.biomarker}`, status: 'Not Met', explanation: 'Excluded biomarker is positive' });
460
+ }
461
+ }
462
+ }
463
+
464
+ // Check age eligibility
465
+ const ageElig = trial.eligibilityCriteria.ageRange;
466
+ if (patient.age >= ageElig.min && patient.age <= ageElig.max) {
467
+ score += 10;
468
+ matchDetails.push({ criterion: 'Age', status: 'Met', explanation: `Age ${patient.age} within range ${ageElig.min}-${ageElig.max}` });
469
+ } else {
470
+ barriers.push(`Age ${patient.age} outside eligible range ${ageElig.min}-${ageElig.max}`);
471
+ matchDetails.push({ criterion: 'Age', status: 'Not Met', explanation: 'Age outside eligible range' });
472
+ }
473
+
474
+ // Check performance status
475
+ const psReq = trial.eligibilityCriteria.performanceStatus;
476
+ if (patient.performanceStatus <= psReq.maxValue) {
477
+ score += 10;
478
+ matchDetails.push({ criterion: 'Performance status', status: 'Met', explanation: `PS ${patient.performanceStatus} meets requirement ≤${psReq.maxValue}` });
479
+ } else {
480
+ barriers.push(`Performance status ${patient.performanceStatus} exceeds maximum ${psReq.maxValue}`);
481
+ matchDetails.push({ criterion: 'Performance status', status: 'Not Met', explanation: 'Performance status too high' });
482
+ }
483
+
484
+ // Check phase preference
485
+ if (patient.preferences.preferredPhases.includes(trial.phase)) {
486
+ score += 5;
487
+ }
488
+
489
+ // Check location
490
+ const matchingLocation = trial.locations.find(loc =>
491
+ loc.country === patient.location.country &&
492
+ loc.status === 'Recruiting'
493
+ );
494
+ if (matchingLocation) {
495
+ score += 10;
496
+ matchDetails.push({ criterion: 'Location', status: 'Met', explanation: `Trial available in ${matchingLocation.city}, ${matchingLocation.state}` });
497
+ } else if (patient.willingToTravel) {
498
+ score += 5;
499
+ matchDetails.push({ criterion: 'Location', status: 'Partial', explanation: 'Patient willing to travel' });
500
+ } else {
501
+ barriers.push('No recruiting sites in patient location');
502
+ matchDetails.push({ criterion: 'Location', status: 'Not Met', explanation: 'No local sites; travel required' });
503
+ }
504
+
505
+ // Determine eligibility status
506
+ let eligibilityStatus: TrialMatch['eligibilityStatus'];
507
+ if (barriers.length === 0 && score > 50) {
508
+ eligibilityStatus = 'Likely Eligible';
509
+ } else if (barriers.length === 0) {
510
+ eligibilityStatus = 'Need More Info';
511
+ } else if (barriers.some(b => b.includes('Required biomarker') || b.includes('Age'))) {
512
+ eligibilityStatus = 'Likely Ineligible';
513
+ } else {
514
+ eligibilityStatus = 'Possibly Eligible';
515
+ }
516
+
517
+ // Generate next steps
518
+ const nextSteps: string[] = [];
519
+ if (eligibilityStatus === 'Likely Eligible' || eligibilityStatus === 'Possibly Eligible') {
520
+ nextSteps.push('Discuss with oncologist');
521
+ nextSteps.push(`Contact trial site: ${trial.locations[0]?.facility || 'See ClinicalTrials.gov'}`);
522
+ nextSteps.push(`Search ClinicalTrials.gov for NCT: ${trial.nctId}`);
523
+ }
524
+ if (matchDetails.some(m => m.status === 'Unknown')) {
525
+ nextSteps.push('Complete biomarker testing');
526
+ }
527
+
528
+ return {
529
+ trial,
530
+ matchScore: Math.max(0, score),
531
+ matchDetails,
532
+ eligibilityStatus,
533
+ barriers,
534
+ nextSteps
535
+ };
536
+ }
537
+
538
+ findTrialsByBiomarker(biomarker: string): ClinicalTrial[] {
539
+ return this.trials.filter(trial =>
540
+ trial.biomarkerRequirements.some(b =>
541
+ b.biomarker.toLowerCase().includes(biomarker.toLowerCase())
542
+ )
543
+ );
544
+ }
545
+
546
+ findTrialsByMechanism(mechanism: string): ClinicalTrial[] {
547
+ return this.trials.filter(trial =>
548
+ trial.interventions.some(i =>
549
+ i.mechanism.toLowerCase().includes(mechanism.toLowerCase())
550
+ )
551
+ );
552
+ }
553
+
554
+ findBasketTrials(): ClinicalTrial[] {
555
+ return this.trials.filter(trial => trial.trialType === 'Basket');
556
+ }
557
+
558
+ findPediatricTrials(): ClinicalTrial[] {
559
+ return this.trials.filter(trial =>
560
+ trial.eligibilityCriteria.ageRange.min < 18 ||
561
+ trial.conditions.some(c => c.toLowerCase().includes('pediatric'))
562
+ );
563
+ }
564
+
565
+ getTrialById(nctId: string): ClinicalTrial | undefined {
566
+ return this.trials.find(t => t.nctId === nctId);
567
+ }
568
+
569
+ generateTrialSearchStrategy(patient: PatientTrialProfile): {
570
+ searchTerms: string[];
571
+ recommendedDatabases: string[];
572
+ searchTips: string[];
573
+ } {
574
+ const searchTerms: string[] = [
575
+ patient.cancerType,
576
+ patient.histology,
577
+ ...patient.biomarkers.filter(b => b.status === 'Positive').map(b => b.name)
578
+ ];
579
+
580
+ return {
581
+ searchTerms,
582
+ recommendedDatabases: [
583
+ 'ClinicalTrials.gov (clinicaltrials.gov)',
584
+ 'NCI Cancer Clinical Trials (cancer.gov/clinicaltrials)',
585
+ 'TrialMatch (lls.org/support/information-specialists)',
586
+ 'EmergingMed Navigator (emergingmed.com)'
587
+ ],
588
+ searchTips: [
589
+ 'Use condition + biomarker for targeted searches',
590
+ 'Filter by "Recruiting" status',
591
+ 'Check Phase 1/2 trials for novel mechanisms',
592
+ 'Consider basket trials if you have an actionable mutation',
593
+ 'Contact trial coordinators directly for eligibility questions'
594
+ ]
595
+ };
596
+ }
597
+ }
598
+
599
+ // Export singleton
600
+ export const clinicalTrialMatchingEngine = new ClinicalTrialMatchingEngine();