-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (39 loc) · 1.82 KB
/
script.js
File metadata and controls
47 lines (39 loc) · 1.82 KB
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
function generateOutput() {
const form = document.getElementById('ipss-form');
const formData = new FormData(form);
let ipssTotal = 0;
const scores = {};
const questions = ['incomplete_emptying', 'frequency', 'intermittency', 'urgency', 'weak_stream', 'straining', 'nocturia'];
questions.forEach(question => {
scores[question] = parseInt(formData.get(question)) || 0;
ipssTotal += scores[question];
});
let severity = '';
if (ipssTotal >= 0 && ipssTotal <= 7) severity = 'mild';
else if (ipssTotal >= 8 && ipssTotal <= 19) severity = 'moderate';
else if (ipssTotal >= 20 && ipssTotal <= 35) severity = 'severe';
const qualityOfLife = parseInt(formData.get('quality_of_life')) || 0;
const output = `Total score: ${ipssTotal}/35\n` +
`Severity: ${severity}\n` +
`Placeholder for storage/voiding\n` +
`\n` +
`Incomplete Emptying: ${scores['incomplete_emptying']}\n` +
`Frequency: ${scores['frequency']}\n` +
`Intermittency: ${scores['intermittency']}\n` +
`Urgency: ${scores['urgency']}\n` +
`Weak Stream: ${scores['weak_stream']}\n` +
`Straining: ${scores['straining']}\n` +
`Nocturia: ${scores['nocturia']}\n` +
`Quality of Life: ${qualityOfLife}`;
const outputText = document.getElementById('outputText');
outputText.value = output;
outputText.style.height = outputText.scrollHeight + 'px';
}
function copyOutput() {
const outputText = document.getElementById('outputText');
outputText.select();
document.execCommand('copy');
}
document.querySelectorAll('input[type=radio]').forEach(radio => {
radio.addEventListener('change', generateOutput);
});