-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
221 lines (201 loc) · 8.07 KB
/
index.html
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
<html lang="en" class="m-0 p-0">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<title>BioSense-AI</title>
</head>
<body class="m-0 p-0 bg-blue-200 text-center content-center">
<h1 class="mt-10 text-3xl font-bold text-blue-700">Welcome to Biosence-AI</h1>
<canvas id="StressChart" class="p-10 m-auto max-w-2xl w-fit h-fit"></canvas>
<p>Patient's State : <span id="person_id">Loading...</span></p>
<p>Patient's stress level is <span id="stress_id">Loading...</span> % </p>
<br></br>
<form action="/" method="POST">
<div class="text-center py-4 lg:px-4">
<div class="p-2 bg-blue-800 items-center text-blue-100 leading-none lg:rounded-full flex lg:inline-flex"
role="alert">
<span class="flex rounded-full bg-red-500 uppercase px-2 py-1 text-xs font-bold mr-3"><input
type="submit" name="submit" value="OFF"></span>
<span class="flex rounded-full bg-green-500 uppercase px-2 py-1 text-xs font-bold mr-3"><input
type="submit" name="submit" value="ON"></span>
<span class="font-semibold mr-2 text-left flex-auto">SPO2 Sensor</span>
<svg class="fill-current opacity-75 h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path d="M12.95 10.707l.707-.707L8 4.343 6.586 5.757 10.828 10l-4.242 4.243L8 15.657l4.95-4.95z" />
</svg>
</div>
</div>
<!-- Turn SpO2 Sensor ON/OFF: -->
<!-- <input type="submit" name="submit" value="On"> -->
<!-- <input type="submit" name="submit" value="Off"> -->
<p>Patient's Blood SpO2 level is <span id="spo2_id">Loading...</span></p>
<p>Patient's BPM level is <span id="bpm_id">Loading...</span></p>
<br><br>
Stethoscope Analysis :
<button value="Connect" type="submit"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
Connect
</button>
<br><br><br>
<p>Predictions from Steathascope report: Loading...</span></p>
</form>
<h1 class="text-2xl font-bold text-red-500 my-10"> Electro Cardio Graph </h1>
<div id="ldo_detect"
class="flex m-auto iitems-center justify-center bg-red-500 text-white text-sm font-bold px-4 py-3 w-1/2 rounded"
role="alert">
<svg class="fill-current w-4 h-4 mr-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<path
d="M12.432 0c1.34 0 2.01.912 2.01 1.957 0 1.305-1.164 2.512-2.679 2.512-1.269 0-2.009-.75-1.974-1.99C9.789 1.436 10.67 0 12.432 0zM8.309 20c-1.058 0-1.833-.652-1.093-3.524l1.214-5.092c.211-.814.246-1.141 0-1.141-.317 0-1.689.562-2.502 1.117l-.528-.88c2.572-2.186 5.531-3.467 6.801-3.467 1.057 0 1.233 1.273.705 3.23l-1.391 5.352c-.246.945-.141 1.271.106 1.271.317 0 1.357-.392 2.379-1.207l.6.814C12.098 19.02 9.365 20 8.309 20z" />
</svg>
<p>Check the ECG Leads!</p>
</div>
<canvas id="ecg_chart" class="m-auto mt-3 w-full max-w-2xl"></canvas>
<br></br>
<form action="/" method="POST">
Biosense-AI Report :
<button type="submit" name="submit" value="Generate now"
class="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded">
Generate
</button>
</form>
<script> //updateVals chart
function updateValues() {
fetch('/state_page')
.then(response => response.text())
.then(data => {
document.getElementById('person_id').innerHTML = data;
});
fetch('/spo2')
.then(response => response.text())
.then(data => {
document.getElementById('spo2_id').innerHTML = data;
});
fetch('/temp')
.then(response => response.text())
.then(data => {
document.getElementById('stress_id').innerHTML = data;
});
}
setInterval(updateValues, 1000); // Update every second
</script>
<script> //Stress chart
var xValues = ["Stressed", "Normal", "Calm"];
var yValues = [78, 12, 10];
var barColors = [
"#b91d47",
"#2b5797",
"#ffffff",
];
new Chart("StressChart", {
type: "doughnut",
data: {
labels: xValues,
datasets: [{
backgroundColor: barColors,
borderWidth: 0,
data: yValues
}]
},
options: {
title: {
display: false,
text: "Based on Patients SpO2 and BPM Analysis"
}
}
});
</script>
<script>
///////////////////////////////////////////////////////////////////////////
// ECG chart
///////////////////////////////////////////////////////////////////////////
xValues = Array(100).fill(0)
yValues = Array(100).fill(12000)
// Function to update the chart
// function updateChartData() {
// fetch('/ecg_data')
// .then(response => response.text())
// .then(data => {
// ecg_val = parseInt(data);
// yValues.push((ecg_val));
// })
// xValues.push(xValues[xValues.length - 1] + 1);
// yValues.shift();
// xValues.shift();
// chart.update();
// }
// Pusing Limits :)
num = 20;
function updateChartDataFast() {
for (let i = 0; i < num; i++) {
fetch('/ecg_data')
.then(response => response.text())
.then(data => {
ecg_val = parseInt(data);
console.log(ecg_val);
yValues.push((ecg_val));
})
}
xValues.push(xValues[xValues.length - 1] + num);
yValues.shift(num);
xValues.shift(num);
chart.update();
}
const chart = new Chart("ecg_chart", {
type: "line",
data: {
labels: xValues,
datasets: [{
data: yValues,
borderColor: "red",
borderWidth: 2,
radius: 0,
fill: false,
// cubicInterpolationMode: 'monotone',
tension: 0.4
}],
},
options: {
animation: {
duration: 10,
},
scales: {
x: {
ticks: {
display: false
}
},
y: {
ticks: {
display: false
}
},
},
plugins: {
// animation,
interaction: {
intersect: false
},
tooltip: { enabled: false },
scales: {
y: {
min: 10000,
max: 22000,
type: 'linear',
},
x: {
type: 'linear'
}
},
legend: {
display: false
}
},
},
});
setInterval(updateChartDataFast, 100);
// setInterval(updateChartData, 100);
</script>
</body>
</html>