-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHospitalManagementSystem.java
More file actions
466 lines (415 loc) · 15.5 KB
/
Copy pathHospitalManagementSystem.java
File metadata and controls
466 lines (415 loc) · 15.5 KB
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
import java.util.ArrayList;
import java.util.Scanner;
public class HospitalManagementSystem {
private static Scanner sc = new Scanner(System.in);
// Main menu
public static void main(String[] args) {
while (true) {
System.out.println("\n* * * * * Hospital Management System * * * * *");
System.out.println("1. Patient Management");
System.out.println("2. Appointment Management");
System.out.println("3. Electronic Health Records (EHR)");
System.out.println("4. Billing Management");
System.out.println("5. Inventory Management");
System.out.println("6. Staff Management");
System.out.println("7. Exit");
System.out.print("Enter your choice: ");
int choice = sc.nextInt();
switch (choice) {
case 1:
PatientManager.menu();
break;
case 2:
AppointmentManager.menu();
break;
case 3:
EHRManager.menu();
break;
case 4:
BillingManager.menu();
break;
case 5:
InventoryManager.menu();
break;
case 6:
StaffManager.menu();
break;
case 7:
System.out.println("Exiting system. Goodbye!");
return;
default:
System.out.println("Invalid choice. Try again.");
}
}
}
// PatientManager Class
static class PatientManager {
static ArrayList<Patient> patients = new ArrayList<>();
static void menu() {
while (true) {
System.out.println("\n* * * Patient Management * * *");
System.out.println("1. Add Patient");
System.out.println("2. View Patients");
System.out.println("3. Back to Main Menu");
System.out.print("Enter your choice: ");
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
registerPatient();
break;
case 2:
viewPatients();
break;
case 3:
return;
default:
System.out.println("Invalid choice. Try again.");
}
}
}
static void registerPatient() {
System.out.print("Enter name: ");
String name = sc.nextLine();
System.out.print("Enter age: ");
int age = sc.nextInt();
sc.nextLine();
System.out.print("Enter gender: ");
String gender = sc.nextLine();
patients.add(new Patient(name, age, gender));
System.out.println("Patient registered successfully.");
}
static void viewPatients() {
if (patients.isEmpty()) {
System.out.println("No patients registered.");
return;
}
System.out.println("\n* * * Registered Patients * * *");
for (int i = 0; i < patients.size(); i++) {
System.out.println((i + 1) + ". " + patients.get(i));
}
}
static class Patient {
String name;
int age;
String gender;
Patient(String name, int age, String gender) {
this.name = name;
this.age = age;
this.gender = gender;
}
public String toString() {
return "Name: " + name + ", Age: " + age + ", Gender: " + gender;
}
}
}
// AppointmentManager Class
static class AppointmentManager {
static ArrayList<Appointment> appointments = new ArrayList<>();
static void menu() {
while (true) {
System.out.println("\n* * * Appointment Management * * *");
System.out.println("1. Book Appointment");
System.out.println("2. View Appointments");
System.out.println("3. Back to Main Menu");
System.out.print("Enter your choice: ");
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
bookAppointment();
break;
case 2:
viewAppointments();
break;
case 3:
return;
default:
System.out.println("Invalid choice. Try again.");
}
}
}
static void bookAppointment() {
System.out.print("Enter patient name: ");
String patientName = sc.nextLine();
System.out.print("Enter doctor name: ");
String doctorName = sc.nextLine();
System.out.print("Enter date (DD/MM/YYYY): ");
String date = sc.nextLine();
appointments.add(new Appointment(patientName, doctorName, date));
System.out.println("Appointment booked successfully.");
}
static void viewAppointments() {
if (appointments.isEmpty()) {
System.out.println("No appointments scheduled.");
return;
}
System.out.println("\n* * * Appointments * * *");
for (int i = 0; i < appointments.size(); i++) {
System.out.println((i + 1) + ". " + appointments.get(i));
}
}
static class Appointment {
String patientName;
String doctorName;
String date;
Appointment(String patientName, String doctorName, String date) {
this.patientName = patientName;
this.doctorName = doctorName;
this.date = date;
}
public String toString() {
return "Patient: " + patientName + ", Doctor: " + doctorName + ", Date: " + date;
}
}
}
// Electronic Health Records (EHR)
static class EHRManager {
static ArrayList<EHR> ehrRecords = new ArrayList<>();
static void menu() {
while (true) {
System.out.println("\n* * * Electronic Health Records * * *");
System.out.println("1. Add Record");
System.out.println("2. View Records");
System.out.println("3. Back to Main Menu");
System.out.print("Enter your choice: ");
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
addRecord();
break;
case 2:
viewRecords();
break;
case 3:
return;
default:
System.out.println("Invalid choice. Try again.");
}
}
}
static void addRecord() {
System.out.print("Enter patient name: ");
String patientName = sc.nextLine();
System.out.print("Enter diagnosis: ");
String diagnosis = sc.nextLine();
System.out.print("Enter treatment: ");
String treatment = sc.nextLine();
ehrRecords.add(new EHR(patientName, diagnosis, treatment));
System.out.println("Record added successfully.");
}
static void viewRecords() {
if (ehrRecords.isEmpty()) {
System.out.println("No records available.");
return;
}
System.out.println("\n* * * EHR Records * * *");
for (int i = 0; i < ehrRecords.size(); i++) {
System.out.println((i + 1) + ". " + ehrRecords.get(i));
}
}
static class EHR {
String patientName;
String diagnosis;
String treatment;
EHR(String patientName, String diagnosis, String treatment) {
this.patientName = patientName;
this.diagnosis = diagnosis;
this.treatment = treatment;
}
public String toString() {
return "Patient: " + patientName + ", Diagnosis: " + diagnosis + ", Treatment: " + treatment;
}
}
}
// BillingManager Class
static class BillingManager {
static ArrayList<Bill> bills = new ArrayList<>();
static void menu() {
while (true) {
System.out.println("\n* * * Billing Management * * *");
System.out.println("1. Create Bill");
System.out.println("2. View Bills");
System.out.println("3. Back to Main Menu");
System.out.print("Enter your choice: ");
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
createBill();
break;
case 2:
viewBills();
break;
case 3:
return;
default:
System.out.println("Invalid choice. Try again.");
}
}
}
static void createBill() {
System.out.print("Enter patient name: ");
String patientName = sc.nextLine();
System.out.print("Enter amount: ");
double amount = sc.nextDouble();
sc.nextLine();
bills.add(new Bill(patientName, amount));
System.out.println("Bill created successfully.");
}
static void viewBills() {
if (bills.isEmpty()) {
System.out.println("No bills available.");
return;
}
System.out.println("\n* * * Bills * * *");
for (int i = 0; i < bills.size(); i++) {
System.out.println((i + 1) + ". " + bills.get(i));
}
}
static class Bill {
String patientName;
double amount;
Bill(String patientName, double amount) {
this.patientName = patientName;
this.amount = amount;
}
public String toString() {
return "Patient: " + patientName + ", Amount:₹ " + amount;
}
}
}
// InventoryManager Class
static class InventoryManager {
static ArrayList<InventoryItem> inventory = new ArrayList<>();
static void menu() {
while (true) {
System.out.println("\n* * * Inventory Management * * *");
System.out.println("1. Add Item");
System.out.println("2. View Inventory");
System.out.println("3. Update Stock");
System.out.println("4. Back to Main Menu");
System.out.print("Enter your choice: ");
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
addItem();
break;
case 2:
viewInventory();
break;
case 3:
updateStock();
break;
case 4:
return;
default:
System.out.println("Invalid choice. Try again.");
}
}
}
static void addItem() {
System.out.print("Enter item name: ");
String name = sc.nextLine();
System.out.print("Enter quantity: ");
int quantity = sc.nextInt();
sc.nextLine();
inventory.add(new InventoryItem(name, quantity));
System.out.println("Item added successfully.");
}
static void viewInventory() {
if (inventory.isEmpty()) {
System.out.println("Inventory is empty.");
return;
}
System.out.println("\n* * * Inventory * * *");
for (int i = 0; i < inventory.size(); i++) {
System.out.println((i + 1) + ". " + inventory.get(i));
}
}
static void updateStock() {
viewInventory();
if (inventory.isEmpty()) return;
System.out.print("Enter item number to update: ");
int index = sc.nextInt() - 1;
if (index < 0 || index >= inventory.size()) {
System.out.println("Invalid item number.");
return;
}
System.out.print("Enter new quantity: ");
int quantity = sc.nextInt();
sc.nextLine();
inventory.get(index).quantity = quantity;
System.out.println("Stock updated successfully.");
}
static class InventoryItem {
String name;
int quantity;
InventoryItem(String name, int quantity) {
this.name = name;
this.quantity = quantity;
}
public String toString() {
return "Item: " + name + ", Quantity: " + quantity;
}
}
}
// StaffManager Class
static class StaffManager {
static ArrayList<Staff> staffList = new ArrayList<>();
static void menu() {
while (true) {
System.out.println("\n* * * Staff Management * * *");
System.out.println("1. Add Staff");
System.out.println("2. View Staff");
System.out.println("3. Back to Main Menu");
System.out.print("Enter your choice: ");
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
addStaff();
break;
case 2:
viewStaff();
break;
case 3:
return;
default:
System.out.println("Invalid choice. Try again.");
}
}
}
static void addStaff() {
System.out.print("Enter staff name: ");
String name = sc.nextLine();
System.out.print("Enter role: ");
String role = sc.nextLine();
staffList.add(new Staff(name, role));
System.out.println("Staff added successfully.");
}
static void viewStaff() {
if (staffList.isEmpty()) {
System.out.println("No staff registered.");
return;
}
System.out.println("\n* * * Staff List * * *");
for (int i = 0; i < staffList.size(); i++) {
System.out.println((i + 1) + ". " + staffList.get(i));
}
}
static class Staff {
String name;
String role;
Staff(String name, String role) {
this.name = name;
this.role = role;
}
public String toString() {
return "Name: " + name + ", Role: " + role;
}
}
}
}