import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df=pd.read_csv("/Users/saranyarayaprolu/Desktop/2024 hospital.csv")
print(df.head(100))
import os
# Create file if it doesn't exist
if not os.path.exists('patients.txt'):
file = open('patients.txt', 'w')
file.close()
while True:
print("Welcome to the Hospital Management System")
print("1. Admin")
print("2. Patient")
print("3. Sign Out")
role = input("Select your role (1/2/3): ")
if role == "1":
while True:
print("\nAdmin Options:")
print("1. Add New Patient Record")
print("2. Delete Patient Record")
print("3. Check Monthly Record")
print("4. Back to Main Menu")
admin_choice = input("Enter your choice: ")
if admin_choice == "1":
patient = {
"PatientID": input("Enter Patient ID: "),
"Name": input("Enter Patient Name: "),
"Age": input("Enter Patient Age: "),
"Gender": input("Enter Patient Gender (M/F/Other): "),
"Illness": input("Enter Patient's illness: "),
"Phone": input("Enter Patient Phone Number: "),
"DOA": input("enter the date of Admission: "),
"DoD": input("enter the date of discharge: "),
"doctor": input("Enter the doctors name: ").split(","),
}
# Open file and read records
file = open('patients.txt', 'r')
records = file.readlines()
file.close()
# Add new patient record to the list
records.append(str(patient) + "\n")
# Open file and write updated records
file = open('patients.txt', 'w')
file.writelines(records)
file.close()
print("Patient record added successfully!")
elif admin_choice == "2":
patient_id = input("Enter Patient ID to delete: ")
# Open file and read records
file = open('patients.txt', 'r')
records = file.readlines()
file.close()
# Remove the record matching the PatientID
updated_records = [record for record in records if f"PatientID': '{patient_id}" not in
record]
# Open file and write updated records
file = open('patients.txt', 'w')
file.writelines(updated_records)
file.close()
print("Patient record deleted successfully!")
elif admin_choice == "3":
# Step added: Ask for Patient ID
patient_id = input("Enter Patient ID to view record: ")
# Open file and read records
file = open('patients.txt', 'r')
records = file.readlines()
file.close()
# Find the patient record matching the PatientID
patient_record = next((record for record in records if f"PatientID': '{patient_id}" in
record), None)
if patient_record:
print("Patient Record Found:")
print(patient_record.strip())
else:
print("Patient record not found.")
elif admin_choice == "4":
break
else:
print("Invalid choice, please try again.")
elif role == "2":
patient_id = input("Enter your Patient ID: ")
while True:
print("\nPatient Options:")
print("1. View Patient Details")
print("2. View Payment Details")
print("3. Back to Main Menu")
patient_choice = input("Enter your choice: ")
if patient_choice == "1":
# Open file and read records
file = open('patients.txt', 'r')
records = file.readlines()
file.close()
patient_record = next((record for record in records if f"PatientID': '{patient_id}" in
record), None)
if patient_record:
print(patient_record.strip())
else:
print("Patient record not found.")
elif patient_choice == "2":
print("Payment details functionality coming soon.")
elif patient_choice == "3":
break
else:
print("Invalid choice, please try again.")
elif role == "3":
print("Signing out... Goodbye!")
break
else:
print("Invalid input, please select a valid option.")