SUNIL CS PROJECT 12YH
SUNIL CS PROJECT 12YH
Principal
ACKNOWLEDGMENT
It is with pleasure that I acknowledge my
sincere gratitude to our teacher, MR.
YOGESH KUMAR NAMA who taught and
undertook the responsibility of teaching the
subject computer science. I have been
greatly benefited from his classes. I am
especially indebted to our Principal MR.
MOHAN MEGHWAL who has always been a
source of encouragement and support and
without whose inspiration this project would
not have been a successful I would like to
place on record heartfelt thanks to him.
Finally, I would like to express my sincere
appreciation for all the other students for my
batch their friendship & the fine time that we
all shared together
HARDWARE AND SOFTWARE REQUIRED:
HARDWARE
1. PC
2. MOBILE PHONE
SOFTWARE
• PYTHON (latest version)
• MYSQL
• PYTHON CONNECTOR
HOSPITAL
A hospital is a health care institution providing patient
treatment with specialized staff and equipment. Hospital are
usually funded by public sector by health organizations (for
profit or non-profit), by health insurance companies, or by
departments (e.g. , surgery, and urgent care etc).
ADMIN
• ADD PATIENTS
• ADD STAFF
• CHANGE PASSWORD
• REMOVE PATIENTS
• REMOVE STAFF
• UPDATE PATIENT
• ADD DOCTOR
• REMOVE DOCTOR
PATIENT
• BOOK APPOINTMENT
• FIND DOCTOR
DOCTER
• LOGIN
• APPLY JOB
• VIEW APPOINTMENT
import tkinter as tk
from tkinter import messagebox, ttk
import mysql.connector
from datetime import date
# MySQL connection
def connect_to_database():
return mysql.connector.connect(
host="localhost",
user="root", # Replace with your MySQL username
password="root", # Replace with your MySQL password
database="eprescription"
)
# Add Prescription
def add_prescription():
try:
conn = connect_to_database()
cursor = conn.cursor()
patient_name = entry_name.get()
age = entry_age.get()
gender = gender_var.get()
contact = entry_contact.get()
diagnosis = entry_diagnosis.get("1.0", tk.END).strip()
medicine = entry_medicine.get("1.0", tk.END).strip()
prescription_date = date.today()
if not (patient_name and age and gender and contact and diagnosis and
medicine):
messagebox.showerror("Error", "All fields are required!")
return
cursor.execute(query, data)
conn.commit()
conn.close()
conn = connect_to_database()
cursor = conn.cursor()
query = "SELECT * FROM prescriptions WHERE patient_name LIKE %s"
cursor.execute(query, (f"%{name}%",))
rows = cursor.fetchall()
conn.close()
# Delete Prescription
def delete_prescription():
try:
selected_item = tree.focus()
if not selected_item:
messagebox.showerror("Error", "Select a record to delete!")
return
record = tree.item(selected_item)["values"]
conn = connect_to_database()
cursor = conn.cursor()
query = "DELETE FROM prescriptions WHERE id = %s"
cursor.execute(query, (record[0],))
conn.commit()
conn.close()
messagebox.showinfo("Success", "Prescription deleted successfully!")
view_prescriptions()
except Exception as e:
messagebox.showerror("Error", f"Something went wrong: {e}")
# Update Prescription
def update_prescription():
try:
selected_item = tree.focus()
if not selected_item:
messagebox.showerror("Error", "Select a record to update!")
return
record = tree.item(selected_item)["values"]
patient_name = entry_name.get()
age = entry_age.get()
gender = gender_var.get()
contact = entry_contact.get()
diagnosis = entry_diagnosis.get("1.0", tk.END).strip()
medicine = entry_medicine.get("1.0", tk.END).strip()
if not (patient_name and age and gender and contact and diagnosis and
medicine):
messagebox.showerror("Error", "All fields are required!")
return
conn = connect_to_database()
cursor = conn.cursor()
query = """
UPDATE prescriptions
SET patient_name = %s, age = %s, gender = %s, contact = %s, diagnosis =
%s, medicine = %s
WHERE id = %s
"""
data = (patient_name, age, gender, contact, diagnosis, medicine,
record[0])
cursor.execute(query, data)
conn.commit()
conn.close()
# Print Prescription
def print_prescription():
try:
selected_item = tree.focus()
if not selected_item:
messagebox.showerror("Error", "Select a record to print!")
return
record = tree.item(selected_item)["values"]
details = (
f"JNV MI ROOM\n\n"
f"Patient Name: {record[1]}\n"
f"Age: {record[2]}\n"
f"Gender: {record[3]}\n"
f"Contact: {record[4]}\n"
f"Diagnosis: {record[5]}\n"
f"Medicines: {record[6]}\n"
f"Date: {record[7]}\n"
)
messagebox.showinfo("Prescription", details)
except Exception as e:
messagebox.showerror("Error", f"Something went wrong: {e}")
# GUI
root = tk.Tk()
root.title("E-Prescription System")
root.geometry("800x600")
# Styling
style = ttk.Style(root)
style.theme_use("clam")
# Input Fields
tk.Label(root, text="Patient Name").grid(row=0, column=0, padx=10, pady=5)
entry_name = tk.Entry(root)
entry_name.grid(row=0, column=1, padx=10, pady=5)
# Search Field
tk.Label(root, text="Search by Name").grid(row=0, column=2, padx=10, pady=5)
entry_search = tk.Entry(root)
entry_search.grid(row=0, column=3, padx=10, pady=5)
btn_search = tk.Button(root, text="Search", command=search_prescription)
btn_search.grid(row=0, column=4, padx=10, pady=5)
# Buttons
btn_add = tk.Button(root, text="Add", command=add_prescription)
btn_add.grid(row=6, column=0, pady=10)