forked from loopccoew/Buffer_3.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HospitalMain.java
152 lines (122 loc) · 4.54 KB
/
HospitalMain.java
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
package loop;
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class HospitalMain {
static PatientList plist = new PatientList();
static DoctorList dlist = new DoctorList();
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String choice;
while (true) {
MainMenu();
choice = sc.nextLine();
if (choice.equals("1")) {
System.out.println("\nDoctor Id ");
String Id = sc.nextLine();
System.out.println("\nDoctor Name ");
String name = sc.nextLine();
System.out.println("\nDoctor Speciality ");
String spec = sc.nextLine();
System.out.println("\nDoctor fees ");
int fees = sc.nextInt();
sc.nextLine();
Doctor d = new Doctor(Id, name, spec, fees);
dlist.Insert(d);
} else if (choice.equals("2")) {
System.out.println("\nPatient Id");
String Id = sc.nextLine();
System.out.println("\nPatient Name");
String Name = sc.nextLine();
System.out.println("\nPatient Age");
String Age = sc.nextLine();
System.out.println("\nPatient Contact number");
String ContNo = sc.nextLine();
System.out.println("\nPatient Blood group");
String BloodGrp = sc.nextLine();
Patient patient = new Patient(Id, Name, Age, ContNo, BloodGrp);
plist.Insert(patient);
} else if (choice.equals("3")) {
dlist.PrintData();
} else if (choice.equals("4")) {
plist.PrintData();
} else if (choice.equals("5")) {
System.out.println("\n");
System.out.println(" ______________________________________________ ");
System.out.println(" | WELCOME TO CHECKUP LIST | ");
System.out.println(" |______________________________________________| ");
CheckUpList[] clist = new CheckUpList[dlist.Size()];
for (int i = 0; i < clist.length; i++) {
clist[i] = new CheckUpList();
Doctor doctor = dlist.getAtIndex(i);
System.out.println("\nEnter Patient for Doctor");
System.out.println("\nName : " + doctor.getName());
System.out.println("\nSpeciality :" + doctor.getSpeciality());
System.out.println("\nFees : " + doctor.getFees());
System.out.println("\nAll Patient : ");
plist.PrintData();
while (true) {
System.out.println("Enter patient Id or type null to stop");
String Id = sc.nextLine();
if (Id.equals("null")) {
break;
}
System.out.println("priority 3 for emergency , 2 for intermidiate , any other key for normal");
String per = sc.nextLine();
int p = 1;
if (per.equals("3")) {
p = 3;
} else if (per.equals("2")) {
p = 2;
}
Patient patient = plist.searchById(Id);
if (patient == null) {
System.out.println("\n Invalid Patient ID:\n");
} else {
Checkup cup = new Checkup(doctor, patient, p, "",
"" + java.util.Calendar.getInstance().getTime().toString());
clist[i].Enqueue(cup);
}
}
}
for (int i = 0; i < clist.length; i++) {
System.out
.println("\n\n Patient" + (i + 1) + "In Queue for doctor " + dlist.getAtIndex(i).getName());
}
}
else if(choice.equals("6"))
{
System.out.println("Enter Speciality Which you want to search");
String speciality =sc.next();
dlist.searchBySpeciality(speciality);
}
else if(choice.equals("7"))
{
System.out.println("Enter Name of patient to search");
String name =sc.next();
plist.searchByName(name);
}
else if (choice.equals("0")) {
break;
}
}
}
public static void MainMenu() {
System.out.println("\n");
System.out.println(" *************************************************** ");
System.out.println(" * Hospital Manegment System * ");
System.out.println(" * Main Menu * ");
System.out.println(" *************************************************** ");
System.out.println("Enter 1 for insert new doctor");
System.out.println("Enter 2 for insert patient");
System.out.println("Enter 3 for print all doctor ");
System.out.println("Enter 4 for print all patient");
System.out.println("Enter 5 for CheckUp Menu");
System.out.println("nEnter 6 for Search doctor by Speciality ");
System.out.println("nEnter 7 for Search patient by name ");
System.out.println("Enter 0 for exit ");
}
}