-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.h
More file actions
130 lines (107 loc) · 5.16 KB
/
header.h
File metadata and controls
130 lines (107 loc) · 5.16 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <windows.h>
#include <unordered_map>
using namespace std;
void setTextColor(int color) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, color);
}
// Function to convert input to lowercase for case-insensitive matching
string toLower(const string& str) {
string lowerStr = str;
transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(), ::tolower);
return lowerStr;
}
// Function to check if the user input contains the symptom
bool hasSymptom(const string& input, const string& symptom) {
return toLower(input).find(toLower(symptom)) != string::npos;
}
// Main function to run the disease detector
void runDiseaseDetector() {
// Initialize the disease database with a Hash Table
unordered_map<string, vector<string>> diseaseDatabase = {
{"Flu", {"fever", "cough", "sore throat", "runny nose", "body aches"}},
{"Cold", {"sneezing", "runny nose", "cough", "congestion"}},
{"COVID-19", {"fever", "cough", "shortness of breath", "loss of taste", "loss of smell"}},
{"Malaria", {"fever", "chills", "sweating", "muscle pain", "headache"}},
{"Diabetes", {"frequent urination", "increased thirst", "fatigue", "blurry vision"}},
{"Asthma", {"shortness of breath", "chest tightness", "wheezing", "cough"}},
{"Bronchitis", {"persistent cough", "chest discomfort", "mucus production"}},
{"Pneumonia", {"chest pain", "fever", "cough", "difficulty breathing"}},
{"Tuberculosis", {"persistent cough", "weight loss", "night sweats", "fever"}},
{"Migraine", {"severe headache", "sensitivity to light", "nausea", "vomiting"}},
{"Hypertension", {"headache", "dizziness", "blurred vision", "shortness of breath"}},
{"Depression", {"persistent sadness", "loss of interest", "fatigue", "insomnia"}}
// Add more diseases as needed
};
// Display greeting interface
setTextColor(10); // Light green color
cout << "\n=============================================\n";
cout << " WELCOME TO THE DISEASE DETECTOR \n";
cout << "=============================================\n";
setTextColor(15); // Reset to white color
// Display menu
cout << "\nMenu:\n";
cout << "Press 1 to Start Disease Detection\n";
cout << "Press any other key to Exit\n";
// Get user choice
char choice;
cout << "Enter your choice: ";
cin >> choice;
cin.ignore(); // To handle the newline character after entering choice
if (choice == '1') {
setTextColor(11); // Light cyan color
cout << "\nHi! I can help you detect possible diseases based on your symptoms.\n";
setTextColor(15); // Reset to white color
do {
// Symptom input
string userInput;
cout << "\nPlease enter your symptoms (separated by commas): ";
getline(cin, userInput);
userInput = toLower(userInput);
bool diseaseFound = false;
// Check each disease in the database
for (const auto& disease : diseaseDatabase) {
const string& diseaseName = disease.first;
const vector<string>& symptoms = disease.second;
// Count matching symptoms
int matchCount = 0;
for (const string& symptom : symptoms) {
if (hasSymptom(userInput, symptom)) {
matchCount++;
}
}
// Display result based on symptom match
if (matchCount > 0) {
setTextColor(14); // Yellow color for matched disease
cout << "\nPossible Disease Detected: " << diseaseName << "\n";
cout << "Matching Symptoms: " << matchCount << "/" << symptoms.size() << "\n";
setTextColor(15); // Reset to white color
diseaseFound = true;
}
}
if (!diseaseFound) {
setTextColor(12); // Red color for no matches
cout << "\nNo disease could be confidently identified based on the provided symptoms. Please consult a doctor.\n";
setTextColor(15); // Reset to white color
}
// Ask if the user wants to search again
string repeatChoice;
cout << "\nWould you like to search for another disease? (yes/no): ";
getline(cin, repeatChoice);
if (toLower(repeatChoice) != "yes" && toLower(repeatChoice) != "y") {
break;
}
} while (true);
setTextColor(10); // Light green color for exit message
cout << "\nThank you for using the Disease Detector! Take care and stay healthy!\n";
setTextColor(15); // Reset to white color
} else {
setTextColor(12); // Red color for exit message
cout << "\nExiting the Disease Detector. Stay healthy!\n";
setTextColor(15); // Reset to white color
}
}