COMPUTER SCIENCE PROJECT
COMPUTER SCIENCE PROJECT
Uses of MySQL
• Data Warehousing:
• E-Commerce Applications:
• Education Sector:
• Telecommunications:
Software Requirements:
1. Python 3.x
o An Integrated Development
Environment facilitates easier coding,
debugging, and project management.
Existing vs. Proposed System Existing System:
Manual record-keeping with a high chance of
human errors. Difficult to retrieve patient data
efficiently. No automated symptom analysis or
disease prediction. Proposed System: Uses a
structured MySQL database for efficient data
storage and retrieval. Automates symptom-
based disease diagnosis. Generates reports for
patient history and recommended precautions.
extend it like above
1. Proposed System:
1. Uses a Structured MySQL Database for
Efficient Data Storage and Retrieval
# Connect to MySQL
try:
conn =
mysql.connector.connect(
host="localhost",
user="root",
password="9C@akshat"
)
cursor = conn.cursor()
print(Fore.GREEN + "
Connected to the database
successfully!" +
Style.RESET_ALL)
except mysql.connector.Error as
err:
print(Fore.RED + f"
Error: {err}" + Style.RESET_ALL)
exit()
# Use database
cursor.execute("CREATE DATABASE
IF NOT EXISTS diagnosis_db")
cursor.execute("USE
diagnosis_db")
# Create tables
cursor.execute("DROP TABLE IF
EXISTS symptoms") # Prevent
duplicate symptoms
cursor.execute("""
CREATE TABLE symptoms (
id INT PRIMARY KEY
AUTO_INCREMENT,
name VARCHAR(50),
category VARCHAR(50)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS
patients (
name VARCHAR(50) NOT
NULL,
age INT,
gender CHAR(1),
phone CHAR(10) PRIMARY
KEY,
dob DATE
)
""")
conn.commit()
# Register a patient
def register_patient():
print(Fore.BLUE + "===
Register Patient ===" +
Style.RESET_ALL)
name = input("Enter
patient's name: ")
age = input("Enter age: ")
gender = input("Enter gender
(M/F): ").upper()
phone = input("Enter phone
number (10 digits): ")
dob = input("Enter date of
birth (YYYY-MM-DD): ")
cursor.execute(
"INSERT INTO patients
(name, age, gender, phone, dob)
VALUES (%s, %s, %s, %s, %s)",
(name, age, gender,
phone, dob)
)
conn.commit()
print(Fore.GREEN + "
Patient registered
successfully!" +
Style.RESET_ALL)
return {
"time_period":
time_period,
"hunger": hunger,
"body_temp": body_temp,
"hydration": hydration,
"travel": travel
}
# Select symptoms
def select_symptoms():
print(Fore.BLUE + "\n===
Select Symptoms ===" +
Style.RESET_ALL)
cursor.execute("SELECT
DISTINCT category FROM
symptoms")
categories =
cursor.fetchall()
selected = []
for category in categories:
print(Fore.CYAN +
f"\n{category[0]} Symptoms:" +
Style.RESET_ALL)
cursor.execute("SELECT
id, name FROM symptoms WHERE
category = %s", (category[0],))
symptoms =
cursor.fetchall()
for symptom in symptoms:
print(f"{symptom[0]}
. {symptom[1]}")
selected.extend(input("E
nter symptom IDs (comma-
separated, or leave blank to
skip): ").split(','))
return [symptom.strip() for
symptom in selected if
symptom.strip().isdigit()]
cursor.execute("SELECT *
FROM diseases")
diagnoses = []
for disease in
cursor.fetchall():
disease_symptoms =
set(disease[2].split(','))
match =
(len(set(symptoms) &
disease_symptoms) /
len(disease_symptoms)) * 100 if
disease_symptoms else 0
# **Modify match
probability based on health
data**
if "week" in
health_data["time_period"]:
match += 10 #
Increase probability for long-
term conditions
if
health_data["body_temp"] > 38.3:
match += 15 #
Increase chances for Flu, COVID-
19
if health_data["hunger"]
== "Y":
match += 10 #
Increase probability of
digestive issues
if health_data["travel"]
== "Y":
match += 10 #
Increase probability of
infections
diagnoses.append({'name'
: disease[1], 'prevention':
disease[3], 'doctor':
disease[4], 'match':
round(match, 2)})
return diagnoses
if choice == '1':
register_patient()
elif choice == '2':
patient_name =
input("Enter patient's name: ")
phone = input("Enter
patient's phone number: ")
symptoms =
select_symptoms()
health_data =
ask_health_questions()
diagnosed_diseases =
diagnose(symptoms, patient_name,
phone, health_data)
if
diagnosed_diseases:
generate_report(
patient_name, phone,
diagnosed_diseases, health_data)
elif choice == '3':
break
to cloud services to
allow seamless access
to patient records from
multiple locations.
oEnsuring data security
and compliance with
healthcare regulations.
3. IoT and Wearable Device
Support
Integrating real-time
o
worldwide .
Conclusion
The Patient Diagnosis System using Python and
MySQL successfully demonstrates how
technology can assist in medical diagnosis by
automating symptom analysis. The system helps
in reducing manual efforts, improving accuracy,
and maintaining a structured patient database.
This project serves as a foundational step toward
integrating AI and machine learning in future
healthcare applications.
The proposed advancements such as cloud
storage, wearable device integration, and voice-
based support could make the system even more
powerful and accessible. As healthcare technology
evolves, such systems will play a vital role in
making medical diagnosis more efficient and
patient-friendly.
Limitations
Despite its advantages, the project has certain
limitations:
• The accuracy of diagnosis depends on
predefined symptom-disease mapping.
• The system does not yet integrate real-time
AI-based learning.
• No graphical user interface (GUI) is currently
implemented, making it command-line
dependent.
• Requires internet connectivity for cloud-based
enhancements.
Bibliography / References
The following resources were referred to while
developing this project:
• Python Official Documentation:
https://docs.python.org/
• MySQL Official Documentation:
https://dev.mysql.com/doc/
• Online programming communities and forums
(Stack Overflow, GeeksforGeeks, W3Schools)
• Books and resources on Database
Management Systems (DBMS) and Python
programme