File size: 3,178 Bytes
02b9964 |
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 |
function showTab(tabId) {
const tabs = document.querySelectorAll('.tab-content');
tabs.forEach(tab => {
if (tab.id === tabId) {
tab.classList.add('active');
} else {
tab.classList.remove('active');
}
});
}
function submitCounseling() {
const question = document.getElementById('counseling-question').value;
fetch('/api/counseling', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question })
})
.then(response => response.json())
.then(data => {
document.getElementById('counseling-response').innerText = data.response;
})
.catch(error => console.error('Error:', error));
}
function submitMedication() {
const question = document.getElementById('medication-question').value;
fetch('/api/medication', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question })
})
.then(response => response.json())
.then(data => {
document.getElementById('medication-response').innerText = data.response;
})
.catch(error => console.error('Error:', error));
}
function submitDiabetes() {
const glucose = document.getElementById('glucose').value;
const bmi = document.getElementById('bmi').value;
const age = document.getElementById('age-diabetes').value;
fetch('/api/diabetes_classification', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ glucose, bmi, age })
})
.then(response => response.json())
.then(data => {
document.getElementById('diabetes-response').innerText = data.result;
})
.catch(error => console.error('Error:', error));
}
function submitMedicine() {
const age = document.getElementById('age').value;
const gender = document.getElementById('gender').value;
const bloodType = document.getElementById('blood-type').value;
const medicalCondition = document.getElementById('medical-condition').value;
const testResults = document.getElementById('test-results').value;
fetch('/api/medicine_classification', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ age, gender, blood_type: bloodType, medical_condition: medicalCondition, test_results: testResults })
})
.then(response => response.json())
.then(data => {
document.getElementById('medicine-response').innerText = data.medicine;
})
.catch(error => console.error('Error:', error));
}
function submitGeneral() {
const question = document.getElementById('general-question').value;
fetch('/api/general', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question })
})
.then(response => response.json())
.then(data => {
document.getElementById('general-response').innerText = data.response;
})
.catch(error => console.error('Error:', error));
}
|