Shfkvl commited on
Commit
bf67022
·
verified ·
1 Parent(s): f102cb6

Add 2 files

Browse files
Files changed (2) hide show
  1. index.html +125 -13
  2. prompts.txt +2 -1
index.html CHANGED
@@ -23,6 +23,32 @@
23
  transform: translateY(-2px);
24
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
25
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  </style>
27
  </head>
28
  <body class="bg-gray-50 min-h-screen">
@@ -41,9 +67,23 @@
41
  <i class="fas fa-calculator mr-2 text-blue-600"></i>Patient Information
42
  </h2>
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
45
  <!-- Weight Input -->
46
- <div>
47
  <label for="weight" class="block text-sm font-medium text-gray-700 mb-1">
48
  <i class="fas fa-weight mr-1"></i>Weight (kg)
49
  </label>
@@ -56,13 +96,13 @@
56
  </div>
57
 
58
  <!-- Age Input -->
59
- <div>
60
  <label class="block text-sm font-medium text-gray-700 mb-1">
61
- <i class="fas fa-birthday-cake mr-1"></i>Age (optional)
62
  </label>
63
  <div class="grid grid-cols-2 gap-2">
64
  <div>
65
- <input type="number" id="years" min="0" max="120"
66
  class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
67
  placeholder="Years">
68
  </div>
@@ -73,6 +113,17 @@
73
  </div>
74
  </div>
75
  </div>
 
 
 
 
 
 
 
 
 
 
 
76
  </div>
77
 
78
  <div class="mt-6 flex justify-center">
@@ -97,6 +148,7 @@
97
  <div>
98
  <h3 class="font-medium text-blue-800">Patient Summary</h3>
99
  <p id="patientSummary" class="text-sm text-gray-700"></p>
 
100
  </div>
101
  </div>
102
 
@@ -126,6 +178,7 @@
126
  <li>Consider patient comorbidities, allergies, and other medications when determining final dosages.</li>
127
  <li>For pediatric patients, additional adjustments may be required based on age and clinical condition.</li>
128
  <li>Paracetamol dosage is calculated as IV (10-15mg/kg) for weights >25kg and as suppository (20mg/kg) for weights ≤25kg.</li>
 
129
  </ul>
130
  </div>
131
  </div>
@@ -136,10 +189,31 @@
136
  const weightInput = document.getElementById('weight');
137
  const yearsInput = document.getElementById('years');
138
  const monthsInput = document.getElementById('months');
 
139
  const calculateBtn = document.getElementById('calculateBtn');
140
  const resultsSection = document.getElementById('resultsSection');
141
  const resultsTable = document.getElementById('resultsTable');
142
  const patientSummary = document.getElementById('patientSummary');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
  // Drug database
145
  const drugs = [
@@ -163,32 +237,70 @@
163
  ];
164
 
165
  calculateBtn.addEventListener('click', function() {
166
- const weight = parseFloat(weightInput.value);
167
  const years = parseInt(yearsInput.value) || 0;
168
  const months = parseInt(monthsInput.value) || 0;
 
169
 
170
- // Validate input
171
- if (isNaN(weight) || weight <= 0) {
172
- alert('Please enter a valid weight in kilograms');
173
- weightInput.focus();
174
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
176
 
177
  // Calculate and display results
178
- calculateDosages(weight, years, months);
179
  resultsSection.classList.remove('hidden');
180
 
181
  // Scroll to results
182
  resultsSection.scrollIntoView({ behavior: 'smooth' });
183
  });
184
 
185
- function calculateDosages(weight, years, months) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  // Update patient summary
187
  let summaryText = `Weight: ${weight.toFixed(1)} kg`;
188
  if (years > 0 || months > 0) {
189
  summaryText += ` | Age: ${years > 0 ? `${years} year${years > 1 ? 's' : ''}` : ''}${years > 0 && months > 0 ? ', ' : ''}${months > 0 ? `${months} month${months > 1 ? 's' : ''}` : ''}`;
190
  }
191
  patientSummary.textContent = summaryText;
 
192
 
193
  // Clear previous results
194
  resultsTable.innerHTML = '';
@@ -244,7 +356,7 @@
244
 
245
  yearsInput.addEventListener('input', function() {
246
  if (this.value < 0) this.value = '';
247
- if (this.value > 120) this.value = 120;
248
  });
249
 
250
  monthsInput.addEventListener('input', function() {
 
23
  transform: translateY(-2px);
24
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
25
  }
26
+ .toggle-input {
27
+ display: flex;
28
+ align-items: center;
29
+ }
30
+ .toggle-input input[type="radio"] {
31
+ display: none;
32
+ }
33
+ .toggle-input label {
34
+ padding: 0.5rem 1rem;
35
+ cursor: pointer;
36
+ border: 1px solid #d1d5db;
37
+ transition: all 0.2s;
38
+ }
39
+ .toggle-input label:first-of-type {
40
+ border-radius: 0.375rem 0 0 0.375rem;
41
+ border-right: none;
42
+ }
43
+ .toggle-input label:last-of-type {
44
+ border-radius: 0 0.375rem 0.375rem 0;
45
+ border-left: none;
46
+ }
47
+ .toggle-input input[type="radio"]:checked + label {
48
+ background-color: #3b82f6;
49
+ color: white;
50
+ border-color: #3b82f6;
51
+ }
52
  </style>
53
  </head>
54
  <body class="bg-gray-50 min-h-screen">
 
67
  <i class="fas fa-calculator mr-2 text-blue-600"></i>Patient Information
68
  </h2>
69
 
70
+ <div class="mb-4">
71
+ <p class="text-sm font-medium text-gray-700 mb-2">Input Method:</p>
72
+ <div class="toggle-input">
73
+ <input type="radio" id="weightMethod" name="inputMethod" value="weight" checked>
74
+ <label for="weightMethod" class="flex items-center">
75
+ <i class="fas fa-weight mr-1"></i> Weight
76
+ </label>
77
+ <input type="radio" id="ageMethod" name="inputMethod" value="age">
78
+ <label for="ageMethod" class="flex items-center">
79
+ <i class="fas fa-birthday-cake mr-1"></i> Age
80
+ </label>
81
+ </div>
82
+ </div>
83
+
84
  <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
85
  <!-- Weight Input -->
86
+ <div id="weightInputGroup">
87
  <label for="weight" class="block text-sm font-medium text-gray-700 mb-1">
88
  <i class="fas fa-weight mr-1"></i>Weight (kg)
89
  </label>
 
96
  </div>
97
 
98
  <!-- Age Input -->
99
+ <div id="ageInputGroup" class="hidden">
100
  <label class="block text-sm font-medium text-gray-700 mb-1">
101
+ <i class="fas fa-birthday-cake mr-1"></i>Age
102
  </label>
103
  <div class="grid grid-cols-2 gap-2">
104
  <div>
105
+ <input type="number" id="years" min="0" max="18"
106
  class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
107
  placeholder="Years">
108
  </div>
 
113
  </div>
114
  </div>
115
  </div>
116
+
117
+ <!-- Additional Info -->
118
+ <div>
119
+ <label for="gender" class="block text-sm font-medium text-gray-700 mb-1">
120
+ <i class="fas fa-venus-mars mr-1"></i>Gender
121
+ </label>
122
+ <select id="gender" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
123
+ <option value="male">Male</option>
124
+ <option value="female">Female</option>
125
+ </select>
126
+ </div>
127
  </div>
128
 
129
  <div class="mt-6 flex justify-center">
 
148
  <div>
149
  <h3 class="font-medium text-blue-800">Patient Summary</h3>
150
  <p id="patientSummary" class="text-sm text-gray-700"></p>
151
+ <p id="weightSource" class="text-xs text-gray-500 mt-1"></p>
152
  </div>
153
  </div>
154
 
 
178
  <li>Consider patient comorbidities, allergies, and other medications when determining final dosages.</li>
179
  <li>For pediatric patients, additional adjustments may be required based on age and clinical condition.</li>
180
  <li>Paracetamol dosage is calculated as IV (10-15mg/kg) for weights >25kg and as suppository (20mg/kg) for weights ≤25kg.</li>
181
+ <li>Weight calculated from age is an estimate. Always measure actual weight when possible.</li>
182
  </ul>
183
  </div>
184
  </div>
 
189
  const weightInput = document.getElementById('weight');
190
  const yearsInput = document.getElementById('years');
191
  const monthsInput = document.getElementById('months');
192
+ const genderSelect = document.getElementById('gender');
193
  const calculateBtn = document.getElementById('calculateBtn');
194
  const resultsSection = document.getElementById('resultsSection');
195
  const resultsTable = document.getElementById('resultsTable');
196
  const patientSummary = document.getElementById('patientSummary');
197
+ const weightSource = document.getElementById('weightSource');
198
+ const weightMethod = document.getElementById('weightMethod');
199
+ const ageMethod = document.getElementById('ageMethod');
200
+ const weightInputGroup = document.getElementById('weightInputGroup');
201
+ const ageInputGroup = document.getElementById('ageInputGroup');
202
+
203
+ // Toggle between weight and age input
204
+ weightMethod.addEventListener('change', function() {
205
+ if (this.checked) {
206
+ weightInputGroup.classList.remove('hidden');
207
+ ageInputGroup.classList.add('hidden');
208
+ }
209
+ });
210
+
211
+ ageMethod.addEventListener('change', function() {
212
+ if (this.checked) {
213
+ weightInputGroup.classList.add('hidden');
214
+ ageInputGroup.classList.remove('hidden');
215
+ }
216
+ });
217
 
218
  // Drug database
219
  const drugs = [
 
237
  ];
238
 
239
  calculateBtn.addEventListener('click', function() {
240
+ let weight, sourceText = '';
241
  const years = parseInt(yearsInput.value) || 0;
242
  const months = parseInt(monthsInput.value) || 0;
243
+ const gender = genderSelect.value;
244
 
245
+ if (weightMethod.checked) {
246
+ // Using direct weight input
247
+ weight = parseFloat(weightInput.value);
248
+
249
+ if (isNaN(weight) || weight <= 0) {
250
+ alert('Please enter a valid weight in kilograms');
251
+ weightInput.focus();
252
+ return;
253
+ }
254
+
255
+ sourceText = 'Weight entered directly';
256
+ } else {
257
+ // Calculate weight from age
258
+ if (years === 0 && months === 0) {
259
+ alert('Please enter either years or months of age');
260
+ yearsInput.focus();
261
+ return;
262
+ }
263
+
264
+ weight = calculateWeightFromAge(years, months, gender);
265
+ sourceText = `Weight estimated from age (${years > 0 ? `${years} year${years > 1 ? 's' : ''}` : ''}${years > 0 && months > 0 ? ', ' : ''}${months > 0 ? `${months} month${months > 1 ? 's' : ''}` : ''}, ${gender})`;
266
  }
267
 
268
  // Calculate and display results
269
+ calculateDosages(weight, years, months, sourceText);
270
  resultsSection.classList.remove('hidden');
271
 
272
  // Scroll to results
273
  resultsSection.scrollIntoView({ behavior: 'smooth' });
274
  });
275
 
276
+ function calculateWeightFromAge(years, months, gender) {
277
+ const totalMonths = years * 12 + months;
278
+
279
+ // Weight estimation formulas based on age (simplified pediatric growth charts)
280
+ if (totalMonths <= 24) { // 0-2 years
281
+ // For infants <2 years: weight (kg) = (age in months + 9)/2
282
+ return (totalMonths + 9) / 2;
283
+ } else if (totalMonths <= 120) { // 2-10 years
284
+ // For children 2-10 years: weight (kg) = (age in years × 2) + 8
285
+ return (years + (months / 12)) * 2 + 8;
286
+ } else { // >10 years
287
+ // For adolescents >10 years: different formulas for boys and girls
288
+ if (gender === 'male') {
289
+ return (years + (months / 12)) * 3 + 13;
290
+ } else {
291
+ return (years + (months / 12)) * 2.5 + 13;
292
+ }
293
+ }
294
+ }
295
+
296
+ function calculateDosages(weight, years, months, sourceText) {
297
  // Update patient summary
298
  let summaryText = `Weight: ${weight.toFixed(1)} kg`;
299
  if (years > 0 || months > 0) {
300
  summaryText += ` | Age: ${years > 0 ? `${years} year${years > 1 ? 's' : ''}` : ''}${years > 0 && months > 0 ? ', ' : ''}${months > 0 ? `${months} month${months > 1 ? 's' : ''}` : ''}`;
301
  }
302
  patientSummary.textContent = summaryText;
303
+ weightSource.textContent = sourceText;
304
 
305
  // Clear previous results
306
  resultsTable.innerHTML = '';
 
356
 
357
  yearsInput.addEventListener('input', function() {
358
  if (this.value < 0) this.value = '';
359
+ if (this.value > 18) this.value = 18;
360
  });
361
 
362
  monthsInput.addEventListener('input', function() {
prompts.txt CHANGED
@@ -1 +1,2 @@
1
- Create an app...Dr Shafi Anesthesia Dosage Dosage Calculator This calculator provides anesthesia dosages based on patient weight. To use, enter the patient's weight in kilograms or their age in years and months. Drug Name Minimum Dose (mg/kg) Maximum Dose (mg/kg) Glycopyrrolate 0.005 0.01 Ondansetron 0.05 0.1 Midazolam 0.05 0.1 Atropine 0.01 0.02 Fentanyl 1 2 Propofol 2 3 Atracurium 0.5 0.5 Rocuronium 0.6 1.2 Ketamine Sedation 0.2 0.8 Ketamine Induction 0.5 2 Ketamine IM Sedation 2 4 Neostigmine 0.05 0.05 Lidocaine 1 2 Dexamethasone 0.15 15 Succinylcholine 1 2 Paracetamol IV 10 15 Paracetamol Suppository 20 30... Below that in another section..for Paracetamol merge maximum and minimum cells,if weight >25kg calculate IV dosage as 10-15mg/kg and if weight<=25 kg Calculated as suppository dosage as 20mg/kg...display output as a table with Row headings as Drug,Dosage, Calculated dosage, maximum 1 decimal point,use banded columns,Bold row and column headings
 
 
1
+ Create an app...Dr Shafi Anesthesia Dosage Dosage Calculator This calculator provides anesthesia dosages based on patient weight. To use, enter the patient's weight in kilograms or their age in years and months. Drug Name Minimum Dose (mg/kg) Maximum Dose (mg/kg) Glycopyrrolate 0.005 0.01 Ondansetron 0.05 0.1 Midazolam 0.05 0.1 Atropine 0.01 0.02 Fentanyl 1 2 Propofol 2 3 Atracurium 0.5 0.5 Rocuronium 0.6 1.2 Ketamine Sedation 0.2 0.8 Ketamine Induction 0.5 2 Ketamine IM Sedation 2 4 Neostigmine 0.05 0.05 Lidocaine 1 2 Dexamethasone 0.15 15 Succinylcholine 1 2 Paracetamol IV 10 15 Paracetamol Suppository 20 30... Below that in another section..for Paracetamol merge maximum and minimum cells,if weight >25kg calculate IV dosage as 10-15mg/kg and if weight<=25 kg Calculated as suppository dosage as 20mg/kg...display output as a table with Row headings as Drug,Dosage, Calculated dosage, maximum 1 decimal point,use banded columns,Bold row and column headings
2
+ Calculate weight using formula if not already given