-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
52 lines (41 loc) · 1.11 KB
/
server.js
File metadata and controls
52 lines (41 loc) · 1.11 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
const express = require("express");
const cors = require("cors");
const app = express();
app.use(cors());
app.use(express.json());
app.use(express.static("public"));
let patients = [];
let tokenNumber = 1;
// 🧠 AI Priority Logic (Simple)
function calculatePriority(patient) {
let score = 0;
if (patient.emergency) score += 50;
if (patient.age > 60) score += 20;
return score;
}
// 📝 Patient Registration
app.post("/register", (req, res) => {
const patient = req.body;
patient.token = tokenNumber++;
patient.priority = calculatePriority(patient);
patients.push(patient);
// Sort queue by priority
patients.sort((a, b) => b.priority - a.priority);
res.json({
message: "Patient Registered",
token: patient.token
});
});
// 📊 Get Queue (Admin Dashboard)
app.get("/queue", (req, res) => {
res.json(patients);
});
// 👨⚕️ Doctor Availability
let doctorAvailable = true;
app.post("/doctor-status", (req, res) => {
doctorAvailable = req.body.available;
res.json({ doctorAvailable });
});
app.listen(3000, () => {
console.log("Server running on http://localhost:3000");
});