@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,711 @@
1
+ /**
2
+ * Special Populations Oncology Module
3
+ *
4
+ * ╔═══════════════════════════════════════════════════════════════════════════════╗
5
+ * ║ SPECIAL POPULATIONS - COMPREHENSIVE PROTOCOLS FOR ALL PATIENTS ║
6
+ * ╠═══════════════════════════════════════════════════════════════════════════════╣
7
+ * ║ This module provides: ║
8
+ * ║ - Pediatric dosing calculations and protocols ║
9
+ * ║ - Geriatric assessment and dose modifications ║
10
+ * ║ - Pregnancy-specific management by trimester ║
11
+ * ║ - Organ dysfunction dosing adjustments ║
12
+ * ║ - HIV/AIDS oncology protocols ║
13
+ * ║ - Drug interaction safety checking ║
14
+ * ╚═══════════════════════════════════════════════════════════════════════════════╝
15
+ */
16
+
17
+ // ═══════════════════════════════════════════════════════════════════════════════
18
+ // PEDIATRIC ONCOLOGY DOSING
19
+ // ═══════════════════════════════════════════════════════════════════════════════
20
+
21
+ export interface PediatricDosingProtocol {
22
+ drug: string;
23
+ indication: string[];
24
+ dosingMethod: 'BSA' | 'Weight' | 'Age-based' | 'Fixed';
25
+ standardDose: string;
26
+ maxDose: string;
27
+ ageAdjustments: AgeAdjustment[];
28
+ organFunctionAdjustments: string[];
29
+ formulations: string[];
30
+ administrationNotes: string[];
31
+ monitoringRequirements: string[];
32
+ }
33
+
34
+ export interface AgeAdjustment {
35
+ ageGroup: 'Neonate (<1 mo)' | 'Infant (1-12 mo)' | 'Toddler (1-3 yr)' | 'Child (3-12 yr)' | 'Adolescent (12-18 yr)';
36
+ adjustment: string;
37
+ rationale: string;
38
+ }
39
+
40
+ export function calculateBSA(weight: number, height: number): number {
41
+ // Mosteller formula: BSA (m²) = √((height cm × weight kg) / 3600)
42
+ return Math.sqrt((height * weight) / 3600);
43
+ }
44
+
45
+ export function calculatePediatricDose(
46
+ adultDose: number,
47
+ patientBSA: number,
48
+ dosingMethod: 'BSA' | 'Weight' | 'Fixed',
49
+ weight?: number
50
+ ): { dose: number; unit: string; notes: string[] } {
51
+ const notes: string[] = [];
52
+
53
+ if (dosingMethod === 'BSA') {
54
+ const dose = adultDose * patientBSA;
55
+ notes.push(`Calculated using BSA ${patientBSA.toFixed(2)} m²`);
56
+ return { dose: Math.round(dose * 10) / 10, unit: 'mg', notes };
57
+ } else if (dosingMethod === 'Weight' && weight) {
58
+ notes.push(`Calculated using weight ${weight} kg`);
59
+ return { dose: Math.round(adultDose * weight * 10) / 10, unit: 'mg', notes };
60
+ }
61
+
62
+ return { dose: adultDose, unit: 'mg', notes: ['Fixed dose used'] };
63
+ }
64
+
65
+ export const PEDIATRIC_DOSING_PROTOCOLS: PediatricDosingProtocol[] = [
66
+ {
67
+ drug: 'Vincristine',
68
+ indication: ['ALL', 'Lymphoma', 'Wilms tumor', 'Neuroblastoma'],
69
+ dosingMethod: 'BSA',
70
+ standardDose: '1.5 mg/m² IV (max 2 mg)',
71
+ maxDose: '2 mg absolute',
72
+ ageAdjustments: [
73
+ { ageGroup: 'Infant (1-12 mo)', adjustment: 'Reduce by 50%', rationale: 'Immature hepatic metabolism' },
74
+ { ageGroup: 'Neonate (<1 mo)', adjustment: 'Use with extreme caution, 75% reduction', rationale: 'Limited clearance' }
75
+ ],
76
+ organFunctionAdjustments: ['Reduce dose 50% for bilirubin >3', 'Reduce 75% for bilirubin >5'],
77
+ formulations: ['1 mg/mL solution for injection'],
78
+ administrationNotes: ['Vesicant - ensure good IV access', 'Fatal if given intrathecally', 'Must be in minibag, not syringe'],
79
+ monitoringRequirements: ['Neuro exam for neuropathy', 'Bowel function (constipation)', 'Jaw pain (first-dose)']
80
+ },
81
+ {
82
+ drug: 'Doxorubicin',
83
+ indication: ['Osteosarcoma', 'Ewing sarcoma', 'Lymphoma', 'Solid tumors'],
84
+ dosingMethod: 'BSA',
85
+ standardDose: '30-75 mg/m² IV per cycle (protocol-dependent)',
86
+ maxDose: 'Cumulative lifetime max: 450-550 mg/m²',
87
+ ageAdjustments: [
88
+ { ageGroup: 'Infant (1-12 mo)', adjustment: 'Use with caution; increased cardiac risk', rationale: 'Developing myocardium' },
89
+ { ageGroup: 'Adolescent (12-18 yr)', adjustment: 'Standard dosing; monitor cumulative dose', rationale: 'Long survival means late effects matter' }
90
+ ],
91
+ organFunctionAdjustments: ['Bilirubin 1.2-3: reduce 50%', 'Bilirubin 3-5: reduce 75%', 'Bilirubin >5: hold'],
92
+ formulations: ['2 mg/mL solution'],
93
+ administrationNotes: ['Vesicant', 'Infuse over 15-60 minutes', 'Red urine is expected'],
94
+ monitoringRequirements: ['Echocardiogram at baseline, q3-6 months during, and annually after', 'CBC before each dose', 'LFTs']
95
+ },
96
+ {
97
+ drug: 'Methotrexate (High-dose)',
98
+ indication: ['ALL', 'Osteosarcoma', 'Lymphoma'],
99
+ dosingMethod: 'BSA',
100
+ standardDose: '1-12 g/m² IV (protocol-dependent)',
101
+ maxDose: 'Protocol-specific',
102
+ ageAdjustments: [
103
+ { ageGroup: 'Infant (1-12 mo)', adjustment: 'Reduce by 30-50%; prolonged clearance', rationale: 'Immature renal function' },
104
+ { ageGroup: 'Child (3-12 yr)', adjustment: 'Standard protocol dosing', rationale: 'Adequate clearance' }
105
+ ],
106
+ organFunctionAdjustments: ['Contraindicated if CrCl <60', 'Third-spacing prolongs clearance', 'Hold if effusions present'],
107
+ formulations: ['Various concentrations for IV'],
108
+ administrationNotes: ['Aggressive hydration required', 'Urine alkalinization (pH ≥7)', 'Leucovorin rescue per protocol'],
109
+ monitoringRequirements: ['MTX levels per protocol', 'Creatinine daily', 'CBC', 'Continue leucovorin until MTX <0.1']
110
+ },
111
+ {
112
+ drug: 'Cisplatin',
113
+ indication: ['Osteosarcoma', 'Hepatoblastoma', 'Germ cell tumors', 'Brain tumors'],
114
+ dosingMethod: 'BSA',
115
+ standardDose: '60-100 mg/m² IV (protocol-dependent)',
116
+ maxDose: 'Protocol-specific; watch cumulative nephrotoxicity/ototoxicity',
117
+ ageAdjustments: [
118
+ { ageGroup: 'Infant (1-12 mo)', adjustment: 'Reduce dose; higher ototoxicity risk', rationale: 'Developing auditory system' },
119
+ { ageGroup: 'Neonate (<1 mo)', adjustment: 'Avoid if possible', rationale: 'Extreme ototoxicity risk' }
120
+ ],
121
+ organFunctionAdjustments: ['CrCl 10-50: reduce 25-50%', 'CrCl <10: avoid'],
122
+ formulations: ['1 mg/mL solution'],
123
+ administrationNotes: ['Vigorous hydration pre/post', 'Mannitol diuresis in some protocols', 'Antiemetics required'],
124
+ monitoringRequirements: ['Audiometry at baseline and after each cycle', 'Creatinine/BUN', 'Electrolytes (Mg, K)', 'CBC']
125
+ },
126
+ {
127
+ drug: 'Cyclophosphamide',
128
+ indication: ['ALL', 'Lymphoma', 'Solid tumors', 'Conditioning for HSCT'],
129
+ dosingMethod: 'BSA',
130
+ standardDose: '500-1800 mg/m² (protocol-dependent)',
131
+ maxDose: 'Protocol-specific',
132
+ ageAdjustments: [
133
+ { ageGroup: 'Infant (1-12 mo)', adjustment: 'Standard dosing per BSA; monitor closely', rationale: 'Adequate metabolism' }
134
+ ],
135
+ organFunctionAdjustments: ['Reduce 25% for CrCl 10-50', 'Reduce 50% for CrCl <10'],
136
+ formulations: ['Lyophilized powder for reconstitution', 'Oral tablets'],
137
+ administrationNotes: ['Hydrate to prevent hemorrhagic cystitis', 'Mesna for high doses (>1g/m²)'],
138
+ monitoringRequirements: ['CBC', 'Urinalysis', 'Fluid balance', 'Fertility counseling']
139
+ }
140
+ ];
141
+
142
+ // ═══════════════════════════════════════════════════════════════════════════════
143
+ // GERIATRIC ONCOLOGY
144
+ // ═══════════════════════════════════════════════════════════════════════════════
145
+
146
+ export interface GeriatricAssessment {
147
+ domain: string;
148
+ tool: string;
149
+ interpretation: AssessmentInterpretation[];
150
+ treatmentImplications: string[];
151
+ }
152
+
153
+ export interface AssessmentInterpretation {
154
+ score: string;
155
+ category: string;
156
+ meaning: string;
157
+ }
158
+
159
+ export interface GeriatricDosingAdjustment {
160
+ drug: string;
161
+ standardDose: string;
162
+ geriatricConsiderations: string[];
163
+ doseModification: string;
164
+ alternativeAgents?: string[];
165
+ monitoringIntensification: string[];
166
+ }
167
+
168
+ export const COMPREHENSIVE_GERIATRIC_ASSESSMENT: GeriatricAssessment[] = [
169
+ {
170
+ domain: 'Functional Status',
171
+ tool: 'Activities of Daily Living (ADL)',
172
+ interpretation: [
173
+ { score: '6/6', category: 'Independent', meaning: 'No functional impairment' },
174
+ { score: '4-5/6', category: 'Mild impairment', meaning: 'May need some assistance' },
175
+ { score: '<4/6', category: 'Dependent', meaning: 'Significant functional limitation' }
176
+ ],
177
+ treatmentImplications: ['Independent: standard treatment', 'Mild impairment: consider dose reduction', 'Dependent: palliative-focused care often appropriate']
178
+ },
179
+ {
180
+ domain: 'Functional Status',
181
+ tool: 'Instrumental ADL (IADL)',
182
+ interpretation: [
183
+ { score: '8/8', category: 'Independent', meaning: 'Can manage complex tasks' },
184
+ { score: '5-7/8', category: 'Some limitation', meaning: 'May need support for some tasks' },
185
+ { score: '<5/8', category: 'Significant limitation', meaning: 'Needs substantial support' }
186
+ ],
187
+ treatmentImplications: ['IADL impairment predicts chemotherapy toxicity', 'Consider treatment simplification']
188
+ },
189
+ {
190
+ domain: 'Comorbidity',
191
+ tool: 'Charlson Comorbidity Index',
192
+ interpretation: [
193
+ { score: '0', category: 'No comorbidity', meaning: 'Low competing mortality' },
194
+ { score: '1-2', category: 'Mild comorbidity', meaning: 'Moderate competing mortality' },
195
+ { score: '≥3', category: 'Severe comorbidity', meaning: 'High competing mortality' }
196
+ ],
197
+ treatmentImplications: ['High CCI: balance cancer treatment benefit vs comorbidity burden', 'Consider life expectancy from comorbidities']
198
+ },
199
+ {
200
+ domain: 'Cognition',
201
+ tool: 'Mini-Cog',
202
+ interpretation: [
203
+ { score: '4-5', category: 'Normal', meaning: 'No cognitive impairment detected' },
204
+ { score: '0-3', category: 'Abnormal', meaning: 'Possible cognitive impairment; needs further evaluation' }
205
+ ],
206
+ treatmentImplications: ['Cognitive impairment affects treatment adherence', 'Need caregiver involvement', 'Simplify oral regimens']
207
+ },
208
+ {
209
+ domain: 'Nutrition',
210
+ tool: 'Mini Nutritional Assessment - Short Form (MNA-SF)',
211
+ interpretation: [
212
+ { score: '12-14', category: 'Normal', meaning: 'No malnutrition risk' },
213
+ { score: '8-11', category: 'At risk', meaning: 'Malnutrition risk' },
214
+ { score: '0-7', category: 'Malnourished', meaning: 'Malnutrition present' }
215
+ ],
216
+ treatmentImplications: ['Malnutrition increases toxicity', 'Consider nutritional support before chemotherapy', 'May need dose reduction']
217
+ },
218
+ {
219
+ domain: 'Mood',
220
+ tool: 'Geriatric Depression Scale (GDS-4)',
221
+ interpretation: [
222
+ { score: '0', category: 'Normal', meaning: 'No depression' },
223
+ { score: '≥1', category: 'Possible depression', meaning: 'Screen further with GDS-15' }
224
+ ],
225
+ treatmentImplications: ['Depression affects QoL and adherence', 'Consider psychiatry/psychology referral']
226
+ },
227
+ {
228
+ domain: 'Falls',
229
+ tool: 'Falls in past 6 months',
230
+ interpretation: [
231
+ { score: '0 falls', category: 'Low risk', meaning: 'No recent falls' },
232
+ { score: '1+ falls', category: 'High risk', meaning: 'Fall risk present' }
233
+ ],
234
+ treatmentImplications: ['Falls risk with neurotoxic agents (taxanes, platinum)', 'Physical therapy evaluation', 'Home safety assessment']
235
+ },
236
+ {
237
+ domain: 'Polypharmacy',
238
+ tool: 'Number of medications',
239
+ interpretation: [
240
+ { score: '<5', category: 'Normal', meaning: 'Acceptable' },
241
+ { score: '5-9', category: 'Polypharmacy', meaning: 'Moderate drug burden' },
242
+ { score: '≥10', category: 'Excessive polypharmacy', meaning: 'High interaction risk' }
243
+ ],
244
+ treatmentImplications: ['Review for deprescribing', 'Drug-drug interaction check critical', 'Simplify regimens']
245
+ }
246
+ ];
247
+
248
+ export const GERIATRIC_DOSING_ADJUSTMENTS: GeriatricDosingAdjustment[] = [
249
+ {
250
+ drug: 'Capecitabine',
251
+ standardDose: '1000-1250 mg/m² BID D1-14 q21d',
252
+ geriatricConsiderations: ['Higher toxicity in elderly', 'Diarrhea more severe', 'Hand-foot syndrome'],
253
+ doseModification: 'Start at 75% dose (750-1000 mg/m² BID); reduce further if toxicity',
254
+ alternativeAgents: ['5-FU infusional if poor compliance'],
255
+ monitoringIntensification: ['Weekly calls/visits first cycle', 'Aggressive antidiarrheal education']
256
+ },
257
+ {
258
+ drug: 'Docetaxel',
259
+ standardDose: '75-100 mg/m² q3w',
260
+ geriatricConsiderations: ['Higher neutropenia risk', 'Fluid retention', 'Neuropathy'],
261
+ doseModification: 'Consider 60-75 mg/m² in frail elderly; weekly dosing (35 mg/m²) as alternative',
262
+ alternativeAgents: ['Paclitaxel weekly may be better tolerated'],
263
+ monitoringIntensification: ['G-CSF support recommended', 'Weekly CBC first cycle', 'Daily weights for edema']
264
+ },
265
+ {
266
+ drug: 'Cisplatin',
267
+ standardDose: '75-100 mg/m² q3w',
268
+ geriatricConsiderations: ['Nephrotoxicity', 'Ototoxicity', 'Neuropathy', 'Requires aggressive hydration'],
269
+ doseModification: 'Consider carboplatin substitution (AUC 5-6) in elderly; if cisplatin required, reduce to 60-75 mg/m²',
270
+ alternativeAgents: ['Carboplatin preferred in elderly', 'Oxaliplatin for GI cancers'],
271
+ monitoringIntensification: ['CrCl before each cycle', 'Hearing assessment', 'Hydration status']
272
+ },
273
+ {
274
+ drug: 'Doxorubicin',
275
+ standardDose: '60-75 mg/m² q3w',
276
+ geriatricConsiderations: ['Cardiotoxicity risk higher', 'Age-related decrease in cardiac reserve'],
277
+ doseModification: 'Consider liposomal doxorubicin or dose reduction to 50 mg/m²; lower cumulative max (400 mg/m²)',
278
+ alternativeAgents: ['Pegylated liposomal doxorubicin (lower cardiotoxicity)', 'Epirubicin'],
279
+ monitoringIntensification: ['ECHO before treatment and q2-3 cycles', 'BNP/troponin monitoring']
280
+ },
281
+ {
282
+ drug: 'Pembrolizumab/Nivolumab',
283
+ standardDose: 'Standard dosing (fixed or weight-based)',
284
+ geriatricConsiderations: ['Similar efficacy in elderly', 'irAE profile similar but monitoring important'],
285
+ doseModification: 'No dose adjustment for age; monitor closely for irAEs',
286
+ monitoringIntensification: ['Lower threshold for steroid initiation', 'Close symptom monitoring', 'Thyroid function each cycle']
287
+ }
288
+ ];
289
+
290
+ // ═══════════════════════════════════════════════════════════════════════════════
291
+ // PREGNANCY AND CANCER
292
+ // ═══════════════════════════════════════════════════════════════════════════════
293
+
294
+ export interface PregnancyCancerProtocol {
295
+ trimester: 'First' | 'Second' | 'Third';
296
+ generalPrinciples: string[];
297
+ allowedTreatments: TreatmentSafety[];
298
+ contraindicated: string[];
299
+ fetalMonitoring: string[];
300
+ deliveryConsiderations: string[];
301
+ }
302
+
303
+ export interface TreatmentSafety {
304
+ modality: string;
305
+ safety: 'Generally Safe' | 'Use with Caution' | 'Limited Data' | 'Contraindicated';
306
+ evidence: string;
307
+ specificAgents?: string[];
308
+ }
309
+
310
+ export const PREGNANCY_CANCER_PROTOCOLS: PregnancyCancerProtocol[] = [
311
+ {
312
+ trimester: 'First',
313
+ generalPrinciples: [
314
+ 'Organogenesis occurs - highest teratogenic risk',
315
+ 'Delay chemotherapy until second trimester if possible',
316
+ 'Surgery can be performed with caution',
317
+ 'Radiation generally contraindicated near fetus'
318
+ ],
319
+ allowedTreatments: [
320
+ { modality: 'Surgery', safety: 'Use with Caution', evidence: 'Second trimester preferred but first trimester acceptable for urgent cases' },
321
+ { modality: 'Breast surgery', safety: 'Generally Safe', evidence: 'Can proceed; avoid supine hypotension' },
322
+ { modality: 'Sentinel node biopsy', safety: 'Use with Caution', evidence: 'Technetium safe; blue dye avoided by some' }
323
+ ],
324
+ contraindicated: [
325
+ 'All chemotherapy (teratogenic risk 10-20%)',
326
+ 'Radiation therapy near pelvis',
327
+ 'Endocrine therapy (tamoxifen, AIs)',
328
+ 'Methotrexate (abortifacient)',
329
+ 'All targeted therapies'
330
+ ],
331
+ fetalMonitoring: ['First trimester ultrasound', 'Nuchal translucency if indicated', 'Cell-free DNA screening'],
332
+ deliveryConsiderations: ['Plan for second trimester treatment initiation']
333
+ },
334
+ {
335
+ trimester: 'Second',
336
+ generalPrinciples: [
337
+ 'Chemotherapy can be given after week 14',
338
+ 'Organogenesis complete - lower malformation risk',
339
+ 'Surgery remains feasible',
340
+ 'Goal: deliver at term if possible'
341
+ ],
342
+ allowedTreatments: [
343
+ { modality: 'Anthracyclines', safety: 'Generally Safe', evidence: 'Extensive data; doxorubicin, epirubicin acceptable', specificAgents: ['Doxorubicin', 'Epirubicin'] },
344
+ { modality: 'Taxanes', safety: 'Generally Safe', evidence: 'Growing safety data', specificAgents: ['Paclitaxel', 'Docetaxel'] },
345
+ { modality: 'Platinum agents', safety: 'Use with Caution', evidence: 'Carboplatin preferred; cisplatin with caution', specificAgents: ['Carboplatin'] },
346
+ { modality: 'Alkylating agents', safety: 'Use with Caution', evidence: 'Cyclophosphamide used in FAC/FEC', specificAgents: ['Cyclophosphamide'] },
347
+ { modality: 'Surgery', safety: 'Generally Safe', evidence: 'Optimal timing 14-28 weeks' },
348
+ { modality: 'Radiation (non-pelvic)', safety: 'Use with Caution', evidence: 'Fetal shielding; keep dose <100 mGy to fetus' }
349
+ ],
350
+ contraindicated: [
351
+ 'Methotrexate',
352
+ 'Endocrine therapy',
353
+ 'Targeted therapies (trastuzumab - oligohydramnios)',
354
+ 'Immunotherapy (limited data, potential fetal harm)',
355
+ 'Radiation to pelvis'
356
+ ],
357
+ fetalMonitoring: ['Anatomy scan at 18-20 weeks', 'Growth ultrasound after chemotherapy', 'Fetal echocardiogram if anthracyclines used'],
358
+ deliveryConsiderations: ['Allow 3 weeks between last chemo and delivery', 'Avoid delivery during nadir', 'Term delivery preferred (≥37 weeks)']
359
+ },
360
+ {
361
+ trimester: 'Third',
362
+ generalPrinciples: [
363
+ 'Continue chemotherapy until 35-37 weeks',
364
+ 'Plan delivery around treatment',
365
+ 'Allow 3 weeks between last chemo and delivery',
366
+ 'Delivery at term preferred'
367
+ ],
368
+ allowedTreatments: [
369
+ { modality: 'Anthracyclines', safety: 'Generally Safe', evidence: 'Continue if started', specificAgents: ['Doxorubicin'] },
370
+ { modality: 'Taxanes', safety: 'Generally Safe', evidence: 'Continue if started', specificAgents: ['Paclitaxel'] },
371
+ { modality: 'Surgery', safety: 'Use with Caution', evidence: 'Possible but fetus approaching term' }
372
+ ],
373
+ contraindicated: [
374
+ 'Same as second trimester',
375
+ 'Avoid new regimen initiation if delivery imminent'
376
+ ],
377
+ fetalMonitoring: ['Weekly NST after 32 weeks', 'Growth ultrasound', 'Biophysical profile if concerns'],
378
+ deliveryConsiderations: [
379
+ 'Stop chemotherapy at 35-37 weeks',
380
+ 'Delivery at ≥37 weeks if possible',
381
+ 'Cesarean only for obstetric indications',
382
+ 'Breastfeeding contraindicated during chemotherapy'
383
+ ]
384
+ }
385
+ ];
386
+
387
+ // ═══════════════════════════════════════════════════════════════════════════════
388
+ // ORGAN DYSFUNCTION DOSING
389
+ // ═══════════════════════════════════════════════════════════════════════════════
390
+
391
+ export interface OrganDysfunctionDosing {
392
+ drug: string;
393
+ renalDosing: RenalDosing[];
394
+ hepaticDosing: HepaticDosing[];
395
+ dialysisGuidance?: string;
396
+ }
397
+
398
+ export interface RenalDosing {
399
+ crclRange: string;
400
+ adjustment: string;
401
+ }
402
+
403
+ export interface HepaticDosing {
404
+ bilirubinRange: string;
405
+ astAltRange: string;
406
+ adjustment: string;
407
+ }
408
+
409
+ export const ORGAN_DYSFUNCTION_DOSING: OrganDysfunctionDosing[] = [
410
+ {
411
+ drug: 'Carboplatin',
412
+ renalDosing: [
413
+ { crclRange: '≥60', adjustment: 'Standard AUC dosing (Calvert formula)' },
414
+ { crclRange: '15-59', adjustment: 'Calvert formula accounts for renal function; dose automatically reduced' },
415
+ { crclRange: '<15', adjustment: 'Use with extreme caution; AUC 2-4' }
416
+ ],
417
+ hepaticDosing: [
418
+ { bilirubinRange: 'Any', astAltRange: 'Any', adjustment: 'No adjustment needed (not hepatically cleared)' }
419
+ ],
420
+ dialysisGuidance: 'Dialyzable; give after dialysis'
421
+ },
422
+ {
423
+ drug: 'Cisplatin',
424
+ renalDosing: [
425
+ { crclRange: '≥60', adjustment: 'Full dose with aggressive hydration' },
426
+ { crclRange: '40-59', adjustment: 'Reduce by 25% or consider carboplatin substitution' },
427
+ { crclRange: '<40', adjustment: 'Avoid; use carboplatin' }
428
+ ],
429
+ hepaticDosing: [
430
+ { bilirubinRange: 'Any', astAltRange: 'Any', adjustment: 'No adjustment needed' }
431
+ ]
432
+ },
433
+ {
434
+ drug: 'Methotrexate',
435
+ renalDosing: [
436
+ { crclRange: '≥60', adjustment: 'Full dose' },
437
+ { crclRange: '30-59', adjustment: 'Reduce by 50%' },
438
+ { crclRange: '<30', adjustment: 'Contraindicated for high-dose; low-dose with caution' }
439
+ ],
440
+ hepaticDosing: [
441
+ { bilirubinRange: '>3x ULN', astAltRange: 'Any', adjustment: 'Hold until resolved; hepatotoxic' }
442
+ ],
443
+ dialysisGuidance: 'High-flux dialysis can remove methotrexate in toxicity'
444
+ },
445
+ {
446
+ drug: 'Doxorubicin',
447
+ renalDosing: [
448
+ { crclRange: 'Any', adjustment: 'No adjustment (not renally cleared)' }
449
+ ],
450
+ hepaticDosing: [
451
+ { bilirubinRange: '1.2-3.0', astAltRange: 'Any', adjustment: '50% dose reduction' },
452
+ { bilirubinRange: '3.1-5.0', astAltRange: 'Any', adjustment: '75% dose reduction' },
453
+ { bilirubinRange: '>5.0', astAltRange: 'Any', adjustment: 'Contraindicated' }
454
+ ]
455
+ },
456
+ {
457
+ drug: 'Paclitaxel',
458
+ renalDosing: [
459
+ { crclRange: 'Any', adjustment: 'No adjustment needed' }
460
+ ],
461
+ hepaticDosing: [
462
+ { bilirubinRange: '≤1.5x ULN', astAltRange: '≤10x ULN', adjustment: 'Full dose' },
463
+ { bilirubinRange: '1.6-3x ULN', astAltRange: 'Any', adjustment: 'Reduce by 20%' },
464
+ { bilirubinRange: '>3x ULN', astAltRange: 'Any', adjustment: 'Avoid' }
465
+ ]
466
+ },
467
+ {
468
+ drug: 'Docetaxel',
469
+ renalDosing: [
470
+ { crclRange: 'Any', adjustment: 'No adjustment needed' }
471
+ ],
472
+ hepaticDosing: [
473
+ { bilirubinRange: '>ULN', astAltRange: '>1.5x ULN + Alk phos >2.5x ULN', adjustment: 'Contraindicated' }
474
+ ]
475
+ },
476
+ {
477
+ drug: 'Capecitabine',
478
+ renalDosing: [
479
+ { crclRange: '≥50', adjustment: 'Full dose' },
480
+ { crclRange: '30-49', adjustment: '75% dose' },
481
+ { crclRange: '<30', adjustment: 'Contraindicated' }
482
+ ],
483
+ hepaticDosing: [
484
+ { bilirubinRange: 'Mild-moderate', astAltRange: 'Any', adjustment: 'Use with caution' },
485
+ { bilirubinRange: 'Severe', astAltRange: 'Any', adjustment: 'Contraindicated' }
486
+ ]
487
+ },
488
+ {
489
+ drug: 'Pembrolizumab',
490
+ renalDosing: [
491
+ { crclRange: 'Any', adjustment: 'No adjustment needed' }
492
+ ],
493
+ hepaticDosing: [
494
+ { bilirubinRange: '1-1.5x ULN', astAltRange: 'Any', adjustment: 'No adjustment' },
495
+ { bilirubinRange: '>1.5x ULN', astAltRange: 'Any', adjustment: 'Limited data; use with caution' }
496
+ ]
497
+ }
498
+ ];
499
+
500
+ // ═══════════════════════════════════════════════════════════════════════════════
501
+ // HIV/AIDS ONCOLOGY
502
+ // ═══════════════════════════════════════════════════════════════════════════════
503
+
504
+ export interface HIVOncologyProtocol {
505
+ cancerType: string;
506
+ artInteractions: ARTInteraction[];
507
+ treatmentModifications: string[];
508
+ prophylaxisRequirements: string[];
509
+ monitoringIntensification: string[];
510
+ prognosticConsiderations: string;
511
+ }
512
+
513
+ export interface ARTInteraction {
514
+ artClass: string;
515
+ interaction: string;
516
+ management: string;
517
+ }
518
+
519
+ export const HIV_ONCOLOGY_PROTOCOLS: HIVOncologyProtocol[] = [
520
+ {
521
+ cancerType: 'Kaposi Sarcoma',
522
+ artInteractions: [
523
+ { artClass: 'All ART', interaction: 'ART is primary treatment for limited disease', management: 'Optimize ART first' },
524
+ { artClass: 'PIs', interaction: 'CYP3A4 interactions with taxanes, vinca alkaloids', management: 'Consider INSTI-based regimen during chemo' }
525
+ ],
526
+ treatmentModifications: [
527
+ 'Limited/stable KS: ART alone may induce remission',
528
+ 'Advanced/visceral: Liposomal doxorubicin + ART',
529
+ 'Paclitaxel for refractory disease'
530
+ ],
531
+ prophylaxisRequirements: ['PCP prophylaxis if CD4 <200', 'MAC prophylaxis if CD4 <50', 'CMV monitoring'],
532
+ monitoringIntensification: ['CD4/viral load monthly during chemo', 'Watch for immune reconstitution inflammatory syndrome (IRIS)'],
533
+ prognosticConsiderations: 'CD4 >150 and undetectable VL associated with better outcomes'
534
+ },
535
+ {
536
+ cancerType: 'Non-Hodgkin Lymphoma (AIDS-related)',
537
+ artInteractions: [
538
+ { artClass: 'Protease inhibitors', interaction: 'Increase vincristine/doxorubicin toxicity', management: 'Switch to INSTI-based ART' },
539
+ { artClass: 'NNRTIs (efavirenz)', interaction: 'CYP inducer; may reduce chemo levels', management: 'Consider dose adjustment or switch' }
540
+ ],
541
+ treatmentModifications: [
542
+ 'R-EPOCH preferred for DLBCL (infusional, less myelosuppressive)',
543
+ 'DA-EPOCH-R with dose adjustments',
544
+ 'R-CHOP for patients with good PS and CD4'
545
+ ],
546
+ prophylaxisRequirements: ['G-CSF support routinely', 'PCP prophylaxis regardless of CD4 during chemo', 'Consider antifungal prophylaxis'],
547
+ monitoringIntensification: ['CD4/VL monthly', 'Close monitoring for opportunistic infections', 'Tumor lysis prophylaxis'],
548
+ prognosticConsiderations: 'IPI + CD4 count; ART era outcomes approaching HIV-negative patients'
549
+ },
550
+ {
551
+ cancerType: 'Cervical Cancer (AIDS-defining)',
552
+ artInteractions: [
553
+ { artClass: 'All ART', interaction: 'Continue ART during treatment', management: 'Optimize regimen for minimal interactions' }
554
+ ],
555
+ treatmentModifications: [
556
+ 'Standard treatment per stage',
557
+ 'Cisplatin-based chemoradiation for locally advanced',
558
+ 'May have higher toxicity rates'
559
+ ],
560
+ prophylaxisRequirements: ['Standard prophylaxis per CD4', 'Aggressive supportive care'],
561
+ monitoringIntensification: ['CD4/VL q3 months', 'Close monitoring for treatment toxicity'],
562
+ prognosticConsiderations: 'Outcomes improving with ART but still worse than HIV-negative'
563
+ },
564
+ {
565
+ cancerType: 'Lung Cancer (non-AIDS-defining)',
566
+ artInteractions: [
567
+ { artClass: 'PIs/Cobicistat', interaction: 'CYP3A4 interactions with TKIs (osimertinib, crizotinib)', management: 'Use INSTI-based ART; consider TKI dose adjustment' }
568
+ ],
569
+ treatmentModifications: [
570
+ 'Standard treatment per stage and histology',
571
+ 'Immunotherapy appears safe and effective',
572
+ 'Watch for increased autoimmune manifestations'
573
+ ],
574
+ prophylaxisRequirements: ['Continue standard prophylaxis', 'G-CSF as needed'],
575
+ monitoringIntensification: ['CD4/VL monitoring', 'Watch for irAEs with immunotherapy'],
576
+ prognosticConsiderations: 'Outcomes similar to HIV-negative in ART era with controlled HIV'
577
+ }
578
+ ];
579
+
580
+ // ═══════════════════════════════════════════════════════════════════════════════
581
+ // SPECIAL POPULATIONS ENGINE
582
+ // ═══════════════════════════════════════════════════════════════════════════════
583
+
584
+ export class SpecialPopulationsEngine {
585
+ calculatePediatricDose(
586
+ drug: string,
587
+ weight: number,
588
+ height: number,
589
+ age: number
590
+ ): { dose: string; adjustments: string[]; monitoring: string[] } {
591
+ const bsa = calculateBSA(weight, height);
592
+ const protocol = PEDIATRIC_DOSING_PROTOCOLS.find(p => p.drug.toLowerCase() === drug.toLowerCase());
593
+
594
+ if (!protocol) {
595
+ return { dose: 'Protocol not found', adjustments: [], monitoring: [] };
596
+ }
597
+
598
+ const adjustments: string[] = [];
599
+
600
+ // Check age-specific adjustments
601
+ let ageGroup: AgeAdjustment['ageGroup'];
602
+ if (age < 1/12) ageGroup = 'Neonate (<1 mo)';
603
+ else if (age < 1) ageGroup = 'Infant (1-12 mo)';
604
+ else if (age < 3) ageGroup = 'Toddler (1-3 yr)';
605
+ else if (age < 12) ageGroup = 'Child (3-12 yr)';
606
+ else ageGroup = 'Adolescent (12-18 yr)';
607
+
608
+ const ageAdj = protocol.ageAdjustments.find(a => a.ageGroup === ageGroup);
609
+ if (ageAdj) {
610
+ adjustments.push(`${ageGroup}: ${ageAdj.adjustment} - ${ageAdj.rationale}`);
611
+ }
612
+
613
+ return {
614
+ dose: `${protocol.standardDose} (BSA: ${bsa.toFixed(2)} m²)`,
615
+ adjustments,
616
+ monitoring: protocol.monitoringRequirements
617
+ };
618
+ }
619
+
620
+ performGeriatricAssessment(scores: Record<string, number>): {
621
+ riskCategory: 'Fit' | 'Vulnerable' | 'Frail';
622
+ recommendations: string[];
623
+ treatmentImplications: string[];
624
+ } {
625
+ let fitCount = 0;
626
+ let vulnerableCount = 0;
627
+ let frailCount = 0;
628
+ const recommendations: string[] = [];
629
+
630
+ // Simple scoring based on key domains
631
+ if (scores['adl'] >= 5) fitCount++; else if (scores['adl'] >= 3) vulnerableCount++; else frailCount++;
632
+ if (scores['iadl'] >= 7) fitCount++; else if (scores['iadl'] >= 4) vulnerableCount++; else frailCount++;
633
+ if (scores['comorbidity'] <= 1) fitCount++; else if (scores['comorbidity'] <= 3) vulnerableCount++; else frailCount++;
634
+
635
+ let riskCategory: 'Fit' | 'Vulnerable' | 'Frail';
636
+ if (frailCount >= 2) {
637
+ riskCategory = 'Frail';
638
+ recommendations.push('Consider palliative-focused or modified-intensity treatment');
639
+ recommendations.push('Prioritize quality of life');
640
+ } else if (vulnerableCount >= 2 || frailCount === 1) {
641
+ riskCategory = 'Vulnerable';
642
+ recommendations.push('Consider dose reductions');
643
+ recommendations.push('Close monitoring for toxicity');
644
+ recommendations.push('Geriatric co-management recommended');
645
+ } else {
646
+ riskCategory = 'Fit';
647
+ recommendations.push('Standard treatment appropriate');
648
+ recommendations.push('Continue routine monitoring');
649
+ }
650
+
651
+ return {
652
+ riskCategory,
653
+ recommendations,
654
+ treatmentImplications: COMPREHENSIVE_GERIATRIC_ASSESSMENT.flatMap(a => a.treatmentImplications)
655
+ };
656
+ }
657
+
658
+ getPregnancyGuidelines(trimester: PregnancyCancerProtocol['trimester']): PregnancyCancerProtocol | undefined {
659
+ return PREGNANCY_CANCER_PROTOCOLS.find(p => p.trimester === trimester);
660
+ }
661
+
662
+ getOrganDysfunctionDosing(drug: string, crcl?: number, bilirubin?: number): {
663
+ renalAdjustment: string;
664
+ hepaticAdjustment: string;
665
+ } {
666
+ const protocol = ORGAN_DYSFUNCTION_DOSING.find(p => p.drug.toLowerCase() === drug.toLowerCase());
667
+
668
+ if (!protocol) {
669
+ return { renalAdjustment: 'No data available', hepaticAdjustment: 'No data available' };
670
+ }
671
+
672
+ let renalAdjustment = 'Check CrCl';
673
+ if (crcl !== undefined) {
674
+ for (const rd of protocol.renalDosing) {
675
+ if (rd.crclRange === 'Any' ||
676
+ (rd.crclRange.includes('≥') && crcl >= parseInt(rd.crclRange.replace('≥', ''))) ||
677
+ (rd.crclRange.includes('<') && crcl < parseInt(rd.crclRange.replace('<', '')))) {
678
+ renalAdjustment = rd.adjustment;
679
+ break;
680
+ }
681
+ }
682
+ }
683
+
684
+ let hepaticAdjustment = 'Check bilirubin/LFTs';
685
+ if (bilirubin !== undefined) {
686
+ for (const hd of protocol.hepaticDosing) {
687
+ if (hd.bilirubinRange === 'Any') {
688
+ hepaticAdjustment = hd.adjustment;
689
+ break;
690
+ }
691
+ }
692
+ }
693
+
694
+ return { renalAdjustment, hepaticAdjustment };
695
+ }
696
+
697
+ getHIVOncologyProtocol(cancerType: string): HIVOncologyProtocol | undefined {
698
+ return HIV_ONCOLOGY_PROTOCOLS.find(p =>
699
+ p.cancerType.toLowerCase().includes(cancerType.toLowerCase())
700
+ );
701
+ }
702
+
703
+ getGeriatricDosingAdjustment(drug: string): GeriatricDosingAdjustment | undefined {
704
+ return GERIATRIC_DOSING_ADJUSTMENTS.find(g =>
705
+ g.drug.toLowerCase() === drug.toLowerCase()
706
+ );
707
+ }
708
+ }
709
+
710
+ // Export singleton
711
+ export const specialPopulationsEngine = new SpecialPopulationsEngine();