0% found this document useful (0 votes)
5 views12 pages

Python Mini Project

The document outlines a Python-based Diabetes Diagnosis System developed by students at PSG College of Technology, which collects patient health details, calculates BMI, analyzes glucose levels, and diagnoses diabetes status using an SQLite database. The system employs libraries such as Pandas, NumPy, and SQLite3 to manage data and generate patient reports. The conclusion highlights the system's effectiveness in healthcare applications and suggests future enhancements for improved accuracy and user experience.

Uploaded by

atishridwik9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views12 pages

Python Mini Project

The document outlines a Python-based Diabetes Diagnosis System developed by students at PSG College of Technology, which collects patient health details, calculates BMI, analyzes glucose levels, and diagnoses diabetes status using an SQLite database. The system employs libraries such as Pandas, NumPy, and SQLite3 to manage data and generate patient reports. The conclusion highlights the system's effectiveness in healthcare applications and suggests future enhancements for improved accuracy and user experience.

Uploaded by

atishridwik9
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PSG COLLEGE OF TECHNOLOGY

PEELAMEDU-641004

PYTHON MINI PROJECT REPORT


1 YEAR BTech IT(Information Technology)

By:
Nishita L (25I239)
Atish Ridwik R (25I244)
Ridhanishaa N L (25I246)
Samiksha G (25I253)
Sharvesh A P (25I256)
AIM:
To develop a Python-based Diabetes Diagnosis System that collects
patient health details, calculates BMI, analyzes glucose levels and
symptoms, determines diabetes status, classifies the type of diabetes,
and stores patient records using an SQLite database.

OBJECTIVES:
The objectives of the Diabetes Diagnosis System are:
1. To collect patient health details.
2. To calculate and analyze BMI.
3. To evaluate glucose levels.
4. To analyze diabetes symptoms.
5. To diagnose diabetic condition.
6. To identify the type of diabetes.
7. To store and display patient records.

SYSTEM DESCRIPTION:
The Diabetes Diagnosis System is developed using Python and
integrates the libraries Pandas, NumPy, and SQLite3.
Modules Used
• Pandas: Used for displaying and managing patient records in
tabular form.
• NumPy: Used for BMI calculation and symptom analysis.
• SQLite3: Used for storing patient information permanently in a
database.
Working of the System
1. Database Creation
The program creates a SQLite database named diabetes_patient.db
and creates a table called patients to store patient details.
2. Input Collection
The system collects:
• Patient name
• Age
• Height
• Weight
• Glucose level
• Diabetes-related symptoms
3. BMI Calculation
BMI is calculated using the formula:
𝑤𝑒𝑖𝑔ℎ𝑡
𝐵𝑀𝐼 =
(ℎ𝑒𝑖𝑔ℎ𝑡/100)2
Based on the BMI value, the patient is categorized as:
• Underweight
• Normal
• Overweight
• Obese
4. Glucose Level Analysis
The glucose level is analyzed and classified into:
• Normal
• Prediabetes
• Diabetes
5. Symptom Analysis
The system checks symptoms such as:
• Frequent thirst
• Frequent urination
• Fatigue
• Weight loss
NumPy arrays are used to count the number of symptoms entered as
“yes”.
6. Diagnosis Logic
The patient is diagnosed as Diabetic if:
• Glucose level ≥ 126
• BMI ≥ 30
• Symptom count ≥ 2
Otherwise, the patient is classified as Non-Diabetic.
7. Diabetes Type Identification
• Patients below 30 years are classified as Type 1 Diabetes.
• Patients aged 30 or above are classified as Type 2 Diabetes.
8. Report Generation
The program retrieves stored records from the database and displays a
formatted patient report containing:
• Personal details
• BMI and glucose status
• Symptoms count
• Diagnosis result
• Diabetes type
SOURCE CODE:
import pandas as pd

import numpy as np

import sqlite3

print("===== DIABETES DIAGNOSIS SYSTEM =====")

# Connect to database (fresh start to avoid errors)

conn = [Link]("diabetes_patient.db")

cursor = [Link]()

# Recreate table (important fix for column mismatch)

[Link]("DROP TABLE IF EXISTS patients")

[Link]("""

CREATE TABLE patients (

patient_name TEXT,

age INTEGER,

height REAL,

weight REAL,

glucose_level REAL,

glucose_status TEXT,

bmi REAL,

bmi_status TEXT,

symptoms_count INTEGER,

diagnosis TEXT,

diabetes_type TEXT

""")
# Input details

name = input("Enter Patient Name: ")

age = int(input("Enter Age: ").strip())

height = float(input("Enter Height (in meters): "))

weight = float(input("Enter Weight (in kg): "))

glucose = float(input("Enter Glucose Level: "))

# BMI calculation

bmi = [Link](weight / ((height/100) ** 2), 2)

# BMI status

if bmi < 18.5:

bmi_status = "Underweight"

elif bmi < 25:

bmi_status = "Normal"

elif bmi < 30:

bmi_status = "Overweight"

else:

bmi_status = "Obese"

# Glucose status

if 70 <= glucose <= 99:

glucose_status = "Normal"

elif 100 <= glucose <= 125:

glucose_status = "Prediabetes"

else:

glucose_status = "Diabetes"
# Symptoms input

print("\nEnter Symptoms (yes/no)")

thirst = input("Frequent Thirst: ").lower()

urination = input("Frequent Urination: ").lower()

fatigue = input("Fatigue/Tiredness: ").lower()

weight_loss = input("Weight Loss: ").lower()

# NumPy symptom processing

symptoms = [Link]([

thirst == "yes",

urination == "yes",

fatigue == "yes",

weight_loss == "yes"

])

symptom_count = int([Link](symptoms))

# Diagnosis logic

if glucose >= 126 and bmi >= 30 and symptom_count >= 2:

diagnosis = "Diabetic"

else:

diagnosis = "Non-Diabetic"

# Diabetes type

if diagnosis == "Diabetic":

if age < 30:

diabetes_type = "Type 1 Diabetes"

else:

diabetes_type = "Type 2 Diabetes"

else:
diabetes_type = "No Diabetes"

# Insert into database

[Link]("""

INSERT INTO patients VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

""", (

name,

age,

height,

weight,

glucose,

glucose_status,

bmi,

bmi_status,

symptom_count,

diagnosis,

diabetes_type

))

[Link]()

# Fetch all records

all_records = pd.read_sql_query("SELECT * FROM patients", conn)

# Patient reports one by one

print("\n====================================\n")

for index, row in all_records.iterrows():

print("====================================")
print(f" PATIENT REPORT ")

print("====================================")

print(f"Patient Name : {row['patient_name']}")

print(f"Age : {row['age']}")

print(f"Height (m) : {row['height']}")

print(f"Weight (kg) : {row['weight']}")

print(f"Glucose Level : {row['glucose_level']}")

print(f"Glucose Status : {row['glucose_status']}")

print(f"BMI : {row['bmi']}")

print(f"BMI Status : {row['bmi_status']}")

print(f"Symptoms Count : {row['symptoms_count']}")

print(f"Diagnosis : {row['diagnosis']}")

print(f"Diabetes Type : {row['diabetes_type']}")

print("====================================\n")

# Final status

print("===== HEALTH STATUS =====")

if diagnosis == "Diabetic":

print(f"{name} may have {diabetes_type}.")

print("Medical consultation is recommended.")

else:

print(f"{name} is currently Non-Diabetic.")

[Link]()
OUTPUT:
===== DIABETES DIAGNOSIS SYSTEM =====

Enter Patient Name: Arun

Enter Age: 25

Enter Height (in meters): 169

Enter Weight (in kg): 68

Enter Glucose Level: 66

Enter Symptoms (yes/no)

Frequent Thirst: Yes

Frequent Urination: No

Fatigue/Tiredness: Yes

Weight Loss: Yes

====================================

====================================

PATIENT REPORT

====================================

Patient Name : Arun

Age : 25

Height (m) : 169.0

Weight (kg) : 68.0

Glucose Level : 66.0

Glucose Status : Diabetes

BMI : 23.81

BMI Status : Normal

Symptoms Count : 3

Diagnosis : Non-Diabetic

Diabetes Type : No Diabetes

====================================
===== HEALTH STATUS =====

Arun is currently Non-Diabetic.

** Process exited - Return Code: 0 **

CONCLUSION:
The Diabetes Diagnosis System is an effective healthcare application
developed using Python. The system collects patient information,
calculates BMI, evaluates glucose levels, and analyzes symptoms to
identify diabetic conditions. It also classifies the type of diabetes
based on the patient’s age and health data.
The use of NumPy improves calculation efficiency, Pandas helps in
organizing and displaying reports, and SQLite provides secure storage
of patient records. The program generates clear and detailed patient
reports, making the diagnosis process simple and user-friendly.
This project demonstrates how programming and database
management can be applied in the medical field to support basic
health analysis and record maintenance. The system reduces manual
effort, improves accuracy, and provides quick results. It can be further
enhanced in the future by adding graphical interfaces, advanced
medical parameters, and machine learning techniques for more
accurate diabetes prediction.

You might also like