Cs Final Project
Cs Final Project
MrS.MAHALAKSHMI RAMESH
B.Ss.,M.C.A.,M.Phil.,B.Ed.
(Computer Science Faculty)
Hardware and
2. software 1
requirements
3. Python 2
Overview
4. CSV files 3
Overview
5. Source Code 4
Output
6. screens 14
7. Bibliograph 18
ABOUT PROJECT
This project focuses on hospital
management system by using python and
CSV file.
Hardware requirements:
Laptop
Minimum 1GB of ram
Minimum of 100GB HDD
Software requirements:
Windows operating system
Python 3. 12. 5
PYTHON OVERVIEW
Python is a high level, interpreted,
interactive and object oriented Scripted
language. Python is a designed to be highly
readable. It uses English keywords
frequently where as other languages use
punctuation, and it has fewer syntactical
constructions than other languages.
import os
import csv
def newPatient():
print("Add a new patient record")
print("======================
========")
with open('Patient.csv', 'a', newline='') as
f:
s = csv.writer(f)
patient_id = input('Enter Patient ID: ')
patient_name = input('Enter Patient
Name: ')
disease = input('Enter Disease: ')
fee = float(input('Enter Fee: '))
doctor_name = input('Enter Name of
the Doctor: ')
print("----------------------------------------")
rec = [patient_id, patient_name,
disease, fee, doctor_name]
s.writerow(rec)
print("Patient Record Saved")
input("Press any key to continue..")
def editPatient():
print("Modify a Patient Record")
print("======================
======")
with open('Patient.csv', 'r', newline='') as
f, open('temp.csv', 'w', newline='') as f1:
r = input('Enter Patient ID to modify: ')
s = csv.reader(f)
s1 = csv.writer(f1)
modified = False
for rec in s:
if rec[0] == r:
print("-------------------------------------")
print("Patient ID:", rec[0])
print("Patient Name:", rec[1])
print("Disease:", rec[2])
print("Fee:", rec[3])
print("Name of the Doctor:",
rec[4])
print("-------------------------------------")
choice = input("Do you want to
modify this patient record (y/n)? ")
if choice.lower() == 'y':
print("-----------------------------------------------------
--------------------------")
patient_id = input('Enter new
Patient ID (leave blank if not required): ') or
rec[0]
patient_name = input('Enter
new Patient Name (leave blank if not
required): ') or rec[1]
disease = input('Enter Disease
(leave blank if not required): ') or rec[2]
fee = input('Enter Fee (leave
blank if not required): ')
fee = float(fee) if fee else
rec[3]
doctor_name = input('Enter
Name of the Doctor (leave blank if not
required): ') or rec[4]
print("-----------------------------------------------------
--------------------------")
rec = [patient_id,
patient_name, disease, fee, doctor_name]
modified = True
s1.writerow(rec)
if modified:
print("Patient record modified.")
else:
print("No record modified.")
os.remove("Patient.csv")
os.rename("temp.csv", "Patient.csv")
input("Press any key to continue..")
def delPatient():
print("Delete a Patient Record")
with open('Patient.csv', 'r', newline='') as
f, open('temp.csv', 'w', newline='') as f1:
r = input('Enter Patient ID to delete: ')
s = csv.reader(f)
s1 = csv.writer(f1)
found = False
for rec in s:
if rec[0] == r:
print("---------------------------------------")
print("Patient ID:", rec[0])
print("Patient Name:", rec[1])
print("Disease:", rec[2])
print("Fee:", rec[3])
print("Name of the Doctor:",
rec[4])
print("---------------------------------------")
choice = input("Do you want to
delete this patient record (y/n)? ")
if choice.lower() == 'y':
found = True
print("Patient record deleted.")
continue # Skip writing this
record
s1.writerow(rec)
if not found:
print("Patient ID not found.")
os.remove("Patient.csv")
os.rename("temp.csv", "Patient.csv")
input("Press any key to continue..")
def searchPatient():
print("Search a Patient Record")
print("======================
========")
with open('Patient.csv', 'r', newline='') as
f:
r = input('Enter Patient ID to search: ')
s = csv.reader(f)
found = False
for rec in s:
if rec[0] == r:
print("------------------------------")
print("Patient ID:", rec[0])
print("Patient Name:", rec[1])
print("Fee:", rec[3])
print("Name of the Doctor:",
rec[4])
print("------------------------------")
found = True
break
if not found:
print("Patient ID not found.")
input("Press any key to continue..")
def listofPatients():
print("======================
========================")
print(" List of All Patients")
print("======================
========================")
with open('Patient.csv', 'r', newline='') as
f:
s = csv.reader(f)
for rec in s:
print("\t\t".join(rec))
print("------------------------------------------------")
input("Press any key to continue..")
def menu():
while True:
print("\n")
print("|--------------------------|")
print("| Hospital Management System
|")
print("|--------------------------|")
print("\n")
print("######################
###########")
print(" Menu")
print("######################
###########")
print("1. Add a new Patient Record")
print("2. Modify Existing Patient")
print("3. Delete Existing Patient")
print("4. Search a Patient")
print("5. List all Patients")
print("6. Exit")
print("---------------------------------")
choice = int(input('Enter your choice:
'))
print("---------------------------------")
if choice == 1:
newPatient()
elif choice == 2:
editPatient()
elif choice == 3:
delPatient()
elif choice == 4:
searchPatient()
elif choice == 5:
listofPatients()
elif choice == 6:
print("Exiting the software...")
break
else:
print("Invalid choice, please try
again.")
menu()
OUTPUT SCREENS
BIBILOGRAPHY:
1)Progress in computr with python
-Dhanpat Rai &
Co[publisher]
-Sumita Arora[AUTHOR]
2)Computer scienece with python:
-Sultan chand [publisher]
-Preeti Arora [AUTHOR]
3)Computer science:
-New Saraswathi house
[Publisher]
-Harsha basin[ Auhtor]