@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,1373 @@
1
+ import { UniversalCancerCureEngine } from '../capabilities/universalCancerCureEngine.js';
2
+ import { TreatmentSequencingEngine } from '../capabilities/treatmentSequencing.js';
3
+ import { SpecialPopulationsEngine } from '../capabilities/specialPopulationsModule.js';
4
+ import { GlobalCancerCoverageModule } from '../capabilities/globalCancerCoverage.js';
5
+ import { UniversalHealthEngine } from '../capabilities/universalHealthFramework.js';
6
+ import { PrecisionMedicineEngine } from '../capabilities/precisionMedicineModule.js';
7
+ import { CureValidationFramework } from '../capabilities/cureValidationFramework.js';
8
+ import { PalliativeCareEngine } from '../capabilities/palliativeCareModule.js';
9
+ import { EmergencyOncologyEngine } from '../capabilities/emergencyOncology.js';
10
+ import { SurvivorshipCareEngine } from '../capabilities/survivorshipManagement.js';
11
+ import { MultimodalOncologyEngine } from '../capabilities/multimodalOncologyModule.js';
12
+ import { ResistanceManagementEngine, CureVerificationEngine } from '../capabilities/resistanceManagement.js';
13
+ import { ClinicalTrialMatchingEngine } from '../capabilities/clinicalTrialMatchingModule.js';
14
+ import { EmergingTherapeuticsModule } from '../capabilities/emergingTherapeutics.js';
15
+ import { RetrospectiveValidationService } from '../validation/index.js';
16
+ import { createRealWorldOncologyService } from '../orchestrator/realWorldOncology.js';
17
+ import { OutcomePredictorService } from '../ml/outcomePredictor.js';
18
+ import { DrugSafetyService } from '../safety/drugInteractions.js';
19
+ import { HIPAAComplianceService } from '../compliance/hipaa.js';
20
+ import { ClinicalDecisionSupportService } from '../clinician/decisionSupport.js';
21
+ import { PatientPortalService } from '../patient/patientPortal.js';
22
+ import { UnifiedGenomicsService, GenomicPlatformClient } from '../integrations/genomics/genomicPlatforms.js';
23
+ const SAMPLE_PATIENT_ID = 'TOOL-001';
24
+ const SAMPLE_CANCER_TYPE = 'NSCLC';
25
+ const SAMPLE_STAGE = 'IV';
26
+ function formatPercent(value) {
27
+ return `${(value * 100).toFixed(1)}%`;
28
+ }
29
+ function formatNumber(value) {
30
+ return Math.round(value * 10) / 10;
31
+ }
32
+ function runToolAction(toolId, action) {
33
+ const start = Date.now();
34
+ return action()
35
+ .then(payload => {
36
+ const checks = payload.checks;
37
+ const ok = payload.ok ?? (checks ? checks.every(check => check.ok) : true);
38
+ return {
39
+ toolId,
40
+ ok,
41
+ summary: payload.summary,
42
+ durationMs: Date.now() - start,
43
+ checks,
44
+ metrics: payload.metrics
45
+ };
46
+ })
47
+ .catch(error => {
48
+ const message = error instanceof Error ? error.message : String(error);
49
+ return {
50
+ toolId,
51
+ ok: false,
52
+ summary: message,
53
+ durationMs: Date.now() - start
54
+ };
55
+ });
56
+ }
57
+ function createSampleGenomicProfile() {
58
+ return {
59
+ mutations: ['EGFR', 'TP53'],
60
+ biomarkers: ['EGFR+', 'PD-L1 60%'],
61
+ msiStatus: 'MSS',
62
+ tmbLevel: 'High',
63
+ pdl1Expression: 60,
64
+ hrdStatus: false
65
+ };
66
+ }
67
+ function createSampleRealWorldPatient() {
68
+ return {
69
+ id: SAMPLE_PATIENT_ID,
70
+ demographics: {
71
+ firstName: 'Alex',
72
+ lastName: 'Taylor',
73
+ dateOfBirth: new Date('1962-05-10'),
74
+ gender: 'male',
75
+ ethnicity: 'other',
76
+ address: {
77
+ city: 'Boston',
78
+ state: 'MA',
79
+ zipCode: '02115',
80
+ country: 'USA'
81
+ }
82
+ },
83
+ diagnosis: {
84
+ cancerType: SAMPLE_CANCER_TYPE,
85
+ stage: SAMPLE_STAGE,
86
+ diagnosisDate: new Date('2022-01-15'),
87
+ histology: 'Adenocarcinoma',
88
+ primarySite: 'Lung',
89
+ metastaticSites: ['Brain']
90
+ },
91
+ genomics: {
92
+ testDate: new Date('2022-02-01'),
93
+ platform: 'Foundation',
94
+ mutations: ['EGFR L858R', 'TP53'],
95
+ biomarkers: {
96
+ EGFR: 'positive',
97
+ 'PD-L1': '60%'
98
+ },
99
+ msiStatus: 'MSS',
100
+ tmbLevel: 'High',
101
+ tmbValue: 12,
102
+ pdl1Expression: 60,
103
+ hrdStatus: false,
104
+ hrdScore: 22
105
+ },
106
+ performanceStatus: 1,
107
+ comorbidities: ['Hypertension']
108
+ };
109
+ }
110
+ function createSamplePatientFeatures() {
111
+ return {
112
+ age: 62,
113
+ gender: 'male',
114
+ cancerType: SAMPLE_CANCER_TYPE,
115
+ stage: 'IV',
116
+ ecogStatus: 1,
117
+ genomicAlterations: [
118
+ {
119
+ gene: 'EGFR',
120
+ alteration: 'L858R',
121
+ type: 'mutation',
122
+ vaf: 0.32
123
+ }
124
+ ],
125
+ pdl1Score: 60,
126
+ pdl1ScoreType: 'TPS',
127
+ msiStatus: 'MSS',
128
+ tmbValue: 12,
129
+ tmbStatus: 'high'
130
+ };
131
+ }
132
+ function createSampleTreatmentFeatures() {
133
+ return {
134
+ regimen: 'Osimertinib',
135
+ drugs: ['Osimertinib'],
136
+ treatmentType: 'targeted',
137
+ setting: 'first-line'
138
+ };
139
+ }
140
+ function createSampleSafetyProfile(patientId) {
141
+ return {
142
+ patientId,
143
+ allergies: [
144
+ {
145
+ allergen: 'Penicillin',
146
+ reactionType: 'rash',
147
+ severity: 'moderate'
148
+ }
149
+ ],
150
+ renalFunction: {
151
+ gfr: 85,
152
+ creatinine: 1.0,
153
+ dialysis: false
154
+ },
155
+ hepaticFunction: {
156
+ childPughClass: 'A',
157
+ bilirubin: 1.1,
158
+ albumin: 4.0,
159
+ inr: 1.0,
160
+ ascites: 'none',
161
+ encephalopathy: 'none'
162
+ },
163
+ cardiacStatus: {
164
+ qtcInterval: 440,
165
+ lvef: 60,
166
+ arrhythmiaHistory: false
167
+ },
168
+ currentMedications: [
169
+ {
170
+ drug: 'Lisinopril',
171
+ dose: '10mg',
172
+ frequency: 'daily',
173
+ startDate: new Date('2020-01-01')
174
+ }
175
+ ],
176
+ demographics: {
177
+ age: 62,
178
+ weight: 78,
179
+ gender: 'male'
180
+ }
181
+ };
182
+ }
183
+ function createSampleTrialProfile() {
184
+ return {
185
+ cancerType: SAMPLE_CANCER_TYPE,
186
+ histology: 'Adenocarcinoma',
187
+ stage: SAMPLE_STAGE,
188
+ biomarkers: [
189
+ {
190
+ name: 'EGFR exon 19 del or L858R',
191
+ status: 'Positive'
192
+ }
193
+ ],
194
+ priorTherapies: ['Osimertinib'],
195
+ currentLine: 2,
196
+ age: 62,
197
+ performanceStatus: 1,
198
+ organFunction: {
199
+ renalFunction: 'Normal',
200
+ hepaticFunction: 'Normal',
201
+ cardiacFunction: 'Normal',
202
+ bonemarrowFunction: 'Normal'
203
+ },
204
+ location: {
205
+ country: 'United States',
206
+ state: 'MA',
207
+ city: 'Boston'
208
+ },
209
+ willingToTravel: true,
210
+ maxTravelDistance: 100,
211
+ preferences: {
212
+ preferredPhases: ['Phase 2', 'Phase 3'],
213
+ acceptPlaceboArm: false,
214
+ preferLocalTrials: true,
215
+ interestedMechanisms: ['EGFR inhibitors', 'Immunotherapy']
216
+ }
217
+ };
218
+ }
219
+ function createSamplePainAssessment() {
220
+ return {
221
+ location: ['Lower back'],
222
+ intensity: 7,
223
+ quality: ['Burning', 'Shooting'],
224
+ temporalPattern: 'Constant',
225
+ aggravatingFactors: ['Movement'],
226
+ relievingFactors: ['Rest', 'Heat'],
227
+ functionalImpact: {
228
+ sleepDisturbance: 2,
229
+ mobilityImpairment: 1,
230
+ selfCareImpairment: 0,
231
+ socialImpairment: 1,
232
+ overallQoL: 6
233
+ },
234
+ psychologicalImpact: ['Anxiety'],
235
+ painType: ['Neuropathic-Peripheral']
236
+ };
237
+ }
238
+ function createSampleTreatmentSummary() {
239
+ return {
240
+ cancerType: 'breast',
241
+ stage: 'early stage',
242
+ summary: {
243
+ surgery: [
244
+ {
245
+ procedure: 'Lumpectomy',
246
+ date: '2022-06-01',
247
+ findings: 'Clear margins',
248
+ complications: [],
249
+ longTermConsiderations: ['Lymphedema monitoring']
250
+ }
251
+ ],
252
+ radiation: [
253
+ {
254
+ site: 'Breast',
255
+ modality: 'IMRT',
256
+ totalDose: '50 Gy',
257
+ fractions: 25,
258
+ completionDate: '2022-09-01',
259
+ acuteToxicities: ['Fatigue'],
260
+ expectedLateEffects: ['Fibrosis']
261
+ }
262
+ ],
263
+ systemicTherapy: [
264
+ {
265
+ agentClass: 'Chemotherapy',
266
+ specificAgents: ['Doxorubicin', 'Cyclophosphamide'],
267
+ duration: '12 weeks',
268
+ completionDate: '2022-05-01',
269
+ significantToxicities: ['Nausea'],
270
+ expectedLateEffects: ['Cardiac monitoring']
271
+ }
272
+ ],
273
+ otherTreatments: []
274
+ }
275
+ };
276
+ }
277
+ function createSamplePortalSummary(patientId) {
278
+ return {
279
+ patientId,
280
+ diagnosis: {
281
+ condition: 'Non-small cell lung cancer',
282
+ diagnosisDate: new Date('2022-01-15'),
283
+ stage: 'IV',
284
+ simpleExplanation: 'Lung cancer that has spread, treated with targeted therapy.'
285
+ },
286
+ currentTreatment: {
287
+ regimen: 'Osimertinib',
288
+ medications: [
289
+ {
290
+ name: 'Osimertinib',
291
+ purpose: 'Target EGFR mutation',
292
+ dose: '80mg',
293
+ frequency: 'Daily',
294
+ instructions: 'Take with or without food',
295
+ sideEffectsToWatch: ['Rash', 'Diarrhea']
296
+ }
297
+ ],
298
+ startDate: new Date('2022-02-01'),
299
+ cycleInfo: {
300
+ currentCycle: 3,
301
+ totalPlannedCycles: 12,
302
+ nextCycleDate: new Date('2022-05-01')
303
+ },
304
+ whatToExpect: ['Monthly labs', 'Imaging every 8-12 weeks'],
305
+ whenToCallDoctor: ['Fever over 100.4F', 'Shortness of breath']
306
+ },
307
+ upcomingAppointments: [
308
+ {
309
+ date: new Date('2022-05-15'),
310
+ type: 'CT Scan',
311
+ provider: 'Radiology',
312
+ location: 'Main Hospital'
313
+ }
314
+ ],
315
+ careTeam: [
316
+ {
317
+ role: 'Medical Oncologist',
318
+ name: 'Dr. Chen',
319
+ phone: '555-0101',
320
+ messageable: true
321
+ }
322
+ ],
323
+ goals: [
324
+ {
325
+ goal: 'Maintain energy levels',
326
+ progress: 70,
327
+ lastUpdated: new Date('2022-04-01')
328
+ }
329
+ ]
330
+ };
331
+ }
332
+ function buildSampleGenomicResults(patientId) {
333
+ return [
334
+ {
335
+ reportId: 'REP-001',
336
+ orderId: 'ORD-001',
337
+ patientId,
338
+ testType: 'comprehensive-genomic-profiling',
339
+ panelName: 'MockPanel',
340
+ specimenInfo: {
341
+ type: 'tissue',
342
+ collectionDate: new Date('2023-01-10'),
343
+ tumorPurity: 0.4
344
+ },
345
+ reportDate: new Date('2023-01-20'),
346
+ variants: [
347
+ {
348
+ gene: 'EGFR',
349
+ hgvsP: 'p.L858R',
350
+ variantType: 'SNV',
351
+ variantAlleleFrequency: 0.32,
352
+ clinicalSignificance: 'pathogenic'
353
+ }
354
+ ],
355
+ copyNumberAlterations: [],
356
+ fusions: [],
357
+ biomarkers: [
358
+ {
359
+ name: 'PD-L1',
360
+ value: 60,
361
+ unit: '%',
362
+ status: 'positive',
363
+ method: 'IHC'
364
+ }
365
+ ],
366
+ therapyMatches: [],
367
+ clinicalTrialMatches: [],
368
+ signatures: {
369
+ microsatelliteInstability: {
370
+ status: 'MSS',
371
+ method: 'NGS'
372
+ },
373
+ tumorMutationalBurden: {
374
+ value: 12,
375
+ unit: 'mutations/Mb',
376
+ status: 'high',
377
+ threshold: 10
378
+ }
379
+ },
380
+ qualityMetrics: {
381
+ meanCoverage: 500,
382
+ percentBases100x: 0.95
383
+ }
384
+ }
385
+ ];
386
+ }
387
+ class MockGenomicClient extends GenomicPlatformClient {
388
+ sampleResults;
389
+ constructor(config, sampleResults) {
390
+ super(config);
391
+ this.sampleResults = sampleResults;
392
+ }
393
+ async authenticate() {
394
+ return;
395
+ }
396
+ async submitOrder(order) {
397
+ return { orderId: order.orderId, status: 'completed' };
398
+ }
399
+ async getOrderStatus(orderId) {
400
+ return {
401
+ orderId,
402
+ patientId: SAMPLE_PATIENT_ID,
403
+ testType: 'comprehensive-genomic-profiling',
404
+ panelName: 'MockPanel',
405
+ specimenType: 'tissue',
406
+ orderDate: new Date(),
407
+ clinicalIndication: 'Mock indication',
408
+ icdCodes: ['C34.9'],
409
+ orderingPhysician: {
410
+ name: 'Dr. Smith',
411
+ npi: '0000000000',
412
+ facility: 'Mock Hospital'
413
+ },
414
+ status: 'completed'
415
+ };
416
+ }
417
+ async getResults(_orderId) {
418
+ return this.sampleResults[0];
419
+ }
420
+ async listPatientResults(patientId) {
421
+ return this.sampleResults.filter(result => result.patientId === patientId);
422
+ }
423
+ }
424
+ function buildSampleValidationData() {
425
+ const cohortId = 'sample-cohort';
426
+ const patients = [
427
+ {
428
+ id: 'VAL-001',
429
+ demographics: { ageAtDiagnosis: 67, gender: 'male' },
430
+ diagnosis: {
431
+ cancerType: 'NSCLC',
432
+ stage: 'IV',
433
+ diagnosisDate: new Date('2021-11-15'),
434
+ biomarkers: [{ name: 'EGFR', value: 'L858R' }]
435
+ },
436
+ treatment: {
437
+ regimen: 'Osimertinib',
438
+ drugs: ['Osimertinib'],
439
+ setting: 'first-line',
440
+ startDate: new Date('2021-12-01'),
441
+ endDate: new Date('2023-01-15')
442
+ },
443
+ outcomes: {
444
+ bestResponse: 'PR',
445
+ responseDate: new Date('2022-02-15'),
446
+ progressionDate: new Date('2023-01-15'),
447
+ lastFollowUpDate: new Date('2023-02-01')
448
+ },
449
+ ecogAtBaseline: 1,
450
+ priorLines: 0
451
+ },
452
+ {
453
+ id: 'VAL-002',
454
+ demographics: { ageAtDiagnosis: 55, gender: 'female' },
455
+ diagnosis: {
456
+ cancerType: 'Breast Cancer',
457
+ stage: 'II',
458
+ diagnosisDate: new Date('2020-03-10'),
459
+ biomarkers: [{ name: 'ER', value: 'positive' }, { name: 'HER2', value: 'negative' }]
460
+ },
461
+ treatment: {
462
+ regimen: 'AC-T',
463
+ drugs: ['Doxorubicin', 'Cyclophosphamide', 'Paclitaxel'],
464
+ setting: 'adjuvant',
465
+ startDate: new Date('2020-04-01'),
466
+ endDate: new Date('2020-09-15'),
467
+ cycles: 8
468
+ },
469
+ outcomes: {
470
+ bestResponse: 'CR',
471
+ responseDate: new Date('2020-09-10'),
472
+ lastFollowUpDate: new Date('2023-03-10')
473
+ },
474
+ ecogAtBaseline: 0,
475
+ priorLines: 0
476
+ },
477
+ {
478
+ id: 'VAL-003',
479
+ demographics: { ageAtDiagnosis: 48, gender: 'female' },
480
+ diagnosis: {
481
+ cancerType: 'Melanoma',
482
+ stage: 'III',
483
+ diagnosisDate: new Date('2019-06-01'),
484
+ biomarkers: [{ name: 'BRAF', value: 'V600E' }]
485
+ },
486
+ treatment: {
487
+ regimen: 'Nivolumab',
488
+ drugs: ['Nivolumab'],
489
+ setting: 'adjuvant',
490
+ startDate: new Date('2019-07-01'),
491
+ endDate: new Date('2020-02-01')
492
+ },
493
+ outcomes: {
494
+ bestResponse: 'SD',
495
+ responseDate: new Date('2019-10-01'),
496
+ progressionDate: new Date('2020-02-01'),
497
+ deathDate: new Date('2021-01-15'),
498
+ lastFollowUpDate: new Date('2021-01-15')
499
+ },
500
+ ecogAtBaseline: 1,
501
+ priorLines: 1
502
+ }
503
+ ];
504
+ const recommendations = [
505
+ {
506
+ patientId: 'VAL-001',
507
+ recommendedRegimen: 'Osimertinib',
508
+ recommendedDrugs: ['Osimertinib'],
509
+ predictions: {
510
+ responseRate: 0.68,
511
+ pfsMonths: 14,
512
+ osMonths: 28,
513
+ toxicityRisk: 0.2
514
+ },
515
+ matchingBiomarkers: ['EGFR L858R'],
516
+ confidenceScore: 0.82,
517
+ timestamp: new Date('2021-12-01')
518
+ },
519
+ {
520
+ patientId: 'VAL-002',
521
+ recommendedRegimen: 'AC-T',
522
+ recommendedDrugs: ['Doxorubicin', 'Cyclophosphamide', 'Paclitaxel'],
523
+ predictions: {
524
+ responseRate: 0.85,
525
+ pfsMonths: 30,
526
+ osMonths: 60,
527
+ toxicityRisk: 0.25
528
+ },
529
+ matchingBiomarkers: ['ER+', 'PR+', 'HER2-'],
530
+ confidenceScore: 0.88,
531
+ timestamp: new Date('2020-04-01')
532
+ },
533
+ {
534
+ patientId: 'VAL-003',
535
+ recommendedRegimen: 'Nivolumab + Ipilimumab',
536
+ recommendedDrugs: ['Nivolumab', 'Ipilimumab'],
537
+ predictions: {
538
+ responseRate: 0.55,
539
+ pfsMonths: 10,
540
+ osMonths: 24,
541
+ toxicityRisk: 0.35
542
+ },
543
+ matchingBiomarkers: ['BRAF V600E'],
544
+ confidenceScore: 0.7,
545
+ timestamp: new Date('2019-07-01')
546
+ }
547
+ ];
548
+ return { cohortId, patients, recommendations };
549
+ }
550
+ export async function runSelfTestSuite(context) {
551
+ const start = Date.now();
552
+ const checks = [];
553
+ const cancerTreatment = context.cancerTreatment;
554
+ const runCheck = async (name, task) => {
555
+ try {
556
+ const result = await task();
557
+ checks.push({ name, ok: result.ok, detail: result.detail });
558
+ }
559
+ catch (error) {
560
+ const message = error instanceof Error ? error.message : String(error);
561
+ checks.push({ name, ok: false, detail: message });
562
+ }
563
+ };
564
+ await runCheck('protocols-loaded', async () => {
565
+ const protocols = await cancerTreatment.listTreatmentProtocols();
566
+ return {
567
+ ok: protocols.length > 0,
568
+ detail: `count=${protocols.length}`
569
+ };
570
+ });
571
+ await runCheck('drug-targets-loaded', async () => {
572
+ const targets = await cancerTreatment.listDrugTargets();
573
+ return {
574
+ ok: targets.length > 10,
575
+ detail: `count=${targets.length}`
576
+ };
577
+ });
578
+ await runCheck('analyze-patient', async () => {
579
+ const analysis = await cancerTreatment.analyzePatient('SELFTEST-001', true);
580
+ const cancerType = analysis?.analysis?.cancerType;
581
+ return {
582
+ ok: Boolean(cancerType),
583
+ detail: `cancerType=${cancerType ?? 'unknown'}`
584
+ };
585
+ });
586
+ await runCheck('treatment-plan', async () => {
587
+ const plan = await cancerTreatment.designTreatmentPlan('SELFTEST-001');
588
+ const protocolId = plan?.plan?.protocol?.id;
589
+ return {
590
+ ok: Boolean(protocolId),
591
+ detail: `protocol=${protocolId ?? 'unknown'}`
592
+ };
593
+ });
594
+ await runCheck('target-discovery', async () => {
595
+ const discovery = await cancerTreatment.discoverDrugTargets('Lung', 'EGFR');
596
+ const matchCount = Array.isArray(discovery?.discoveredTargets)
597
+ ? discovery.discoveredTargets.length
598
+ : 0;
599
+ return {
600
+ ok: matchCount > 0,
601
+ detail: `matches=${matchCount}`
602
+ };
603
+ });
604
+ await runCheck('cure-protocol', async () => {
605
+ const result = await cancerTreatment.cureCancer('SELFTEST-001', 'Lung', 'IV', {
606
+ mutations: ['EGFR'],
607
+ biomarkers: ['EGFR+'],
608
+ msiStatus: 'MSS',
609
+ tmbLevel: 'High',
610
+ pdl1Expression: 60,
611
+ hrdStatus: false
612
+ });
613
+ const confidence = result?.projectedOutcome?.cureConfidence;
614
+ return {
615
+ ok: typeof confidence === 'number',
616
+ detail: confidence !== undefined ? `confidence=${formatPercent(confidence)}` : 'confidence=unknown'
617
+ };
618
+ });
619
+ const ok = checks.every(check => check.ok);
620
+ const summary = ok
621
+ ? `All ${checks.length} checks passed`
622
+ : `${checks.filter(check => !check.ok).length} checks failed`;
623
+ return {
624
+ toolId: 'selftest',
625
+ ok,
626
+ summary,
627
+ durationMs: Date.now() - start,
628
+ checks
629
+ };
630
+ }
631
+ export async function runValidationSample() {
632
+ const start = Date.now();
633
+ try {
634
+ const service = new RetrospectiveValidationService();
635
+ const { cohortId, patients, recommendations } = buildSampleValidationData();
636
+ service.loadCohort(cohortId, patients);
637
+ service.loadRecommendations(recommendations);
638
+ const analysis = await service.runValidation(cohortId);
639
+ const metrics = {
640
+ patients: analysis.patientCount,
641
+ fullConcordance: formatPercent(analysis.concordance.fullConcordance),
642
+ partialConcordance: formatPercent(analysis.concordance.partialConcordance),
643
+ responseAccuracy: formatPercent(analysis.predictionAccuracy.responseAccuracy),
644
+ medianPfsMonths: formatNumber(analysis.clinicalImpact.medianPFS),
645
+ medianOsMonths: formatNumber(analysis.clinicalImpact.medianOS)
646
+ };
647
+ return {
648
+ toolId: 'validate',
649
+ ok: analysis.patientCount === patients.length,
650
+ summary: `Validated ${analysis.patientCount} patients`,
651
+ durationMs: Date.now() - start,
652
+ metrics
653
+ };
654
+ }
655
+ catch (error) {
656
+ const message = error instanceof Error ? error.message : String(error);
657
+ return {
658
+ toolId: 'validate',
659
+ ok: false,
660
+ summary: message,
661
+ durationMs: Date.now() - start
662
+ };
663
+ }
664
+ }
665
+ async function runCancerCore(context) {
666
+ return runToolAction('cancer-core', async () => {
667
+ const protocols = await context.cancerTreatment.listTreatmentProtocols();
668
+ const targets = await context.cancerTreatment.listDrugTargets();
669
+ const immunotherapies = await context.cancerTreatment.listImmunotherapyProtocols();
670
+ const combos = await context.cancerTreatment.listCombinationTherapies();
671
+ const checks = [
672
+ { name: 'protocols', ok: protocols.length > 0, detail: `count=${protocols.length}` },
673
+ { name: 'targets', ok: targets.length > 0, detail: `count=${targets.length}` },
674
+ { name: 'immunotherapy', ok: immunotherapies.length > 0, detail: `count=${immunotherapies.length}` },
675
+ { name: 'combinations', ok: combos.length > 0, detail: `count=${combos.length}` }
676
+ ];
677
+ return {
678
+ summary: `Protocols ${protocols.length}, targets ${targets.length}`,
679
+ checks,
680
+ metrics: {
681
+ protocols: protocols.length,
682
+ drugTargets: targets.length,
683
+ immunotherapyProtocols: immunotherapies.length,
684
+ combinationTherapies: combos.length
685
+ }
686
+ };
687
+ });
688
+ }
689
+ async function runCancerAnalyze(context) {
690
+ return runToolAction('cancer-analyze', async () => {
691
+ const result = await context.cancerTreatment.analyzePatient(SAMPLE_PATIENT_ID, true);
692
+ const analysis = result.analysis;
693
+ return {
694
+ summary: `Analyzed ${analysis.cancerType} ${analysis.stage}`,
695
+ metrics: {
696
+ cancerType: analysis.cancerType,
697
+ stage: analysis.stage,
698
+ biomarkers: analysis.biomarkers.join(', '),
699
+ survivalProbability: formatPercent(analysis.riskAssessment.survivalProbability)
700
+ }
701
+ };
702
+ });
703
+ }
704
+ async function runCancerPlan(context) {
705
+ return runToolAction('cancer-plan', async () => {
706
+ const result = await context.cancerTreatment.designTreatmentPlan(SAMPLE_PATIENT_ID);
707
+ const protocolName = result.plan.protocol.name;
708
+ return {
709
+ summary: `Plan ${protocolName}`,
710
+ metrics: {
711
+ protocol: protocolName,
712
+ estimatedEfficacy: formatPercent(result.estimatedEfficacy)
713
+ }
714
+ };
715
+ });
716
+ }
717
+ async function runCancerCure(context) {
718
+ return runToolAction('cancer-cure', async () => {
719
+ const profile = createSampleGenomicProfile();
720
+ const result = await context.cancerTreatment.cureCancer(SAMPLE_PATIENT_ID, SAMPLE_CANCER_TYPE, SAMPLE_STAGE, profile);
721
+ return {
722
+ summary: `Status ${result.status}`,
723
+ metrics: {
724
+ cureConfidence: formatPercent(result.projectedOutcome.cureConfidence),
725
+ responseRate: formatPercent(result.projectedOutcome.responseRate),
726
+ fiveYearSurvival: formatPercent(result.projectedOutcome.fiveYearSurvival)
727
+ }
728
+ };
729
+ });
730
+ }
731
+ async function runCancerDiscover(context) {
732
+ return runToolAction('cancer-discover', async () => {
733
+ const discovery = await context.cancerTreatment.discoverDrugTargets('Lung', 'EGFR');
734
+ const matchCount = Array.isArray(discovery?.discoveredTargets)
735
+ ? discovery.discoveredTargets.length
736
+ : 0;
737
+ const topTarget = discovery?.discoveredTargets?.[0]?.gene || 'none';
738
+ return {
739
+ summary: `Discovered ${matchCount} targets`,
740
+ metrics: {
741
+ matches: matchCount,
742
+ topTarget
743
+ }
744
+ };
745
+ });
746
+ }
747
+ async function runUniversalCure() {
748
+ return runToolAction('universal-cure', async () => {
749
+ const engine = new UniversalCancerCureEngine();
750
+ const result = await engine.cureAnyCancer('U-001', {
751
+ cancerType: 'NSCLC',
752
+ stage: 'IV',
753
+ histology: 'Adenocarcinoma'
754
+ }, {
755
+ age: 62,
756
+ gender: 'male',
757
+ performanceStatus: 1,
758
+ comorbidities: ['Hypertension'],
759
+ priorTreatments: ['Osimertinib']
760
+ }, {
761
+ mutations: ['EGFR'],
762
+ msiStatus: 'MSS',
763
+ tmbScore: 12,
764
+ immuneScore: 'Hot',
765
+ pdl1TPS: 60
766
+ });
767
+ return {
768
+ summary: `Universal cure status ${result.status}`,
769
+ metrics: {
770
+ cureProbability: formatPercent(result.cureProbability),
771
+ primaryStrategy: result.treatmentPlan.primaryStrategy,
772
+ trialMatches: result.clinicalTrialMatches.highPriority.length +
773
+ result.clinicalTrialMatches.alternatives.length +
774
+ result.clinicalTrialMatches.emergingTrials.length
775
+ }
776
+ };
777
+ });
778
+ }
779
+ async function runGlobalCoverage() {
780
+ return runToolAction('global-coverage', async () => {
781
+ const module = new GlobalCancerCoverageModule();
782
+ const stats = module.getCoverageStatistics();
783
+ return {
784
+ summary: `Guidelines ${stats.totalGlobalGuidelines}`,
785
+ metrics: {
786
+ guidelines: stats.totalGlobalGuidelines,
787
+ regions: stats.regionsRepresented.join(', '),
788
+ rareCancers: stats.totalRareCancers,
789
+ pediatricProtocols: stats.totalPediatricProtocols,
790
+ supportiveCare: stats.totalSupportiveCareProtocols,
791
+ specialPopulations: stats.totalSpecialPopulations
792
+ }
793
+ };
794
+ });
795
+ }
796
+ async function runTreatmentSequencing() {
797
+ return runToolAction('treatment-sequencing', async () => {
798
+ const engine = new TreatmentSequencingEngine();
799
+ const recommendations = engine.getNextLineRecommendation('NSCLC', 'EGFR-mutant (exon 19 del or L858R)', '1L', ['nsclc-egfr-1l-osi'], { 'EGFR exon 19 del or L858R': 'positive' });
800
+ return {
801
+ summary: `Next-line regimens ${recommendations.length}`,
802
+ metrics: {
803
+ recommendations: recommendations.length,
804
+ topRegimen: recommendations[0]?.name || 'none'
805
+ }
806
+ };
807
+ });
808
+ }
809
+ async function runPrecisionMedicine() {
810
+ return runToolAction('precision-medicine', async () => {
811
+ const engine = new PrecisionMedicineEngine();
812
+ const report = engine.generatePrecisionReport(SAMPLE_PATIENT_ID, [
813
+ { gene: 'EGFR', alteration: 'L858R', type: 'mutation' },
814
+ { gene: 'PIK3CA', alteration: 'E545K', type: 'mutation' }
815
+ ], ['DPYD']);
816
+ return {
817
+ summary: report.summary,
818
+ metrics: {
819
+ actionableTargets: report.actionableTargets.length,
820
+ pharmacogenomics: report.pgxRecommendations.length,
821
+ clinicalTrialTargets: report.clinicalTrialTargets.length
822
+ }
823
+ };
824
+ });
825
+ }
826
+ async function runEmergingTherapeutics() {
827
+ return runToolAction('emerging-therapeutics', async () => {
828
+ const module = new EmergingTherapeuticsModule();
829
+ const stats = module.getStatistics();
830
+ return {
831
+ summary: `Emerging targets ${stats.totalNovelTargets}`,
832
+ metrics: {
833
+ cellularTherapies: stats.totalCellularTherapies,
834
+ proteinDegraders: stats.totalProteinDegraders,
835
+ radiopharmaceuticals: stats.totalRadiopharmaceuticals,
836
+ novelTargets: stats.totalNovelTargets,
837
+ aiDrugs: stats.totalAIDrugs,
838
+ stageBreakdown: JSON.stringify(stats.breakdownByStage)
839
+ }
840
+ };
841
+ });
842
+ }
843
+ async function runMultimodalOncology() {
844
+ return runToolAction('multimodal-oncology', async () => {
845
+ const engine = new MultimodalOncologyEngine();
846
+ const sequence = engine.getMultimodalSequence('HER2+ Breast Cancer', 'Stage II-III');
847
+ const bed = engine.calculateBED(60, 30, 10);
848
+ return {
849
+ summary: sequence ? `Sequence found for ${sequence.cancerType}` : 'Sequence not found',
850
+ metrics: {
851
+ sequencePhases: sequence ? sequence.sequence.length : 0,
852
+ bed: formatNumber(bed)
853
+ }
854
+ };
855
+ });
856
+ }
857
+ async function runSpecialPopulations() {
858
+ return runToolAction('special-populations', async () => {
859
+ const engine = new SpecialPopulationsEngine();
860
+ const pediatric = engine.calculatePediatricDose('Vincristine', 18, 110, 6);
861
+ const geriatric = engine.performGeriatricAssessment({
862
+ adl: 4,
863
+ iadl: 5,
864
+ comorbidity: 2
865
+ });
866
+ return {
867
+ summary: `Pediatric dose ${pediatric.dose}`,
868
+ metrics: {
869
+ pediatricDose: pediatric.dose,
870
+ geriatricRisk: geriatric.riskCategory,
871
+ monitoringItems: pediatric.monitoring.length
872
+ }
873
+ };
874
+ });
875
+ }
876
+ async function runResistanceManagement() {
877
+ return runToolAction('resistance-management', async () => {
878
+ const engine = new ResistanceManagementEngine();
879
+ const analysis = engine.analyzeResistance('Osimertinib', 'EGFR', 'T790M', { age: 63, ps: 1, priorLines: 1 });
880
+ const prevention = engine.generatePreventionPlan('NSCLC', 'EGFR TKI', ['EGFR']);
881
+ return {
882
+ summary: `Resistance urgency ${analysis.urgency}`,
883
+ metrics: {
884
+ strategies: analysis.recommendedStrategies.length,
885
+ preventionStrategies: prevention.strategies.length,
886
+ combinationOptions: prevention.combinationOptions.length
887
+ }
888
+ };
889
+ });
890
+ }
891
+ async function runCureVerification() {
892
+ return runToolAction('cure-verification', async () => {
893
+ const engine = new CureVerificationEngine();
894
+ const result = engine.verifyCureStatus('Breast Cancer', 24, 'CR', 'negative', 'undetectable', 18, 18);
895
+ return {
896
+ summary: `Verification ${result.status}`,
897
+ metrics: {
898
+ confidence: formatPercent(result.confidence),
899
+ evidenceItems: result.evidence.length
900
+ }
901
+ };
902
+ });
903
+ }
904
+ async function runCureValidation() {
905
+ return runToolAction('cure-validation', async () => {
906
+ const framework = new CureValidationFramework();
907
+ const report = await framework.validateCoverageCompleteness();
908
+ return {
909
+ summary: `Coverage ${formatNumber(report.coveragePercentage)}%`,
910
+ metrics: {
911
+ totalCancerTypes: report.totalCancerTypes,
912
+ coveredCancerTypes: report.coveredCancerTypes,
913
+ coveragePercent: `${formatNumber(report.coveragePercentage)}%`,
914
+ gapCount: report.gaps.length
915
+ }
916
+ };
917
+ });
918
+ }
919
+ async function runClinicalTrialMatching() {
920
+ return runToolAction('clinical-trial-matching', async () => {
921
+ const engine = new ClinicalTrialMatchingEngine();
922
+ const matches = engine.findMatchingTrials(createSampleTrialProfile());
923
+ const topMatch = matches[0];
924
+ return {
925
+ summary: `Matches ${matches.length}`,
926
+ metrics: {
927
+ matches: matches.length,
928
+ topTrial: topMatch?.trial?.nctId || 'none',
929
+ topScore: topMatch ? formatNumber(topMatch.matchScore) : 0
930
+ }
931
+ };
932
+ });
933
+ }
934
+ async function runPalliativeCare() {
935
+ return runToolAction('palliative-care', async () => {
936
+ const engine = new PalliativeCareEngine();
937
+ const protocol = engine.assessPain(createSamplePainAssessment());
938
+ const conversion = engine.calculateOpioidConversion('Morphine', 30, 'PO', 'Oxycodone', 'PO');
939
+ return {
940
+ summary: protocol ? `Pain protocol ${protocol.severity}` : 'No pain protocol matched',
941
+ metrics: {
942
+ severity: protocol?.severity || 'unknown',
943
+ opioidConversionDose: conversion.dose,
944
+ conversionNotes: conversion.notes.length
945
+ }
946
+ };
947
+ });
948
+ }
949
+ async function runEmergencyOncology() {
950
+ return runToolAction('emergency-oncology', async () => {
951
+ const engine = new EmergencyOncologyEngine();
952
+ const matches = engine.identifyPotentialEmergency(['Back pain', 'Weakness', 'Urinary retention'], { calcium: 13.2, potassium: 6.1 });
953
+ const top = matches[0];
954
+ return {
955
+ summary: `Potential emergencies ${matches.length}`,
956
+ metrics: {
957
+ matches: matches.length,
958
+ topEmergency: top?.name || 'none',
959
+ topUrgency: top?.urgency || 'n/a'
960
+ }
961
+ };
962
+ });
963
+ }
964
+ async function runSurvivorshipCare() {
965
+ return runToolAction('survivorship-care', async () => {
966
+ const engine = new SurvivorshipCareEngine();
967
+ const sample = createSampleTreatmentSummary();
968
+ const plan = engine.generateSurvivorshipCarePlan(sample.cancerType, sample.stage, sample.summary);
969
+ return {
970
+ summary: `Survivorship plan for ${plan.cancerType}`,
971
+ metrics: {
972
+ surveillanceDuration: plan.surveillanceProtocol.duration,
973
+ lateEffects: plan.lateEffectsScreening.length,
974
+ secondaryMalignancy: plan.secondaryMalignancyScreening.length
975
+ }
976
+ };
977
+ });
978
+ }
979
+ async function runUniversalHealth() {
980
+ return runToolAction('universal-health', async () => {
981
+ const engine = new UniversalHealthEngine();
982
+ const plan = engine.generateHealthPlan(45, 'Male', ['hypertension'], ['smoking', 'obesity']);
983
+ return {
984
+ summary: `Health plan with ${plan.conditionManagement.length} conditions`,
985
+ metrics: {
986
+ preventiveCare: plan.preventiveCare.length,
987
+ conditionManagement: plan.conditionManagement.length,
988
+ riskModifications: plan.riskModification.length,
989
+ specialistReferrals: plan.specialistReferrals.length
990
+ }
991
+ };
992
+ });
993
+ }
994
+ async function runClinicalDecisionSupport() {
995
+ return runToolAction('clinical-decision-support', async () => {
996
+ const service = new ClinicalDecisionSupportService();
997
+ const recommendation = await service.generateRecommendation({
998
+ patientId: SAMPLE_PATIENT_ID,
999
+ cancerType: SAMPLE_CANCER_TYPE,
1000
+ stage: SAMPLE_STAGE,
1001
+ biomarkers: [
1002
+ { name: 'EGFR', value: 'L858R', status: 'positive' },
1003
+ { name: 'PD-L1', value: 60, status: 'positive' }
1004
+ ],
1005
+ genomicAlterations: [
1006
+ { gene: 'EGFR', alteration: 'L858R' },
1007
+ { gene: 'TP53', alteration: 'loss' }
1008
+ ],
1009
+ priorTherapies: ['Osimertinib'],
1010
+ performanceStatus: 1,
1011
+ comorbidities: ['Hypertension']
1012
+ });
1013
+ return {
1014
+ summary: `Recommendation ${recommendation.primaryRecommendation.regimen}`,
1015
+ metrics: {
1016
+ primaryRegimen: recommendation.primaryRecommendation.regimen,
1017
+ alternatives: recommendation.alternativeOptions.length,
1018
+ responseRate: formatPercent(recommendation.predictions.responseRate.value)
1019
+ }
1020
+ };
1021
+ });
1022
+ }
1023
+ async function runPatientPortal() {
1024
+ return runToolAction('patient-portal', async () => {
1025
+ const portal = new PatientPortalService();
1026
+ const accountData = {
1027
+ mrn: 'MRN-001',
1028
+ email: 'patient@example.com',
1029
+ preferredLanguage: 'en',
1030
+ preferredContactMethod: 'portal',
1031
+ accessLevel: 'full',
1032
+ notificationPreferences: {
1033
+ appointments: true,
1034
+ labResults: true,
1035
+ messages: true,
1036
+ medications: true,
1037
+ educational: true
1038
+ }
1039
+ };
1040
+ const account = await portal.createAccount(accountData);
1041
+ const summary = createSamplePortalSummary(account.id);
1042
+ portal.setTreatmentSummary(summary);
1043
+ const simple = portal.generateSimpleSummary('NSCLC', 'IV', 'Osimertinib');
1044
+ return {
1045
+ summary: `Portal account ${account.id}`,
1046
+ metrics: {
1047
+ summaryLines: simple.whatItMeans.length,
1048
+ careTeam: summary.careTeam.length,
1049
+ upcomingAppointments: summary.upcomingAppointments.length
1050
+ }
1051
+ };
1052
+ });
1053
+ }
1054
+ async function runMLOutcome() {
1055
+ return runToolAction('ml-outcome', async () => {
1056
+ const predictor = new OutcomePredictorService();
1057
+ const patient = createSamplePatientFeatures();
1058
+ const treatment = createSampleTreatmentFeatures();
1059
+ const response = await predictor.predictResponse(patient, treatment);
1060
+ const survival = await predictor.predictSurvival(patient, treatment);
1061
+ return {
1062
+ summary: `Predicted response ${response.predictedResponse}`,
1063
+ metrics: {
1064
+ objectiveResponseRate: formatPercent(response.objectiveResponseRate),
1065
+ medianPfsMonths: formatNumber(survival.pfs.median),
1066
+ medianOsMonths: formatNumber(survival.os.median)
1067
+ }
1068
+ };
1069
+ });
1070
+ }
1071
+ async function runDrugSafety() {
1072
+ return runToolAction('drug-safety', async () => {
1073
+ const safety = new DrugSafetyService();
1074
+ const patient = createSampleSafetyProfile(SAMPLE_PATIENT_ID);
1075
+ const result = await safety.performSafetyCheck(patient, [
1076
+ { drug: 'Pembrolizumab', dose: '200mg', route: 'IV' },
1077
+ { drug: 'Ipilimumab', dose: '3mg/kg', route: 'IV' }
1078
+ ]);
1079
+ return {
1080
+ summary: `Safety risk ${result.summary.overallRisk}`,
1081
+ metrics: {
1082
+ criticalAlerts: result.summary.criticalAlerts,
1083
+ highAlerts: result.summary.highAlerts,
1084
+ overallRisk: result.summary.overallRisk
1085
+ }
1086
+ };
1087
+ });
1088
+ }
1089
+ async function runHipaaCompliance() {
1090
+ return runToolAction('hipaa-compliance', async () => {
1091
+ const hipaa = new HIPAAComplianceService();
1092
+ const phi = {
1093
+ ssn: '123-45-6789',
1094
+ dob: '1980-01-01',
1095
+ phone: '555-123-4567',
1096
+ address: {
1097
+ street: '100 Main St',
1098
+ city: 'Boston',
1099
+ state: 'MA',
1100
+ zip: '02115'
1101
+ },
1102
+ mrn: 'MRN-001',
1103
+ genomics: { EGFR: 'L858R' }
1104
+ };
1105
+ const masked = hipaa.maskPHI(phi, 'clinical');
1106
+ const encrypted = await hipaa.encryptPHI(phi);
1107
+ const decrypted = await hipaa.decryptPHI(encrypted);
1108
+ const checks = [
1109
+ { name: 'mask-ssn', ok: masked.ssn !== phi.ssn, detail: String(masked.ssn) },
1110
+ { name: 'encrypt-roundtrip', ok: decrypted.ssn === phi.ssn, detail: String(decrypted.ssn) }
1111
+ ];
1112
+ return {
1113
+ summary: 'HIPAA masking/encryption complete',
1114
+ checks,
1115
+ metrics: {
1116
+ encryptedFields: encrypted._encrypted ? Object.keys(encrypted._encrypted).length : 0,
1117
+ maskedDob: String(masked.dob)
1118
+ }
1119
+ };
1120
+ });
1121
+ }
1122
+ async function runRealWorldOrchestrator(context) {
1123
+ return runToolAction('real-world-orchestrator', async () => {
1124
+ const service = context.oncologyService ?? createRealWorldOncologyService(context.serviceConfig);
1125
+ if (!context.oncologyService) {
1126
+ await service.initialize();
1127
+ }
1128
+ const plan = await service.generateComprehensivePlan(createSampleRealWorldPatient(), 'DR-001', {
1129
+ includeTrials: true,
1130
+ includePredictions: true,
1131
+ includeSafetyCheck: true
1132
+ });
1133
+ return {
1134
+ summary: `Plan ${plan.planId}`,
1135
+ metrics: {
1136
+ status: plan.coreRecommendation.status,
1137
+ cureConfidence: formatPercent(plan.coreRecommendation.projectedOutcome.cureConfidence),
1138
+ ehrSource: plan.ehrData?.source || 'none'
1139
+ }
1140
+ };
1141
+ });
1142
+ }
1143
+ async function runGenomicsAggregation() {
1144
+ return runToolAction('genomics-aggregation', async () => {
1145
+ const service = new UnifiedGenomicsService();
1146
+ const sampleResults = buildSampleGenomicResults(SAMPLE_PATIENT_ID);
1147
+ const mockClient = new MockGenomicClient({ platform: 'generic', apiBaseUrl: 'https://example.org' }, sampleResults);
1148
+ service.registerClient('mock', mockClient);
1149
+ const aggregated = await service.getAggregatedVariants(SAMPLE_PATIENT_ID);
1150
+ const matches = await service.matchToTherapies(SAMPLE_PATIENT_ID, SAMPLE_CANCER_TYPE);
1151
+ return {
1152
+ summary: `Aggregated ${aggregated.variants.length} variants`,
1153
+ metrics: {
1154
+ variants: aggregated.variants.length,
1155
+ cnvs: aggregated.cnvs.length,
1156
+ fusions: aggregated.fusions.length,
1157
+ therapyMatches: matches.length,
1158
+ tmbStatus: aggregated.biomarkers.tmb?.status || 'unknown'
1159
+ }
1160
+ };
1161
+ });
1162
+ }
1163
+ async function runEhrReadiness(context) {
1164
+ return runToolAction('ehr-readiness', async () => {
1165
+ const ehrConfig = context.serviceConfig?.ehr;
1166
+ const enabled = ehrConfig?.enabled ?? false;
1167
+ const baseUrl = process.env.FHIR_BASE_URL || ehrConfig?.baseUrl || '';
1168
+ const clientId = process.env.FHIR_CLIENT_ID || ehrConfig?.clientId || '';
1169
+ const clientSecret = process.env.FHIR_CLIENT_SECRET || '';
1170
+ const checks = [
1171
+ { name: 'ehr-enabled', ok: true, detail: enabled ? 'enabled' : 'disabled' },
1172
+ { name: 'FHIR_BASE_URL', ok: !enabled || Boolean(baseUrl), detail: baseUrl || 'missing' },
1173
+ { name: 'FHIR_CLIENT_ID', ok: !enabled || Boolean(clientId), detail: clientId ? 'set' : 'missing' },
1174
+ { name: 'FHIR_CLIENT_SECRET', ok: !enabled || Boolean(clientSecret), detail: clientSecret ? 'set' : 'missing' }
1175
+ ];
1176
+ return {
1177
+ summary: enabled ? 'EHR integration enabled' : 'EHR integration disabled',
1178
+ checks,
1179
+ metrics: {
1180
+ vendor: ehrConfig?.vendor || 'unknown'
1181
+ }
1182
+ };
1183
+ });
1184
+ }
1185
+ const CLI_TOOLS = [
1186
+ {
1187
+ id: 'selftest',
1188
+ description: 'Run core capability smoke tests',
1189
+ usage: '/tool selftest',
1190
+ run: (context) => runSelfTestSuite(context)
1191
+ },
1192
+ {
1193
+ id: 'validate',
1194
+ description: 'Run retrospective validation on a sample cohort',
1195
+ usage: '/tool validate',
1196
+ run: () => runValidationSample()
1197
+ },
1198
+ {
1199
+ id: 'cancer-core',
1200
+ description: 'Summarize cancer treatment core datasets',
1201
+ usage: '/tool cancer-core',
1202
+ run: (context) => runCancerCore(context)
1203
+ },
1204
+ {
1205
+ id: 'cancer-analyze',
1206
+ description: 'Run sample patient analysis',
1207
+ usage: '/tool cancer-analyze',
1208
+ run: (context) => runCancerAnalyze(context)
1209
+ },
1210
+ {
1211
+ id: 'cancer-plan',
1212
+ description: 'Generate sample treatment plan',
1213
+ usage: '/tool cancer-plan',
1214
+ run: (context) => runCancerPlan(context)
1215
+ },
1216
+ {
1217
+ id: 'cancer-cure',
1218
+ description: 'Generate sample cure protocol',
1219
+ usage: '/tool cancer-cure',
1220
+ run: (context) => runCancerCure(context)
1221
+ },
1222
+ {
1223
+ id: 'cancer-discover',
1224
+ description: 'Run sample drug target discovery',
1225
+ usage: '/tool cancer-discover',
1226
+ run: (context) => runCancerDiscover(context)
1227
+ },
1228
+ {
1229
+ id: 'universal-cure',
1230
+ description: 'Run universal cancer cure engine',
1231
+ usage: '/tool universal-cure',
1232
+ run: () => runUniversalCure()
1233
+ },
1234
+ {
1235
+ id: 'global-coverage',
1236
+ description: 'Summarize global guideline coverage',
1237
+ usage: '/tool global-coverage',
1238
+ run: () => runGlobalCoverage()
1239
+ },
1240
+ {
1241
+ id: 'treatment-sequencing',
1242
+ description: 'Recommend next-line therapy sequencing',
1243
+ usage: '/tool treatment-sequencing',
1244
+ run: () => runTreatmentSequencing()
1245
+ },
1246
+ {
1247
+ id: 'precision-medicine',
1248
+ description: 'Generate precision medicine report',
1249
+ usage: '/tool precision-medicine',
1250
+ run: () => runPrecisionMedicine()
1251
+ },
1252
+ {
1253
+ id: 'emerging-therapeutics',
1254
+ description: 'Summarize emerging therapy portfolio',
1255
+ usage: '/tool emerging-therapeutics',
1256
+ run: () => runEmergingTherapeutics()
1257
+ },
1258
+ {
1259
+ id: 'multimodal-oncology',
1260
+ description: 'Generate multimodal oncology sample output',
1261
+ usage: '/tool multimodal-oncology',
1262
+ run: () => runMultimodalOncology()
1263
+ },
1264
+ {
1265
+ id: 'special-populations',
1266
+ description: 'Run pediatric/geriatric special population checks',
1267
+ usage: '/tool special-populations',
1268
+ run: () => runSpecialPopulations()
1269
+ },
1270
+ {
1271
+ id: 'resistance-management',
1272
+ description: 'Analyze resistance and prevention plan',
1273
+ usage: '/tool resistance-management',
1274
+ run: () => runResistanceManagement()
1275
+ },
1276
+ {
1277
+ id: 'cure-verification',
1278
+ description: 'Verify cure status criteria',
1279
+ usage: '/tool cure-verification',
1280
+ run: () => runCureVerification()
1281
+ },
1282
+ {
1283
+ id: 'cure-validation',
1284
+ description: 'Validate coverage completeness',
1285
+ usage: '/tool cure-validation',
1286
+ run: () => runCureValidation()
1287
+ },
1288
+ {
1289
+ id: 'clinical-trial-matching',
1290
+ description: 'Match trials against sample profile',
1291
+ usage: '/tool clinical-trial-matching',
1292
+ run: () => runClinicalTrialMatching()
1293
+ },
1294
+ {
1295
+ id: 'palliative-care',
1296
+ description: 'Assess pain and opioid conversion',
1297
+ usage: '/tool palliative-care',
1298
+ run: () => runPalliativeCare()
1299
+ },
1300
+ {
1301
+ id: 'emergency-oncology',
1302
+ description: 'Identify potential oncology emergencies',
1303
+ usage: '/tool emergency-oncology',
1304
+ run: () => runEmergencyOncology()
1305
+ },
1306
+ {
1307
+ id: 'survivorship-care',
1308
+ description: 'Generate survivorship care plan',
1309
+ usage: '/tool survivorship-care',
1310
+ run: () => runSurvivorshipCare()
1311
+ },
1312
+ {
1313
+ id: 'universal-health',
1314
+ description: 'Generate general health plan',
1315
+ usage: '/tool universal-health',
1316
+ run: () => runUniversalHealth()
1317
+ },
1318
+ {
1319
+ id: 'clinical-decision-support',
1320
+ description: 'Generate clinician decision support output',
1321
+ usage: '/tool clinical-decision-support',
1322
+ run: () => runClinicalDecisionSupport()
1323
+ },
1324
+ {
1325
+ id: 'patient-portal',
1326
+ description: 'Create patient portal artifacts',
1327
+ usage: '/tool patient-portal',
1328
+ run: () => runPatientPortal()
1329
+ },
1330
+ {
1331
+ id: 'ml-outcome',
1332
+ description: 'Run ML outcome prediction',
1333
+ usage: '/tool ml-outcome',
1334
+ run: () => runMLOutcome()
1335
+ },
1336
+ {
1337
+ id: 'drug-safety',
1338
+ description: 'Run drug safety check',
1339
+ usage: '/tool drug-safety',
1340
+ run: () => runDrugSafety()
1341
+ },
1342
+ {
1343
+ id: 'hipaa-compliance',
1344
+ description: 'Run HIPAA masking and encryption checks',
1345
+ usage: '/tool hipaa-compliance',
1346
+ run: () => runHipaaCompliance()
1347
+ },
1348
+ {
1349
+ id: 'real-world-orchestrator',
1350
+ description: 'Generate comprehensive plan via orchestrator',
1351
+ usage: '/tool real-world-orchestrator',
1352
+ run: (context) => runRealWorldOrchestrator(context)
1353
+ },
1354
+ {
1355
+ id: 'genomics-aggregation',
1356
+ description: 'Aggregate genomics (mock platform)',
1357
+ usage: '/tool genomics-aggregation',
1358
+ run: () => runGenomicsAggregation()
1359
+ },
1360
+ {
1361
+ id: 'ehr-readiness',
1362
+ description: 'Check EHR integration readiness',
1363
+ usage: '/tool ehr-readiness',
1364
+ run: (context) => runEhrReadiness(context)
1365
+ }
1366
+ ];
1367
+ export function listCliTools() {
1368
+ return CLI_TOOLS;
1369
+ }
1370
+ export function getCliTool(id) {
1371
+ return CLI_TOOLS.find(tool => tool.id === id);
1372
+ }
1373
+ //# sourceMappingURL=index.js.map