-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathhospitalm.py
282 lines (247 loc) · 15 KB
/
hospitalm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
while (True):
print("""
================================
Welcome To District Hospital
================================
""")
# creating database connectivity
import mysql.connector
p = str(input("Enter the Password Please!!:"))
mysql = mysql.connector.connect( host="localhost", user="root", passwd=p)
mycursor = mysql.cursor()
mycursor.execute("create database if not exists city_hospitals")
mycursor.execute("use city_hospitals")
# tables
mycursor.execute("create table if not exists patient_detail(name varchar(30) primary key,sex varchar(15),age int(3),address varchar(50),contact varchar(15))")
mycursor.execute("create table if not exists doctor_details(name varchar(30) primary key,specialisation varchar(40),age int(2),address varchar(30),contact varchar(15),fees int(10),monthly_salary int(10))")
mycursor.execute("create table if not exists nurse_details(name varchar(30) primary key,age int(2),address varchar(30),contact varchar(15),monthly_salary int(10))")
mycursor.execute("create table if not exists other_workers_details(name varchar(30) primary key,age int(2),address varchar(30),contact varchar(15),monthly_salary int(10))")
# login/register
mycursor.execute("create table if not exists login_data(username varchar(30) primary key,password varchar(30) default'000')")
while (True):
print("""
1. Sign In
2. Registration
""")
r = int(input("enter your choice:"))
if r == 2:
print("""
=======================================
!!!!!!!!!!Register Yourself!!!!!!!!
=======================================
""")
u = input("Input your username!!:")
p = input("Input the password (Note:Password must be strong!:")
mycursor.execute("insert into login_data values('" + u + "','" + p + "')")
mysql.commit()
print("""
============================================
!!Registration Done Successfully!!
============================================
""")
x = input(" Press any key to continue:")
# IF USER WANTS TO LOGIN
elif r == 1:
print("""
==================================
!!!!!!!! {{Sign In}} !!!!!!!!!!
==================================
""")
usern = input("Enter Username!!:")
psw = input("Enter Password!!:")
mycursor.execute("select password from user_data where username='" + usern+ "'")
row = mycursor.fetchall()
for i in row:
a = list(i)
if a[0] == str(psw):
while (True):
print("""
1.Hospital Administration Details
2.Patient Details
3.Sign Out
""")
a = int(input("ENTER YOUR CHOICE:"))
if a == 1:
print("""
1. Display the details
2. Add a new member
3. Delete a member
4. Make an exit
""")
b = int(input("Enter your Choice:"))
if b == 1:
print("""
1. Doctors Details
2. Nurse Details
3. Others
""")
c = int(input("Enter your Choice:"))
if c == 1:
mycursor.execute("select * from doctor_details")
for i in mycursor:
print(i)
b=0
print('\n')
# displays nurses details
elif c == 2:
mycursor.execute("select * from nurse_details")
for i in mycursor:
print(i)
# displays worker details
elif c == 3:
mycursor.execute("select * from other_workers_details")
for i in mycursor:
print(i)
# IF USER WANTS TO ENTER DETAILS
elif b == 2:
print("""
1. Doctor Details
2. Nurse Details
3. Others
""")
c = int(input("ENTER YOUR CHOICE:"))
# enter doctor details
if c == 1:
name = input("Enter the doctor's name")
spe = input("Enter the specilization:")
age = input("Enter the age:")
add = input("Enter the address:")
cont = input("Enter Contact Details:")
fees = input("Enter the fees:")
ms = input("Enter Monthly Salary:")
mycursor.execute("insert into doctor_details values('" + name + "','" + spe +"','" + age + "','" + add + "','" + cont + "','" + fees + "','" + ms + "')")
mysql.commit()
print("SUCCESSFULLY ADDED")
# for nurse details
elif c == 2:
name = input("Enter Nurse name:")
age = input("Enter age:")
add = input("Enter address:")
cont = input("Enter Contact No:")
ms = int(input("Enter Monthly Salary"))
mycursor.execute("insert into nurse_details values('" + name + "','" + age + "','" + add + "','" + cont + "','" + str(ms) + "')")
mysql.commit()
print("SUCCESSFULLY ADDED")
# for entering workers details
elif c == 3:
name = input("Enter worker name:")
age = input("Enter age:")
add = input("Enter address:")
cont = input("Enter Contact No.:")
ms = input("Enter Monthly Salary:")
mycursor.execute("insert into other_workers_details values('" +name + "','" + age + "','" + add + "','" + cont + "','" + ms + "')")
mysql.commit()
print("SUCCESSFULLY ADDED")
# to delete data
elif b == 3:
print("""
1. Doctor Details
2. Nurse Details
3. Others
""")
c = int(input("Enter your Choice:"))
# deleting doctor's details
if c == 1:
name = input("Enter Doctor's Name:")
mycursor.execute( "select * from doctor_details where name='" + name + "'")
row = mycursor.fetchall()
print(row)
p = input("Do you really want to delete this data? (y/n):")
if p == "y":
mycursor.execute("delete from doctor_details where name='" + name + "'")
mysql.commit()
print("SUCCESSFULLY DELETED!!")
else:
print("NOT DELETED")
# deleting nurse details
elif c == 2:
name = input("Enter Nurse Name:")
mycursor.execute(
"select * from nurse_details where name='" + name + "'")
row = mycursor.fetchall()
print(row)
p = input(" Do you really wanna delete this data? (y/n):")
if p == "y":
mycursor.execute("delete from nurse_details where name='" + name + "'")
mysql.commit()
print("SUCCESSFULLY DELETED!!")
else:
print("NOT DELETED")
# deleting other_workers details
elif c == 3:
name = input("Enter the worker Name")
mycursor.execute(
"select * from workers_details where name='" + name + "'")
row = mycursor.fetchall()
print(row)
p = input(" Do you really wanna delete this data? (y/n):")
if p == "y":
mycursor.execute(
"delete from other_workers_details where name='" + name + "'")
mysql.commit()
print("SUCCESSFULLY DELETED!!")
else:
print("NOT DELETED")
elif b == 4:
break
# entering the patient details table
elif a == 2:
print("""
1. Show Patients Info
2. Add New Patient
3. Discharge Summary
4. Exit
""")
b = int(input("Enter your Choice:"))
# showing the existing details
# if user wants to see the details of PATIENT
if b == 1:
flag=0
mycursor.execute("select * from patient_detail")
for i in mycursor:
print(i)
flag=1
if(flag==0):
print("=========================")
print(" NO patient admitted")
print("==========================")
# adding new patient
elif b == 2:
name = input("Enter your name ")
sex = input("Enter the gender: ")
age = input("Enter age: ")
address = input("Enter address: ")
contact = input("Contact Details: ")
mycursor.execute("insert into patient_detail values('" + name + "','" + sex + "','" +age + "','" + address + "','" + contact + "')")
mysql.commit()
mycursor.execute("select * from patient_detail")
for i in mycursor:
print(i)
v = list(i)
print("""
====================================
!!!!!!! Patient Registered Successfully!!!!!!
====================================
""")
# dischage
elif b == 3:
name = input("Enter the Patient Name:")
mycursor.execute("select * from patient_detail where name='" + name + "'")
row = mycursor.fetchall()
print(row)
bill = input("Has he paid all the bills? (y/n):")
if bill == "y":
mycursor.execute(
"delete from patient_detail where name='" + name + "'")
mysql.commit()
print("=====================================\n")
print(" Patient Discharged Successfully")
print("=====================================\n")
elif b == 4:
break
# SIGN OUT
elif a == 3:
break
# IF THE USERNAME AND PASSWORD IS NOT IN THE DATABASE
else:
break