Document
Document
connector
import pandas as pd
import numpy as np
import datetime
# Database Connection
mycursor = mydb.cursor()
print("""
*********************************
FINAL PROJECT
*********************************
""")
print("""
""")
def initialize_tables():
mycursor.execute("""
CREATE TABLE IF NOT EXISTS patients (
""")
mycursor.execute("""
""")
mycursor.execute("""
""")
mycursor.execute("""
CREATE TABLE IF NOT EXISTS bills (
""")
mycursor.execute("""
""")
mycursor.execute("""
""")
mycursor.execute("""
""")
initialize_tables()
# Patient Functions
def add_patient():
mydb.commit()
def view_patients():
patients = mycursor.fetchall()
if not patients:
else:
patient = mycursor.fetchone()
if patient:
else:
def delete_patient():
mydb.commit()
if mycursor.rowcount:
else:
def update_patient():
name = input("Enter new Patient Name (leave blank to keep current): ")
age = input("Enter new Patient Age (leave blank to keep current): ")
gender = input("Enter new Patient Gender (leave blank to keep current): ")
contact = input("Enter new Patient Contact (leave blank to keep current):
")
updates = []
if name:
updates.append(f"name = '{name}'")
if age:
updates.append(f"age = {age}")
if gender:
updates.append(f"gender = '{gender}'")
if contact:
updates.append(f"contact = '{contact}'")
if updates:
mydb.commit()
else:
# Doctor Functions
def add_doctor():
mydb.commit()
def view_doctors():
doctors = mycursor.fetchall()
if not doctors:
else:
def search_doctor():
doctor = mycursor.fetchone()
if doctor:
else:
def delete_doctor():
mydb.commit()
if mycursor.rowcount:
else:
def update_doctor():
name = input("Enter new Doctor Name (leave blank to keep current): ")
updates = []
if name:
updates.append(f"name = '{name}'")
if specialization:
updates.append(f"specialization = '{specialization}'")
if contact:
updates.append(f"contact = '{contact}'")
if updates:
mydb.commit()
# Appointment Functions
def schedule_appointment():
try:
mydb.commit()
except ValueError:
def view_appointments():
appointments = mycursor.fetchall()
if not appointments:
else:
appointments = mycursor.fetchall()
if not appointments:
else:
def view_appointments_by_doctor():
appointments = mycursor.fetchall()
if not appointments:
else:
# Billing Functions
def add_bill():
try:
mydb.commit()
except ValueError:
def view_bills():
bills = mycursor.fetchall()
if not bills:
else:
def view_bills_by_patient():
bills = mycursor.fetchall()
if not bills:
# Inventory Functions
def add_inventory():
mydb.commit()
def view_inventory():
inventory = mycursor.fetchall()
if not inventory:
else:
name = input("Enter new Item Name (leave blank to keep current): ")
updates = []
if name:
updates.append(f"name = '{name}'")
if quantity:
updates.append(f"quantity = {quantity}")
if price:
updates.append(f"price = {price}")
if updates:
mydb.commit()
else:
def add_room():
def view_rooms():
rooms = mycursor.fetchall()
if not rooms:
else:
def update_room():
mydb.commit()
def add_bed():
mydb.commit()
beds = mycursor.fetchall()
if not beds:
else:
def update_bed():
mydb.commit()
# View Reports
def display_chart():
inventory = mycursor.fetchall()
categories = df.groupby('Category')['Quantity'].sum().index
quantities = df.groupby('Category')['Quantity'].sum().values
plt.show()
def display_statistics():
bills = mycursor.fetchall()
df['Date'] = pd.to_datetime(df['Date'])
df.set_index('Date', inplace=True)
monthly_totals = df['Amount'].resample('M').sum()
plt.plot(months, monthly_totals)
plt.xlabel('Month')
plt.title('Monthly Revenue')
plt.show()
# Main Menu
def main_menu():
while True:
print("""
**************************
**************************
1. Patient Management
2. Doctor Management
3. Appointment Management
4. Billing Management
5. Inventory Management
7. View Reports
8. Exit
""")
if choice == '1':
patient_menu()
doctor_menu()
appointment_menu()
billing_menu()
inventory_menu()
room_bed_menu()
reports_menu()
break
else:
# Submenus
def patient_menu():
while True:
print("""
1. Add Patient
2. View Patients
3. Search Patient
4. Delete Patient
5. Update Patient
""")
if choice == '1':
add_patient()
view_patients()
search_patient()
delete_patient()
update_patient()
elif choice == '6':
break
else:
def doctor_menu():
while True:
print("""
1. Add Doctor
2. View Doctors
3. Search Doctor
4. Delete Doctor
5. Update Doctor
""")
if choice == '1':
add_doctor()
view_doctors()
search_doctor()
delete_doctor()
break
else:
def appointment_menu():
while True:
print("""
1. Schedule Appointment
2. View Appointments
""")
if choice == '1':
schedule_appointment()
view_appointments()
view_appointments_by_patient()
view_appointments_by_doctor()
else:
def billing_menu():
while True:
print("""
1. Add Bill
2. View Bills
""")
if choice == '1':
add_bill()
view_bills()
view_bills_by_patient()
break
else:
def inventory_menu():
while True:
print("""
2. View Inventory
3. Update Inventory
""")
if choice == '1':
add_inventory()
view_inventory()
update_inventory()
break
else:
def room_bed_menu():
while True:
print("""
1. Add Room
2. View Rooms
3. Update Room
4. Add Bed
5. View Beds
6. Update Bed
""")
if choice == '1':
add_room()
view_rooms()
update_room()
add_bed()
view_beds()
update_bed()
break
else:
def reports_menu():
while True:
print("""
""")
if choice == '1':
display_chart()
display_statistics()
break
else:
main_menu()