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 |
+
<title>Type 1 Diabetes Dashboard</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: sans-serif;
|
| 10 |
+
margin: 20px;
|
| 11 |
+
}
|
| 12 |
+
.tab {
|
| 13 |
+
overflow: hidden;
|
| 14 |
+
border: 1px solid #ccc;
|
| 15 |
+
background-color: #f1f1f1;
|
| 16 |
+
}
|
| 17 |
+
.tab button {
|
| 18 |
+
background-color: inherit;
|
| 19 |
+
float: left;
|
| 20 |
+
border: none;
|
| 21 |
+
outline: none;
|
| 22 |
+
cursor: pointer;
|
| 23 |
+
padding: 14px 16px;
|
| 24 |
+
transition: 0.3s;
|
| 25 |
+
font-size: 17px;
|
| 26 |
+
}
|
| 27 |
+
.tab button:hover {
|
| 28 |
+
background-color: #ddd;
|
| 29 |
+
}
|
| 30 |
+
.tab button.active {
|
| 31 |
+
background-color: #ccc;
|
| 32 |
+
}
|
| 33 |
+
.tabcontent {
|
| 34 |
+
display: none;
|
| 35 |
+
padding: 6px 12px;
|
| 36 |
+
border: 1px solid #ccc;
|
| 37 |
+
border-top: none;
|
| 38 |
+
}
|
| 39 |
+
label {
|
| 40 |
+
display: block;
|
| 41 |
+
margin-bottom: 5px;
|
| 42 |
+
}
|
| 43 |
+
input[type="number"], input[type="range"], select, textarea {
|
| 44 |
+
width: 100%;
|
| 45 |
+
padding: 8px;
|
| 46 |
+
margin-bottom: 10px;
|
| 47 |
+
border: 1px solid #ccc;
|
| 48 |
+
border-radius: 4px;
|
| 49 |
+
box-sizing: border-box;
|
| 50 |
+
}
|
| 51 |
+
button {
|
| 52 |
+
background-color: #4CAF50;
|
| 53 |
+
color: white;
|
| 54 |
+
padding: 10px 15px;
|
| 55 |
+
border: none;
|
| 56 |
+
border-radius: 4px;
|
| 57 |
+
cursor: pointer;
|
| 58 |
+
}
|
| 59 |
+
button:hover {
|
| 60 |
+
background-color: #3e8e41;
|
| 61 |
+
}
|
| 62 |
+
#glucosePlot {
|
| 63 |
+
width: 100%;
|
| 64 |
+
height: 400px; /* Adjust as needed */
|
| 65 |
+
border: 1px solid #ccc;
|
| 66 |
+
}
|
| 67 |
+
.error-message {
|
| 68 |
+
color: red;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
</style>
|
| 72 |
+
</head>
|
| 73 |
+
<body>
|
| 74 |
+
|
| 75 |
+
<h1>Type 1 Diabetes Management Dashboard</h1>
|
| 76 |
+
|
| 77 |
+
<div class="tab">
|
| 78 |
+
<button class="tablinks" onclick="openTab(event, 'GlucoseMeal')" id="defaultOpen">Glucose & Meal</button>
|
| 79 |
+
<button class="tablinks" onclick="openTab(event, 'Insulin')">Insulin</button>
|
| 80 |
+
<button class="tablinks" onclick="openTab(event, 'BasalSettings')">Basal Settings</button>
|
| 81 |
+
<button class="tablinks" onclick="openTab(event, 'OtherFactors')">Other Factors</button>
|
| 82 |
+
</div>
|
| 83 |
+
|
| 84 |
+
<div id="GlucoseMeal" class="tabcontent">
|
| 85 |
+
<h3>Glucose & Meal</h3>
|
| 86 |
+
<label for="initialGlucose">Current Blood Glucose (mg/dL):</label>
|
| 87 |
+
<input type="number" id="initialGlucose" name="initialGlucose" value="120">
|
| 88 |
+
|
| 89 |
+
<label for="foodImage">Food Image:</label>
|
| 90 |
+
<input type="file" id="foodImage" name="foodImage" accept="image/*">
|
| 91 |
+
|
| 92 |
+
<label for="portionSize">Portion Size Multiplier:</label>
|
| 93 |
+
<input type="range" id="portionSize" name="portionSize" min="0.1" max="3" step="0.1" value="1.0">
|
| 94 |
+
<span id="portionSizeValue">1.0</span>
|
| 95 |
+
</div>
|
| 96 |
+
|
| 97 |
+
<div id="Insulin" class="tabcontent">
|
| 98 |
+
<h3>Insulin</h3>
|
| 99 |
+
<label for="insulinType">Insulin Type:</label>
|
| 100 |
+
<select id="insulinType" name="insulinType">
|
| 101 |
+
<option value="Rapid-Acting">Rapid-Acting</option>
|
| 102 |
+
<option value="Long-Acting">Long-Acting</option>
|
| 103 |
+
</select>
|
| 104 |
+
|
| 105 |
+
<label for="overrideCorrectionDose">Override Correction Dose (Units):</label>
|
| 106 |
+
<input type="number" id="overrideCorrectionDose" name="overrideCorrectionDose">
|
| 107 |
+
|
| 108 |
+
<label for="extendedBolusDuration">Extended Bolus Duration (Hours):</label>
|
| 109 |
+
<input type="number" id="extendedBolusDuration" name="extendedBolusDuration" value="0">
|
| 110 |
+
</div>
|
| 111 |
+
|
| 112 |
+
<div id="BasalSettings" class="tabcontent">
|
| 113 |
+
<h3>Basal Settings</h3>
|
| 114 |
+
<label for="basalRates">Basal Rates (JSON):</label>
|
| 115 |
+
<textarea id="basalRates" name="basalRates" rows="4">{"00:00-06:00": 0.8, "06:00-12:00": 1.0, "12:00-18:00": 0.9, "18:00-24:00": 0.7}</textarea>
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<div id="OtherFactors" class="tabcontent">
|
| 119 |
+
<h3>Other Factors</h3>
|
| 120 |
+
<label for="weight">Weight (kg):</label>
|
| 121 |
+
<input type="number" id="weight" name="weight" value="70">
|
| 122 |
+
|
| 123 |
+
<label for="tdd">Total Daily Dose (TDD) of insulin (units):</label>
|
| 124 |
+
<input type="number" id="tdd" name="tdd" value="40">
|
| 125 |
+
|
| 126 |
+
<label for="targetGlucose">Target Blood Glucose (mg/dL):</label>
|
| 127 |
+
<input type="number" id="targetGlucose" name="targetGlucose" value="100">
|
| 128 |
+
|
| 129 |
+
<label for="stressLevel">Stress Level (1-10):</label>
|
| 130 |
+
<input type="range" id="stressLevel" name="stressLevel" min="1" max="10" step="1" value="1">
|
| 131 |
+
<span id="stressLevelValue">1</span>
|
| 132 |
+
|
| 133 |
+
<label for="sleepHours">Sleep Hours:</label>
|
| 134 |
+
<input type="number" id="sleepHours" name="sleepHours" value="7">
|
| 135 |
+
|
| 136 |
+
<label for="exerciseDuration">Exercise Duration (minutes):</label>
|
| 137 |
+
<input type="number" id="exerciseDuration" name="exerciseDuration" value="0">
|
| 138 |
+
|
| 139 |
+
<label for="exerciseIntensity">Exercise Intensity (1-10):</label>
|
| 140 |
+
<input type="range" id="exerciseIntensity" name="exerciseIntensity" min="1" max="10" step="1" value="1">
|
| 141 |
+
<span id="exerciseIntensityValue">1</span>
|
| 142 |
+
</div>
|
| 143 |
+
|
| 144 |
+
<label for="timeHours">Prediction Time (hours):</label>
|
| 145 |
+
<input type="range" id="timeHours" name="timeHours" min="1" max="24" step="1" value="6">
|
| 146 |
+
<span id="timeHoursValue">6</span>
|
| 147 |
+
|
| 148 |
+
<button onclick="calculate()">Calculate</button>
|
| 149 |
+
|
| 150 |
+
<h2>Results</h2>
|
| 151 |
+
<div id="error" class="error-message"></div>
|
| 152 |
+
<label for="carbDetailsOutput">Carbohydrate Details:</label>
|
| 153 |
+
<textarea id="carbDetailsOutput" rows="5" readonly></textarea>
|
| 154 |
+
|
| 155 |
+
<label for="insulinDetailsOutput">Insulin Calculation Details:</label>
|
| 156 |
+
<textarea id="insulinDetailsOutput" rows="5" readonly></textarea>
|
| 157 |
+
|
| 158 |
+
<label for="basalDoseOutput">Basal Insulin Dose (units/day):</label>
|
| 159 |
+
<input type="number" id="basalDoseOutput" readonly>
|
| 160 |
+
|
| 161 |
+
<label for="bolusDoseOutput">Bolus Insulin Dose (units):</label>
|
| 162 |
+
<input type="number" id="bolusDoseOutput" readonly>
|
| 163 |
+
|
| 164 |
+
<label for="glucosePlot">Glucose Prediction:</label>
|
| 165 |
+
<div id="glucosePlot"></div>
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
<script>
|
| 169 |
+
// Tab functionality
|
| 170 |
+
function openTab(evt, tabName) {
|
| 171 |
+
var i, tabcontent, tablinks;
|
| 172 |
+
tabcontent = document.getElementsByClassName("tabcontent");
|
| 173 |
+
for (i = 0; i < tabcontent.length; i++) {
|
| 174 |
+
tabcontent[i].style.display = "none";
|
| 175 |
+
}
|
| 176 |
+
tablinks = document.getElementsByClassName("tablinks");
|
| 177 |
+
for (i = 0; i < tablinks.length; i++) {
|
| 178 |
+
tablinks[i].className = tablinks[i].className.replace(" active", "");
|
| 179 |
+
}
|
| 180 |
+
document.getElementById(tabName).style.display = "block";
|
| 181 |
+
evt.currentTarget.className += " active";
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// Open default tab
|
| 185 |
+
document.getElementById("defaultOpen").click();
|
| 186 |
+
|
| 187 |
+
// Range slider value display
|
| 188 |
+
document.getElementById("portionSize").addEventListener("input", function() {
|
| 189 |
+
document.getElementById("portionSizeValue").textContent = this.value;
|
| 190 |
+
});
|
| 191 |
+
|
| 192 |
+
document.getElementById("stressLevel").addEventListener("input", function() {
|
| 193 |
+
document.getElementById("stressLevelValue").textContent = this.value;
|
| 194 |
+
});
|
| 195 |
+
|
| 196 |
+
document.getElementById("exerciseIntensity").addEventListener("input", function() {
|
| 197 |
+
document.getElementById("exerciseIntensityValue").textContent = this.value;
|
| 198 |
+
});
|
| 199 |
+
|
| 200 |
+
document.getElementById("timeHours").addEventListener("input", function() {
|
| 201 |
+
document.getElementById("timeHoursValue").textContent = this.value;
|
| 202 |
+
});
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
// Main calculation function
|
| 208 |
+
async function calculate() {
|
| 209 |
+
const initialGlucose = parseFloat(document.getElementById("initialGlucose").value);
|
| 210 |
+
const foodImageInput = document.getElementById("foodImage");
|
| 211 |
+
const portionSize = parseFloat(document.getElementById("portionSize").value);
|
| 212 |
+
const insulinType = document.getElementById("insulinType").value;
|
| 213 |
+
const overrideCorrectionDose = parseFloat(document.getElementById("overrideCorrectionDose").value) || null;
|
| 214 |
+
const extendedBolusDuration = parseFloat(document.getElementById("extendedBolusDuration").value);
|
| 215 |
+
const basalRates = document.getElementById("basalRates").value;
|
| 216 |
+
const weight = parseFloat(document.getElementById("weight").value);
|
| 217 |
+
const tdd = parseFloat(document.getElementById("tdd").value);
|
| 218 |
+
const targetGlucose = parseFloat(document.getElementById("targetGlucose").value);
|
| 219 |
+
const stressLevel = parseInt(document.getElementById("stressLevel").value);
|
| 220 |
+
const sleepHours = parseFloat(document.getElementById("sleepHours").value);
|
| 221 |
+
const exerciseDuration = parseFloat(document.getElementById("exerciseDuration").value);
|
| 222 |
+
const exerciseIntensity = parseInt(document.getElementById("exerciseIntensity").value);
|
| 223 |
+
|
| 224 |
+
const errorDiv = document.getElementById("error");
|
| 225 |
+
errorDiv.textContent = "";
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
let foodImage = null;
|
| 229 |
+
if (foodImageInput.files && foodImageInput.files[0]) {
|
| 230 |
+
foodImage = await toBase64(foodImageInput.files[0]); // Convert to base64
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
const timeHours = parseInt(document.getElementById("timeHours").value);
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
// Prepare data for the backend
|
| 239 |
+
const data = {
|
| 240 |
+
initial_glucose: initialGlucose,
|
| 241 |
+
food_image: foodImage,
|
| 242 |
+
stress_level: stressLevel,
|
| 243 |
+
sleep_hours: sleepHours,
|
| 244 |
+
time_hours: timeHours,
|
| 245 |
+
weight: weight,
|
| 246 |
+
tdd: tdd,
|
| 247 |
+
target_glucose: targetGlucose,
|
| 248 |
+
exercise_duration: exerciseDuration,
|
| 249 |
+
exercise_intensity: exerciseIntensity,
|
| 250 |
+
portion_size: portionSize,
|
| 251 |
+
insulin_type: insulinType,
|
| 252 |
+
override_correction_dose: overrideCorrectionDose,
|
| 253 |
+
extended_bolus_duration: extendedBolusDuration,
|
| 254 |
+
basal_rates_input: basalRates
|
| 255 |
+
};
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
// Send data to the backend (replace with your actual endpoint)
|
| 259 |
+
try {
|
| 260 |
+
const response = await fetch("YOUR_HUGGING_FACE_BACKEND_URL", { // <<<<< REPLACE WITH YOUR HUGGING FACE ENDPOINT
|
| 261 |
+
method: "POST",
|
| 262 |
+
headers: {
|
| 263 |
+
"Content-Type": "application/json",
|
| 264 |
+
},
|
| 265 |
+
body: JSON.stringify(data),
|
| 266 |
+
});
|
| 267 |
+
|
| 268 |
+
if (!response.ok) {
|
| 269 |
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
const result = await response.json();
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
// Update the UI with the results
|
| 276 |
+
document.getElementById("carbDetailsOutput").value = result.carb_details_output;
|
| 277 |
+
document.getElementById("insulinDetailsOutput").value = result.insulin_details_output;
|
| 278 |
+
document.getElementById("basalDoseOutput").value = result.basal_dose_output;
|
| 279 |
+
document.getElementById("bolusDoseOutput").value = result.bolus_dose_output;
|
| 280 |
+
|
| 281 |
+
// Render the plot (assuming the backend returns a base64 encoded image)
|
| 282 |
+
if (result.glucose_plot_output) {
|
| 283 |
+
const plotContainer = document.getElementById("glucosePlot");
|
| 284 |
+
plotContainer.innerHTML = `<img src="data:image/png;base64,${result.glucose_plot_output}" alt="Glucose Prediction Plot">`;
|
| 285 |
+
} else {
|
| 286 |
+
document.getElementById("glucosePlot").textContent = "No plot available.";
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
} catch (error) {
|
| 292 |
+
console.error("Error:", error);
|
| 293 |
+
errorDiv.textContent = "An error occurred during calculation: " + error.message;
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
function toBase64(file) {
|
| 299 |
+
return new Promise((resolve, reject) => {
|
| 300 |
+
const reader = new FileReader();
|
| 301 |
+
reader.readAsDataURL(file);
|
| 302 |
+
reader.onload = () => resolve(reader.result.split(',')[1]); // Remove the prefix
|
| 303 |
+
reader.onerror = error => reject(error);
|
| 304 |
+
});
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
</script>
|
| 309 |
+
|
| 310 |
+
</body>
|
| 311 |
+
</html>
|