Jose Science Project Class 12
Jose Science Project Class 12
2. ACKNOWLEDGEMENT 3
3. AIM 4
4. PROJECT ANALYSIS 5
5. FUNCTIONS AND 7
MODULES
6. DETAILED 9
DESCRIPTION
7. SOURCE CODE 10
8. SCREENSHOTS 14
9. BIBLIOGRAPHY 15
ACKNOWLEDGEMENT
HOSPITAL
MANAGEMENT
APPLICATION
-----------------------------------------------------------------
PROJECT ANALYSIS
Our application program is specially designed for
hospitals .
con=s1.connect(host="localhost",user="root",password=passw)
cur=con.cursor()
cur.execute("CREATE DATABASE IF NOT EXISTS HOS_MNGMNT")
con.close()
con=s1.connect(host="localhost",user="root",password=passw,database="HOS_MNGMNT")
cur=con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS PATIENTS(Pat_id int,Pat_name varchar(30),Pat_age
int,Phno char(10),Pat_housename varchar(30),Pat_dept varchar(30))")
def add():
con=s1.connect(host="localhost",user="root",password=passw,database="HOS_MNGMNT")
cur=con.cursor()
patient_id=int(input("Enter Patient's ID"))
patient_name=input("Enter Patient's Name")
patient_age=int(input("Enter Patient's Age"))
phone_number=input("Enter Patient's Phone Number")
while phone_number.isdigit():
break
else:
print("Phone number should be numbers")
phno=input("Enter Patient's Phone Number")
house_name=input("Enter Patient's House Name")
department=input("Department")
query='INSERT INTO PATIENTS(Pat_id,Pat_name,Pat_age,Phno,Pat_housename,Pat_dept)
VALUES(%s,%s,%s,%s,%s,%s)'
values=(patient_id,patient_name,patient_age,phone_number,house_name,department)
cur.execute(query,values)
con.commit()
print()
print("Successfully added",patient_name)
con.close()
def search_update():
con=s1.connect(host="localhost",user="root",password=passw,database="HOS_MNGMNT")
cur=con.cursor()
record=None
print("Before updating a record verification is required")
patient_id=int(input("Enter patients id "))
sql="select * from patients where pat_id={}".format(patient_id)
cur.execute(sql)
record=cur.fetchone()
ans=False
try:
if(patient_id==record[0]):
ans=True
print("Patient id found...update new phone number.")
if ans==True:
phone_no=int(input("Enter phone number:"))
age=int(input('Enter age:'))
house_name=input("Enter Patient's House Name")
department=input("Department")
patient_address=input("Enter patient's addresss")
doctor_name=input("Enter doctor's name")
sql1="Update patients set Phno=%s where pat_id=%s"
val1=(phone_no,patient_id)
cur.execute(sql1,val1)
con.commit()
sql2="Update patients set Pat_age=%s where pat_id=%s"
val2=(age,patient_id)
cur.execute(sql2,val2)
con.commit()
sql3="Update patients set Pat_housename=%s where pat_id=%s"
val3=(house_name,patient_id)
cur.execute(sql3,val3)
con.commit()
sql4="Update patients set Pat_dept=%s where pat_id=%s"
val4=(department,patient_id)
cur.execute(sql4,val4)
con.commit()
sql5="Update patients set Pat_address=%s where pat_id=%s"
val5=(patient_address,patient_id)
cur.execute(sql5,val5)
con.commit()
sql6="Update patients set Doc_name=%s where pat_id=%s"
val6=(doctor_name,patient_id)
cur.execute(sql6,val6)
con.commit()
print("Update successfully...")
else:
print("Wrong entry...")
except:
print("Not found.Please enter valid patient_id. ")
def delt():
con=s1.connect(host="localhost",user="root",password=passw,database="HOS_MNGMNT")
cur=con.cursor()
nm=input("Enter name:")
query="DELETE FROM patients WHERE Pat_name=%s"
cur.execute(query,(nm,))
if cur.rowcount == 0:
print("No records found with that name.")
else:
con.commit()
print("Successfully deleted")
con.close()
def disp():
print("1.Display all records")
print("2.Display n records")
print("3.Display first record")
ans="y"
while ans=="y" or ans=="Y":
ch=int(input("Enter your choice(1-3):"))
if ch==1:
con=s1.connect(host="localhost",user="root",password=passw,database="HOS_MNGMNT")
cur=con.cursor()
cur.execute("SELECT * FROM patients")
x=cur.fetchall()
if len(x)==0:
print("There are no records available.")
else:
for row in x:
print(row)
con.close()
elif ch==2:
con=s1.connect(host="localhost",user="root",password=passw,database="HOS_MNGMNT")
cur=con.cursor()
cur.execute("SELECT * FROM patients")
n=int(input("Enter the number of records to be displayed:"))
print("Displaying",n,"records")
x=cur.fetchmany(n)
if len(x)==0:
print("There are no records available.")
else:
for row in x:
print(row)
con.close()
elif ch==3:
con=s1.connect(host="localhost",user="root",password=passw,database="HOS_MNGMNT")
cur=con.cursor()
cur.execute("SELECT * FROM patients")
print("Displaying first record")
x=cur.fetchone()
if len(x)==0:
print("There are no records available.")
else:
print(x)
con.close()
else:
print("Invalid choice..")
ans=input("Do you want to perform more operations?(y/n):")
while True:
print()
print("Available options are:")
print()
print("1.Add")
print("2.Delete")
print("3.Update")
print("4.Display")
print("5.Exist")
print()
try:
n=int(input("Enter your choice:"))
if n==1:
add()
elif n==2:
delt()
elif n==3:
search_update()
elif n==4:
disp()
elif n==5:
break
else:
print("Invalid choice")
continue
except ValueError:
print("Invalid input. Please enter a number.")
FUNCTIONS AND MODULES
MODULES:
Import mysql.connector:
By importing this package, we are able to establish
the connection between SQL and Python.
FUNTIONS:
connect():
This function establishes connection between Python
and MYSQL
cursor():
It is a special control structure that facilitates the
row-by-row processing of records in the result set.
The Syntax is:
<cursor object><connection object>.cursor()
execute():
This function is used to execute the sql query and
retrieve records using python.
The Syntax is :
<cursor object >.execute(<sql query string>)
JAWAHAR NAVODAYA
VIDYALAYA IDUKKI 2024-25
COMPUTER SCIENCE
PROJECT
fetchall():
This function will return all the rows from the result set
in the form of a tuple containing the records.
commit():
This function provides changes in the database
physically.
def search_update():
This function allows the user to search the details of the
patient and update it if needed.
DETAILED DESCRIPTION
Our Project has 1 MySQL table:
1) Patients
a) Pat_id
b) Pat_name
c) Pat_age
d) Phno
e) Pat_housename
f) Pat_dep
BIBLIOGRAPHY
https://www.upgrad.com/blog/computer-science
project-ideas-topics-beginners/
https://www.geeksforgeeks.org/computer-science-
projects/
JAWAHAR NAVODAYA VIDYALAYA
IDUKKI 2024-25
CERTIFICATE
This is to certify that this bonafide project work in the
subject of Computer Science has been done by
Josepaul Jude Christy of class XII in the academic year
2024-25 and submitted to AISSCE practical
examination conducted by CBSE at JNV IDUKKI on
TEACHER IN
PRINCIPAL
CHARGE
EXTERNAL EXAMINER