-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdmin.java
211 lines (192 loc) · 5.93 KB
/
Admin.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
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Toeols | Templates
* and open the template in the editor.
*/
package hospitalmanagementsystem;
import javax.swing.*;
import java.awt.event.*;
import java.util.Scanner;
/**
*
* @author Fame
*/
public class Admin {
private final String username;
private final String password;
private Doctor doctors[];
private Patients patient[];
private int count=0;
private int size;
private Bill bills;
public Admin(){
this.username="[email protected]";
this.password="PIMS123";
size=0;
}
public Admin(String username, String password) {
this.username = "[email protected]";
this.password = "PIMS123";
if(this.username.equals(username)&&this.password.equals(password)){
System.out.println("YOU HAVE SUCCESSFULLY LOGGED IN");
}
else{
System.out.println("INVALID USERNAME OR PASSWORD");
}
size=0;
}
public Admin(int size){
doctors=new Doctor[size];
patient=new Patients[size];
this.username="[email protected]";
this.password="PIMS123";
this.size=size;
}
public String getUsername() {
return "[email protected]";
}
public String getPassword() {
return "PIMS123";
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
@Override
public String toString() {
return "Admin{" + "username=" + username + ", password=" + password + '}';
}
public void admitNewPatient(Patients p){
try{
if(count<size){
patient[count]=p;
count++;
System.out.println(count);
System.out.println("PATIENT ADDED SUCCESSFULLY");
}
else{
throw new Exception();
}
}
catch(Exception e){
System.out.println("NO MORE SAPCE!!");
}
}
public Patients dischargePatient(int id){
Patients pat=new Patients();
for(int i=0;i<count;i++){
if(id==patient[i].getId()){
patient[i].getName();
patient[i].getAge();
patient[i].getDisease();
patient[i].getGender();
patient[i].getId();
patient[i]=null;
System.out.println("DISCHARGED SUCCESSFULLY!!");
}
}
return pat;
}
public void viewPatientDetails(){
System.out.println("***********PATIENTS ADMITTED ARE************");
for(int j=0;j<count;j++){
System.out.println(patient[j]);
}
}
public void addDoctor(Doctor d){
try{
if(count<size){
doctors[count]=d;
count++;
System.out.println(count);
System.out.println("DOCTOR ADDED SUCCESSFULLY!!");
}
else{
throw new Exception();
}
}
catch(Exception e){
System.out.println("NO MORE SAPCE!!");
}
}
public Doctor fireDoctor(int id){
Doctor doc=new Doctor();
for(int i=0;i<count;i++){
if(id==doctors[i].getId()){
doctors[i].getName();
doctors[i].getId();
doctors[i].getContact();
doctors[i].getFee();
doctors[i].getSpecialization();
doctors[i]=null;
System.out.println("FIRED SUCCESSFULLY!!");
}
}
return doc;
}
public void confirmAppointment(){
try{
System.out.println("PATIENTS WHO GOT APPOINTMENT ARE");
for(int i=0;i<count;i++){
System.out.println( "NAME OF PATIENT "+(i+1)+" IS "+patient[i].getName());
System.out.println( "ID OF PATIENT "+(i+1)+" IS "+patient[i].getId());
}
}catch(NullPointerException e){
}
}
public void viewDoctorDetails(){
System.out.println("DOCTOR'S ADDED ARE");
for(int i=0;i<count;i++){
System.out.println(doctors[i]);
}
}
public void testsBill(int pId){
try{
Bill bill=new Bill();
Scanner input=new Scanner(System.in);
for(int i=0;i<count;i++){
if(pId==patient[i].getId()){
System.out.println("ENTER THE NAME OF TEST WHICH DOCTOR HAS RECOMMENDED YOU");
String name=input.nextLine();
if(name.equalsIgnoreCase("XRAY")){
bill.setBillNo(i+1);
bill.setName(patient[i].getName());
bill.setAmount( bill.calculateBill(name));
System.out.println("\t\t*********BILL RECIEPT***********");
System.out.println(bill.toString());
}
else if(name.equalsIgnoreCase("CTSCAN")){
bill.setBillNo(i+1);
bill.setName(patient[i].getName());
bill.setAmount( bill.calculateBill(name));
System.out.println("\t\t*********BILL RECIEPT***********");
System.out.println(bill.toString());
}
else if(name.equalsIgnoreCase("BLOODTEST")){
bill.setName(patient[i].getName());
bill.setAmount( bill.calculateBill(name));
System.out.println("\t\t*********BILL RECIEPT***********");
System.out.println(bill.toString());
}
else{
System.out.println("NO SUCH TEST FACILITY IS REQUIRED IN THIS HOSPITAL");
}
}
}
}
catch(NullPointerException e){
}
}
public void seeDoctorFee(int dId){
try{
for(int i=0;i<count;i++){
if(dId==doctors[i].getId()){
System.out.println("DOCTOR "+doctors[i].getName()+" FEE IS "+doctors[i].getFee());
}
}
}
catch(NullPointerException e){
}
}}