File size: 15,458 Bytes
8f65667 |
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 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Health Assistant</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
<style>
/* Additional styles for dropdown functionality */
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #10477d;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f153;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #072d4d;
}
</style>
</head>
<body>
<div class="container">
<h1>AI Health Assistant</h1>
<!-- Tab Buttons -->
<div class="tabs">
<button class="tab-button active" data-target="gastrointestinal">Gastrointestinal Disease Prediction</button>
<button class="tab-button" data-target="chest_ct">Chest CT Disease Prediction</button>
<button class="tab-button" data-target="chest_xray">Chest X-ray Disease Prediction</button>
<button class="tab-button" data-target="llm">Chat</button>
</div>
<!-- Gastrointestinal Model Form -->
<div id="gastrointestinal" class="tab-content active">
<h2>Upload Image for Gastrointestinal Disease Prediction</h2>
<form id="gastrointestinal-form" enctype="multipart/form-data">
<label for="file">Select Image:</label>
<input type="file" name="file" id="gastrointestinal-file" required>
<button type="button" onclick="predictDisease('gastrointestinal')">Predict</button>
</form>
<div class="prediction-result" id="gastrointestinal-result"></div>
<!-- Dropdown for Research Links -->
<div class="dropdown">
<button class="dropbtn">Research Papers</button>
<div class="dropdown-content" id="gastrointestinal-research-links"></div>
</div>
<!-- Dropdown for Case Reports -->
<div class="dropdown">
<button class="dropbtn">Case Reports</button>
<div class="dropdown-content" id="gastrointestinal-case-report-links"></div>
</div>
</div>
<!-- Chest CT Model Form -->
<div id="chest_ct" class="tab-content">
<h2>Upload Image for Chest CT Disease Prediction</h2>
<form id="chest_ct-form" enctype="multipart/form-data">
<label for="file">Select Image:</label>
<input type="file" name="file" id="ct-file" required>
<button type="button" onclick="predictDisease('chest_ct')">Predict</button>
</form>
<div class="prediction-result" id="chest_ct-result"></div>
<!-- Dropdown for Research Links -->
<div class="dropdown">
<button class="dropbtn">Research Papers</button>
<div class="dropdown-content" id="chest_ct-research-links"></div>
</div>
<!-- Dropdown for Case Reports -->
<div class="dropdown">
<button class="dropbtn">Case Reports</button>
<div class="dropdown-content" id="chest_ct-case-report-links"></div>
</div>
</div>
<!-- Chest X-ray Model Form -->
<div id="chest_xray" class="tab-content">
<h2>Upload Image for Chest X-ray Disease Prediction</h2>
<form id="chest_xray-form" enctype="multipart/form-data">
<label for="file">Select Image:</label>
<input type="file" name="file" id="xray-file" required>
<button type="button" onclick="predictDisease('chest_xray')">Predict</button>
</form>
<div class="prediction-result" id="chest_xray-result"></div>
<!-- Dropdown for Research Links -->
<div class="dropdown">
<button class="dropbtn">Research Papers</button>
<div class="dropdown-content" id="chest_xray-research-links"></div>
</div>
<!-- Dropdown for Case Reports -->
<div class="dropdown">
<button class="dropbtn">Case Reports</button>
<div class="dropdown-content" id="chest_xray-case-report-links"></div>
</div>
</div>
<!-- Chat with LLM -->
<div id="llm" class="tab-content">
<h2>Ask the AI Health Assistant</h2>
<div id="llm-answer"></div>
</div>
</div>
<!-- LLM Prompt Bar at the Bottom -->
<div class="llm-prompt-bar">
<input type="text" id="llm-prompt" placeholder="Ask your question here...">
<button onclick="askLLM()">Ask</button>
</div>
<!-- Scripts -->
<script>
const researchLinks = {
'Diverticulosis': {
papers: [
{ title: 'Diverticulosis Research Paper 1', url: 'https://www.ncbi.nlm.nih.gov/books/NBK430771/' },
{ title: 'Diverticulosis Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC10410187/' }
],
reports: [
{ title: 'Diverticulosis Case Report 1', url: 'https://jmedicalcasereports.biomedcentral.com/articles/10.1186/1752-1947-4-172' },
{ title: 'Diverticulosis Case Report 2', url: 'https://wjes.biomedcentral.com/articles/10.1186/1749-7922-3-10' },
{ title: 'Diverticulosis Case Report 3', url: 'https://www.sciencedirect.com/science/article/pii/S2210261223000743' }
]
},
'Neoplasm': {
papers: [
{ title: 'Neoplasm Research Paper 1', url: 'https://www.sciencedirect.com/topics/pharmacology-toxicology-and-pharmaceutical-science/neoplasm' },
{ title: 'Neoplasm Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9846320/' }
],
reports: [
{ title: 'Neoplasm Case Report 1', url: 'https://bmcwomenshealth.biomedcentral.com/articles/10.1186/s12905-022-01766-2' },
{ title: 'Neoplasm Case Report 2', url: 'https://issoonline.biomedcentral.com/articles/10.1186/1477-7800-6-6' },
{ title: 'Neoplasm Case Report 3', url: 'https://wjso.biomedcentral.com/articles/10.1186/1477-7819-5-98' }
]
},
'Peritonitis': {
papers: [
{ title: 'Peritonitis Research Paper 1', url: 'https://my.clevelandclinic.org/health/diseases/17831-peritonitis' },
{ title: 'Peritonitis Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7152366/' }
],
reports: [
{ title: 'Peritonitis Case Report 1', url: 'https://pubmed.ncbi.nlm.nih.gov/11396540/' },
{ title: 'Peritonitis Case Report 2', url: 'https://bmcinfectdis.biomedcentral.com/articles/10.1186/1471-2334-13-S1-P34' },
{ title: 'Peritonitis Case Report 3', url: 'https://ccforum.biomedcentral.com/articles/10.1186/cc12906' }
]
},
'Ureters': {
papers: [
{ title: 'Ureters Research Paper 1', url: 'https://www.sciencedirect.com/topics/medicine-and-dentistry/ureter-disease' },
{ title: 'Ureters Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/books/NBK507817/' }
],
reports: [
{ title: 'Ureters Case Report 1', url: 'https://bmcurol.biomedcentral.com/articles/10.1186/1471-2490-12-35' },
{ title: 'Ureters Case Report 2', url: 'https://bmcurol.biomedcentral.com/articles/10.1186/s12894-018-0396-6' },
{ title: 'Ureters Case Report 3', url: 'https://bmcurol.biomedcentral.com/articles/10.1186/s12894-018-0396-6' }
]
},
'Large Cell Carcinoma': {
papers: [
{ title: 'Large Cell Carcinoma Research Paper 1', url: 'https://www.sciencedirect.com/topics/pharmacology-toxicology-and-pharmaceutical-science/large-cell-carcinoma' },
{ title: 'Large Cell Carcinoma Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4531643/' }
],
reports: [
{ title: 'Large Cell Carcinoma Case Report 1', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7481563/' },
{ title: 'Large Cell Carcinoma Case Report 2', url: 'https://wjso.biomedcentral.com/articles/10.1186/1477-7819-11-205' },
{ title: 'Large Cell Carcinoma Case Report 3', url: 'https://cardiothoracicsurgery.biomedcentral.com/articles/10.1186/s13019-023-02349-4' }
]
},
'Adenocarcinoma': {
papers: [
{ title: 'Adenocarcinoma Research Paper 1', url: 'https://www.ncbi.nlm.nih.gov/books/NBK562137/' },
{ title: 'Adenocarcinoma Research Paper 2', url: 'https://biolres.biomedcentral.com/articles/10.1186/s40659-020-00281-8' }
],
reports: [
{ title: 'Adenocarcinoma Case Report 1', url: 'https://hccpjournal.biomedcentral.com/articles/10.1186/1897-4287-8-S1-P4' },
{ title: 'Adenocarcinoma Case Report 2', url: 'https://cancerandmetabolism.biomedcentral.com/articles/10.1186/2049-3002-2-S1-P76' },
{ title: 'Adenocarcinoma Case Report 3', url: 'https://biologydirect.biomedcentral.com/articles/10.1186/s13062-023-00419-0' }
]
},
'Squamous Cell Carcinoma': {
papers: [
{ title: 'Squamous Cell Carcinoma Research Paper 1', url: 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7319751/' },
{ title: 'Squamous Cell Carcinoma Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/books/NBK441939/' }
],
reports: [
{ title: 'Squamous Cell Carcinoma Case Report 1', url: 'https://headandneckoncology.biomedcentral.com/articles/10.1186/1758-3284-1-S1-P32' },
{ title: 'Squamous Cell Carcinoma Case Report 2', url: 'https://headandneckoncology.biomedcentral.com/articles/10.1186/1758-3284-1-S1-P17' },
{ title: 'Squamous Cell Carcinoma Case Report 3', url: 'https://bmcproc.biomedcentral.com/articles/10.1186/1753-6561-7-S2-P25' }
]
},
'Pneumonia': {
papers: [
{ title: 'Pneumonia Research Paper 1', url: 'https://www.who.int/news-room/fact-sheets/detail/pneumonia' },
{ title: 'Pneumonia Research Paper 2', url: 'https://www.ncbi.nlm.nih.gov/books/NBK513321/' }
],
reports: [
{ title: 'Pneumonia Case Report 1', url: 'https://waojournal.biomedcentral.com/articles/10.1186/1939-4551-6-S1-P56' },
{ title: 'Pneumonia Case Report 2', url: 'https://ccforum.biomedcentral.com/articles/10.1186/cc12928' },
{ title: 'Pneumonia Case Report 3', url: 'https://waojournal.biomedcentral.com/articles/10.1186/1939-4551-6-S1-P191' }
]
}
// Other disease links remain the same
};
// JavaScript to handle tab switching
const tabButtons = document.querySelectorAll('.tab-button');
const tabContents = document.querySelectorAll('.tab-content');
tabButtons.forEach(button => {
button.addEventListener('click', () => {
tabButtons.forEach(btn => btn.classList.remove('active'));
tabContents.forEach(content => content.classList.remove('active'));
button.classList.add('active');
document.getElementById(button.dataset.target).classList.add('active');
});
});
// Function to make predictions
function predictDisease(diseaseType) {
console.log('Predicting for: ' + diseaseType); // Add this for debugging
let formData = new FormData(document.getElementById(diseaseType + '-form'));
fetch(`/predict_${diseaseType}`, {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
document.getElementById(diseaseType + '-result').innerText = data.prediction;
populateLinks(data.prediction, diseaseType); // Pass diseaseType to populateLinks
})
.catch(error => {
console.error('Error:', error);
});
}
// Populate the research and case report links
function populateLinks(prediction, diseaseType) {
const links = researchLinks[prediction.trim()];
const researchLinksDiv = document.getElementById(diseaseType + '-research-links');
const caseReportLinksDiv = document.getElementById(diseaseType + '-case-report-links');
if (links) {
researchLinksDiv.innerHTML = links.papers.map(paper => `<a href="${paper.url}" target="_blank">${paper.title}</a>`).join('');
caseReportLinksDiv.innerHTML = links.reports.map(report => `<a href="${report.url}" target="_blank">${report.title}</a>`).join('');
} else {
researchLinksDiv.innerHTML = '<p>No research papers available for this prediction</p>';
caseReportLinksDiv.innerHTML = '<p>No case reports available for this prediction</p>';
}
}
// JavaScript function to ask the LLM
function askLLM() {
const question = document.getElementById('llm-prompt').value;
const answerContainer = document.getElementById('llm-answer');
fetch('/ask_llm', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ question: question }),
})
.then(response => response.json())
.then(data => {
answerContainer.innerHTML = `<h3>Answer: ${data.answer}</h3>`;
})
.catch(error => {
console.error('Error:', error);
answerContainer.innerHTML = '<h3>Error: Unable to fetch answer</h3>';
});
}
</script>
</body>
</html>
|