|
<!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>
|
|
|
|
.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>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<div class="dropdown">
|
|
<button class="dropbtn">Research Papers</button>
|
|
<div class="dropdown-content" id="gastrointestinal-research-links"></div>
|
|
</div>
|
|
|
|
<div class="dropdown">
|
|
<button class="dropbtn">Case Reports</button>
|
|
<div class="dropdown-content" id="gastrointestinal-case-report-links"></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<div class="dropdown">
|
|
<button class="dropbtn">Research Papers</button>
|
|
<div class="dropdown-content" id="chest_ct-research-links"></div>
|
|
</div>
|
|
|
|
<div class="dropdown">
|
|
<button class="dropbtn">Case Reports</button>
|
|
<div class="dropdown-content" id="chest_ct-case-report-links"></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<div class="dropdown">
|
|
<button class="dropbtn">Research Papers</button>
|
|
<div class="dropdown-content" id="chest_xray-research-links"></div>
|
|
</div>
|
|
|
|
<div class="dropdown">
|
|
<button class="dropbtn">Case Reports</button>
|
|
<div class="dropdown-content" id="chest_xray-case-report-links"></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div id="llm" class="tab-content">
|
|
<h2>Ask the AI Health Assistant</h2>
|
|
<div id="llm-answer"></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="llm-prompt-bar">
|
|
<input type="text" id="llm-prompt" placeholder="Ask your question here...">
|
|
<button onclick="askLLM()">Ask</button>
|
|
</div>
|
|
|
|
|
|
<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' }
|
|
]
|
|
}
|
|
|
|
};
|
|
|
|
|
|
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 predictDisease(diseaseType) {
|
|
console.log('Predicting for: ' + diseaseType);
|
|
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);
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
}
|
|
|
|
|
|
|
|
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>';
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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>
|
|
|