File size: 13,135 Bytes
390cffd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
// Shared utilities and state management
class OncoConnect {
    constructor() {
        this.init();
    }

    init() {
        // Initialize toast system
        this.initToast();
        
        // Initialize navigation
        this.initNavigation();
        
        // Initialize modals
        this.initModals();
        
        // Load saved data
        this.loadData();
    }

    // Toast System
    initToast() {
        if (!document.getElementById('toast')) {
            const toast = document.createElement('div');
            toast.id = 'toast';
            toast.className = 'toast';
            toast.setAttribute('role', 'alert');
            toast.setAttribute('aria-live', 'polite');
            document.body.appendChild(toast);
        }
    }

    showToast(message, type = 'success') {
        const toast = document.getElementById('toast');
        if (toast) {
            toast.textContent = message;
            toast.className = `toast ${type}`;
            toast.classList.add('show');
            
            setTimeout(() => {
                toast.classList.remove('show');
            }, 3000);
        }
    }

    // Navigation
    initNavigation() {
        // Handle mobile navigation if needed
        // Currently using simple navigation
    }

    // Modal System
    initModals() {
        // Handle modal close on backdrop click
        document.addEventListener('click', (e) => {
            if (e.target.classList.contains('modal')) {
                this.closeModal(e.target);
            }
        });

        // Handle escape key
        document.addEventListener('keydown', (e) => {
            if (e.key === 'Escape') {
                const openModal = document.querySelector('.modal.show');
                if (openModal) {
                    this.closeModal(openModal);
                }
                
                const openDrawer = document.querySelector('.drawer.show');
                if (openDrawer) {
                    this.closeDrawer(openDrawer);
                }
            }
        });
    }

    openModal(modalId) {
        const modal = document.getElementById(modalId);
        if (modal) {
            modal.classList.add('show');
            modal.setAttribute('aria-hidden', 'false');
            
            // Focus first focusable element
            const focusable = modal.querySelector('input, button, select, textarea');
            if (focusable) {
                setTimeout(() => focusable.focus(), 100);
            }
        }
    }

    closeModal(modal) {
        if (typeof modal === 'string') {
            modal = document.getElementById(modal);
        }
        if (modal) {
            modal.classList.remove('show');
            modal.setAttribute('aria-hidden', 'true');
        }
    }

    openDrawer(drawerId) {
        const drawer = document.getElementById(drawerId);
        if (drawer) {
            drawer.classList.add('show');
            drawer.setAttribute('aria-hidden', 'false');
        }
    }

    closeDrawer(drawer) {
        if (typeof drawer === 'string') {
            drawer = document.getElementById(drawer);
        }
        if (drawer) {
            drawer.classList.remove('show');
            drawer.setAttribute('aria-hidden', 'true');
        }
    }

    // Data Management
    loadData() {
        this.data = {
            savedCases: this.getSavedData('savedCases') || [],
            enrollments: this.getSavedData('enrollments') || [],
            connections: this.getSavedData('connections') || [],
            challenges: this.getSavedData('challenges') || this.getDefaultChallenges()
        };
    }

    getSavedData(key) {
        try {
            return JSON.parse(localStorage.getItem(key));
        } catch {
            return null;
        }
    }

    saveData(key, data) {
        try {
            localStorage.setItem(key, JSON.stringify(data));
        } catch {
            console.warn('Failed to save data to localStorage');
        }
    }

    // Default Data
    getDefaultChallenges() {
        return [
            {
                id: 'rare-disease-drug',
                title: 'Rare Disease Drug Response Predictive Modeling',
                description: 'Drug development for rare diseases is slowed by small patient populations and limited trial data. Students are tasked with building an ML model that predicts patient response to candidate compounds using pre-clinical and limited clinical datasets.',
                difficulty: 'Expert',
                solved: 12,
                enrolled: false
            },
            {
                id: 'prostate-gleason',
                title: 'Prostate Gleason Grading',
                description: 'Create automated systems for accurate Gleason scoring of prostate cancer specimens using deep learning.',
                difficulty: 'Expert',
                solved: 18,
                enrolled: false
            },
            {
                id: 'lung-nodule',
                title: 'Lung Nodule Detection',
                description: 'Build robust models for detecting and classifying lung nodules in histopathology images.',
                difficulty: 'Intermediate',
                solved: 31,
                enrolled: false
            },
            {
                id: 'colon-polyp',
                title: 'Colon Polyp Segmentation',
                description: 'Develop precise segmentation algorithms for colon polyp identification and boundary delineation.',
                difficulty: 'Advanced',
                solved: 15,
                enrolled: false
            },
            {
                id: 'skin-lesion',
                title: 'Skin Lesion Triage',
                description: 'Create triage systems for skin lesion classification to assist in early melanoma detection.',
                difficulty: 'Beginner',
                solved: 42,
                enrolled: false
            },
            {
                id: 'wsi-artifact',
                title: 'WSI Artifact Removal',
                description: 'Develop methods to detect and remove common artifacts in whole slide images for better analysis.',
                difficulty: 'Intermediate',
                solved: 27,
                enrolled: false
            }
        ];
    }

    getDefaultProfiles() {
        return [
            {
                id: 'sarah-chen',
                name: 'Dr. Sarah Chen',
                role: 'Senior Pathologist',
                expertise: ['Breast', 'Deep Learning', 'WSI Analysis'],
                solved: 50,
                bio: 'Leading pathologist specializing in breast cancer diagnosis with extensive experience in AI-assisted pathology. Published researcher in computational pathology with focus on whole slide image analysis.'
            },
            {
                id: 'michael-torres',
                name: 'Dr. Michael Torres',
                role: 'ML Research Scientist',
                expertise: ['Prostate', 'Computer Vision', 'Segmentation'],
                solved: 45,
                bio: 'Machine learning researcher focused on medical imaging applications. Expert in developing robust computer vision algorithms for pathology image analysis.'
            },
            {
                id: 'emily-rodriguez',
                name: 'Dr. Emily Rodriguez',
                role: 'Digital Pathologist',
                expertise: ['Segmentation', 'Lung', 'Feature Extraction'],
                solved: 41,
                bio: 'Digital pathology expert with strong background in image segmentation and feature extraction for pulmonary pathology applications.'
            },
            {
                id: 'david-kim',
                name: 'Dr. David Kim',
                role: 'Pathology Resident',
                expertise: ['Colon', 'Classification', 'Python'],
                solved: 38,
                bio: 'Pathology resident with programming expertise, focused on developing automated classification systems for gastrointestinal pathology.'
            },
            {
                id: 'maria-gonzalez',
                name: 'Dr. Maria Gonzalez',
                role: 'Research Director',
                expertise: ['Multi-organ', 'AI Ethics', 'Clinical Translation'],
                solved: 35,
                bio: 'Research director overseeing AI implementation in clinical pathology with expertise in ethical AI development and clinical translation.'
            },
            {
                id: 'james-wilson',
                name: 'Dr. James Wilson',
                role: 'Dermatopathologist',
                expertise: ['Skin', 'Melanoma', 'Diagnostic AI'],
                solved: 32,
                bio: 'Dermatopathologist specializing in melanoma diagnosis with focus on developing AI tools for skin cancer detection and classification.'
            },
            {
                id: 'lisa-patel',
                name: 'Dr. Lisa Patel',
                role: 'Computational Pathologist',
                expertise: ['Image Processing', 'Quality Control', 'Artifact Detection'],
                solved: 28,
                bio: 'Computational pathologist focused on image quality assessment and artifact detection in digital pathology workflows.'
            },
            {
                id: 'robert-zhang',
                name: 'Dr. Robert Zhang',
                role: 'Biomedical Engineer',
                expertise: ['Algorithm Development', 'Performance Metrics', 'Validation'],
                solved: 25,
                bio: 'Biomedical engineer specializing in algorithm development and validation for medical imaging applications in pathology.'
            },
            {
                id: 'anna-kowalski',
                name: 'Dr. Anna Kowalski',
                role: 'Pathology Fellow',
                expertise: ['Hematopathology', 'Pattern Recognition', 'Research'],
                solved: 22,
                bio: 'Pathology fellow with research focus on hematologic malignancies and pattern recognition in blood and bone marrow specimens.'
            },
            {
                id: 'thomas-mueller',
                name: 'Dr. Thomas Mueller',
                role: 'Medical Informatics Specialist',
                expertise: ['Data Integration', 'Clinical Workflows', 'DICOM'],
                solved: 20,
                bio: 'Medical informatics specialist working on integration of AI tools into clinical pathology workflows and DICOM standard compliance.'
            }
        ];
    }

    getClinicalTrials() {
        return [
            {
                id: 'trial-1',
                title: 'Immunotherapy Combination for Advanced Breast Cancer',
                phase: 'Phase II',
                status: 'Recruiting',
                description: 'Evaluating combination immunotherapy in patients with advanced triple-negative breast cancer.',
                inclusion: 'Confirmed TNBC, ECOG 0-1, adequate organ function',
                location: 'Multiple US sites',
                contact: 'clinical-trials@oncoconnect.org'
            },
            {
                id: 'trial-2',
                title: 'Targeted Therapy for High-Grade Prostate Cancer',
                phase: 'Phase III',
                status: 'Active',
                description: 'Comparing targeted therapy versus standard care in high-grade prostate adenocarcinoma.',
                inclusion: 'Gleason 8-10, metastatic disease, prior therapy allowed',
                location: 'US and EU centers',
                contact: 'prostate-study@oncoconnect.org'
            },
            {
                id: 'trial-3',
                title: 'Early Detection Biomarker Study',
                phase: 'Phase I',
                status: 'Recruiting',
                description: 'Investigating novel biomarkers for early cancer detection across multiple tumor types.',
                inclusion: 'High-risk patients, no prior cancer diagnosis',
                location: 'Academic medical centers',
                contact: 'biomarker-study@oncoconnect.org'
            }
        ];
    }

    // Utility Functions
    formatFileSize(bytes) {
        if (bytes === 0) return '0 Bytes';
        const k = 1024;
        const sizes = ['Bytes', 'KB', 'MB', 'GB'];
        const i = Math.floor(Math.log(bytes) / Math.log(k));
        return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
    }

    generateId() {
        return Date.now().toString(36) + Math.random().toString(36).substr(2);
    }

    debounce(func, wait) {
        let timeout;
        return function executedFunction(...args) {
            const later = () => {
                clearTimeout(timeout);
                func(...args);
            };
            clearTimeout(timeout);
            timeout = setTimeout(later, wait);
        };
    }
}

// Initialize OncoConnect
window.oncoConnect = new OncoConnect();

// Export for use in other scripts
if (typeof module !== 'undefined' && module.exports) {
    module.exports = OncoConnect;
}