44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
/**
|
|
* TriageEngine: Analyzes symptoms and generates follow-up questions.
|
|
* In a real app, this would call Gemini 1.5 Flash.
|
|
*/
|
|
|
|
class TriageEngine {
|
|
constructor() {
|
|
this.categories = {
|
|
URGENT: { label: "Urgent", color: "#EF4444" },
|
|
MODERATE: { label: "Moderate", color: "#F59E0B" },
|
|
ROUTINE: { label: "Routine", color: "#10B981" }
|
|
};
|
|
}
|
|
|
|
async analyzeSymptoms(symptoms) {
|
|
const text = symptoms.toLowerCase();
|
|
|
|
// Simple keyword-based triage (Simulation)
|
|
if (text.includes('chest pain') || text.includes('breath') || text.includes('dizzy')) {
|
|
return {
|
|
category: "URGENT",
|
|
summary: "Patient reporting possible cardiovascular or respiratory distress.",
|
|
followUp: "How long have you been feeling this pain? Is it spreading to your arm or neck?"
|
|
};
|
|
}
|
|
|
|
if (text.includes('fever') || text.includes('cough') || text.includes('stomach')) {
|
|
return {
|
|
category: "MODERATE",
|
|
summary: "Patient reporting common infection symptoms.",
|
|
followUp: "What is your current temperature? Do you have any other symptoms like body ache?"
|
|
};
|
|
}
|
|
|
|
return {
|
|
category: "ROUTINE",
|
|
summary: "General consultation or mild symptoms.",
|
|
followUp: "Are you here for a regular checkup or a specific issue?"
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = new TriageEngine();
|