-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_validation_direct.html
More file actions
55 lines (49 loc) · 1.67 KB
/
Copy pathtest_validation_direct.html
File metadata and controls
55 lines (49 loc) · 1.67 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
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>Direct Validation Test</title></head>
<body style="background:#0f172a;color:#f1f5f9;font-family:monospace;padding:20px">
<h1>Direct Validation Test</h1>
<button onclick="testValidation()">Run Test</button>
<pre id="output"></pre>
<script>
// Copy the exact validation functions from your file
function parseDosage(dosageStr) {
const match = dosageStr.match(/(\d+(?:\.\d+)?)\s*(mg|mcg|µg|g|iu|ml)?/i);
if (!match) return null;
let amount = parseFloat(match[1]);
let unit = (match[2] || 'mg').toLowerCase();
if (unit === 'µg') unit = 'mcg';
return { amount, unit, originalUnit: unit };
}
function testValidation() {
const output = document.getElementById('output');
let results = 'TEST RESULTS:\n\n';
// Test cases
const tests = [
{ name: 'Zinc', dose: '12222222' },
{ name: 'A', dose: '2222222' },
{ name: 'Tylanol', dose: '299999999999' }
];
tests.forEach(test => {
const parsed = parseDosage(test.dose);
results += `Medication: ${test.name}\n`;
results += `Dosage: ${test.dose}\n`;
results += `Parsed: ${JSON.stringify(parsed)}\n`;
if (parsed) {
const amountInMg = parsed.amount;
results += `Amount in mg: ${amountInMg}\n`;
results += `> 50000? ${amountInMg > 50000}\n`;
results += `> 10000? ${amountInMg > 10000}\n`;
if (amountInMg > 50000) {
results += '🚨 CRITICAL - SHOULD BLOCK!\n';
} else if (amountInMg > 10000) {
results += '⚠️ DANGER - SHOULD WARN!\n';
} else {
results += '✅ Safe\n';
}
}
results += '\n---\n\n';
});
output.textContent = results;
}
</script>
</body></html>