forked from loopccoew/Buffer-5.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BufferProject.java
865 lines (842 loc) · 32.4 KB
/
BufferProject.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
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
package buffer;
//ganpati bappa morya
import java.util.*;
import java.time.LocalTime;
class Laboratory {
static void generateLabParameters() {
Random random = new Random();
int glucoseLevel = random.nextInt(200); // Random glucose level
int cholesterolLevel = random.nextInt(300); // Random cholesterol level
int hemoglobinLevel = random.nextInt(20); // Random hemoglobin level
int whiteBloodCellCount = random.nextInt(15000); // Random white bloocell count
double bodyTemperature = 35.0 + random.nextDouble() * (42.0 - 35.0); // Random body temperature
System.out.println("Glucose Level: " + glucoseLevel + " mg/dL");
System.out.println("Cholesterol Level: " + cholesterolLevel + " mg/dL");
System.out.println("Hemoglobin Level: " + hemoglobinLevel + " g/dL");
System.out.println("White Blood Cell Count: " + whiteBloodCellCount + " cells/mcL");
System.out.println("Body Temperature: " + String.format("%.2f", bodyTemperature) + " °C");
}
}
abstract class Admin {
abstract void replace(HashMap<Integer, Doctor> details);
abstract void accept(HashMap<Integer, Doctor> details);
}
class Patient {
static int idCounter = 1; // Counter to generate unique patient IDs
int id;
String name;
int age, section;
static String consultancysections[] = {"orthopedic", "gynaecologist", "ENT specialist", "Emergency", "cardiologist"};
static String doctorsections[] = {"orthopedic", "gynaecologist", "ENT specialist", "surgeon", "cardiologist"};
boolean appointmentBooked;
boolean labReportRequested;
boolean isOccupied; // New attribute to indicate bed occupancy
boolean isemergency;
LocalTime Slot;
Patient() {
id = idCounter++; // Assigning a unique ID to each patient
}
Patient(String name, int age, int section, boolean isOccupied,boolean isemergency,LocalTime Slot) {
this(); // Call the default constructor to assign ID
this.name = name;
this.age = age;
this.section = section;
this.appointmentBooked = false;
this.labReportRequested = false;
this.isOccupied = isOccupied; // Initialize bed occupancy
this.isemergency=isemergency;
this.Slot=Slot;
}
public static Comparator<Patient> BedPriorityComparator = new Comparator<Patient>() {
public int compare(Patient p1, Patient p2) {
if (p1.isOccupied && !p2.isOccupied) {
return 1; // p2 has higher priority (empty bed)
} else if (!p1.isOccupied && p2.isOccupied) {
return -1; // p1 has higher priority (empty bed)
} else {
return 0; // Equal priority
}
}
};
public static Comparator<Patient> emergencyComparator = new Comparator<Patient>() {
@Override
public int compare(Patient p3, Patient p4) {
if (p3.isemergency && !p4.isemergency) {
return 1; // p2 has higher priority (empty bed)
} else if (!p3.isemergency && p4.isemergency) {
return -1; // p1 has higher priority (empty bed)
} else {
return 0; // Equal priority
}
}
};
public String toString() {
return "\nID: " + id + "\nName: " + name + "\nAge: " + age + "\nSection for consultancy: " + consultancysections[section];
}
public void setSlot(LocalTime slot) {
this.Slot = slot;
}
public LocalTime getSlot() {
return Slot;
}
public static void viewDoctors(HashMap<Integer, Doctor> doctors, int section) {
System.out.println("Available Doctors in section: " + doctorsections[section]);
for (Map.Entry<Integer, Doctor> entry : doctors.entrySet()) {
Doctor doctor = entry.getValue();
if (doctor.section == section) {
System.out.println("ID: " + entry.getKey() + ", " + doctor);
}
}
}
}
class Doctor extends Admin {
String name, experience;
int section;
int id;
int intime;
int outtime;
String speciality[] = {"orthopedic", "gynaecologist", "ENT specialist", "surgeon", "cardiologist"};
Doctor() {
}
Doctor(String name, String experience, String speciality, int section, int intime, int outtime) {
this.name = name;
this.experience = experience;
// this.speciality = speciality;
this.section = section;
this.intime=intime;
this.outtime=outtime;
}
String[] addDoctor() {
String add[] = new String[3];
Scanner s = new Scanner(System.in);
System.out.println("Enter name of doctor to be added");
add[0] = s.nextLine();
System.out.println("Enter experience of doctor ");
add[1] = s.nextLine();
System.out.println("Enter Speciality of doctor");
add[2] = s.nextLine();
return add;
}
void replace(HashMap<Integer, Doctor> details) {
// Implement replacement logic
}
@Override
void accept(HashMap<Integer, Doctor> details) {
// Implement addition logic
}
public String toString() {
return "Name: " + name + ", Experience: " + experience + ", Speciality: " + speciality[section-1]+"\nTimings : "+
intime+" to "+outtime+" hrs";
}
public int getsection() {
return section;
}
public int getId() {
return id;
}
public int getouttime() {
return outtime;
}
public int getintime() {
return intime;
}
}
class Nurse{
String name;
int ward;
String shift;
int id;
Nurse(String name,int ward,String shift){
this.name=name;
this.ward=ward;
this.shift=shift;
}
void display() {
System.out.println("Name of the nurse : "+name);
System.out.println("ward no. assigned : "+ward);
System.out.println("Shift assigned : "+shift);
}
public String getShift() {
return shift;
}
public void setShift(String shift) {
this.shift = shift;
}
public int getWardNumber() {
return ward;
}
public String toString() {
return "Name: " + name + "\nAssigned Ward Number: " +ward + "\nAssigned Shift: " + shift;
}
public int getId() {
return id;
}
}
public class BufferProject {
public static void main(String args[]) {
int i;
int id=0;
int wardno = 0;
String newshift="c";
int nursechoice=0;
int ch=0;
int ptid=0;
int emptybed=10;
int occupiedbed=0;
LocalTime startTime1 = LocalTime.of(10,0);
LocalTime endTime1 = LocalTime.of(14,0);
LocalTime startTime2 = LocalTime.of(16,0);
LocalTime endTime2 = LocalTime.of(20,0);
//gynac
LocalTime gynacstartTime1 = LocalTime.of(10,0);
LocalTime gynacendTime1 = LocalTime.of(14,0);
LocalTime gynacstartTime2 = LocalTime.of(10,0);
LocalTime gynacendTime2 = LocalTime.of(14,0);
//ent
LocalTime entstartTime1 = LocalTime.of(10,0);
LocalTime entendTime1 = LocalTime.of(14,0);
LocalTime entstartTime2 = LocalTime.of(10,0);
LocalTime entendTime2 = LocalTime.of(14,0);
//emergency
LocalTime emstartTime1 = LocalTime.of(10,0);
LocalTime emendTime1 = LocalTime.of(14,0);
LocalTime emstartTime2 = LocalTime.of(10,0);
LocalTime emendTime2 = LocalTime.of(14,0);
//cardio
LocalTime cardstartTime1 = LocalTime.of(10,0);
LocalTime cardendTime1 = LocalTime.of(14,0);
LocalTime cardstartTime2 = LocalTime.of(10,0);
LocalTime cardendTime2 = LocalTime.of(14,0);
LocalTime Slot=LocalTime.of(0,0);
Scanner sc=new Scanner(System.in);
ArrayList<Integer> dischargeid=new ArrayList<Integer>();
ArrayList<Integer> admitid=new ArrayList<Integer>();
HashMap<Integer,Nurse> nurse=new HashMap<Integer,Nurse>();
nurse.put(101,new Nurse("Miss Shreya Gaikwad",1,"morning"));
nurse.put(102,new Nurse("Miss anjali shinde",2,"morning"));
nurse.put(103,new Nurse("Miss mayuri deshpande",3,"morning"));
nurse.put(104,new Nurse("Miss anita kelkar",1,"night"));
nurse.put(105,new Nurse("Miss sakshi burse",2,"night"));
nurse.put(106,new Nurse("Miss bhargavi dange ",3,"night"));
HashMap<Integer, Doctor> details = new HashMap<Integer, Doctor>();
details.put(100, new Doctor("Dr.Sanjay Gaikwad", "18yrs", "Surgeon", 1,10,14));
details.put(200, new Doctor("Dr.Rama Singh", "12yrs", "Gynaecologist", 2,10,14));
details.put(300, new Doctor("Dr.Shilpa Ranade", "10yrs", "ENT", 3,10,14));
details.put(400, new Doctor("Dr.Rakesh Nikam", "8yrs", "orthopedic", 4,10,14));
details.put(500, new Doctor("Dr.Vaishali Jagdale", "7yrs", "cardiologist", 5,10,14));
details.put(600, new Doctor("Dr.Komal Lodha", "15yrs", "surgeon", 1,16,20));
details.put(700, new Doctor("Dr.Pallavi Dange", "20yrs", "Gynaecologist", 2,16,20));
details.put(800, new Doctor("Dr.Avinash Chaudhari", "22yrs", "ENT", 3,16,20));
details.put(900, new Doctor("Dr.Amit Patil", "27yrs", "orthopedic", 4,16,20));
details.put(1000, new Doctor("Dr.Madhura Deshpande", "10yrs", "Cardiologist", 5,16,20));
HashMap<Integer,Patient> patient=new HashMap<Integer,Patient>();
PriorityQueue<Patient> orthoappointments = new PriorityQueue<Patient>(Patient.emergencyComparator);
PriorityQueue<Patient> gynacappointments = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue<Patient> entappointments = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue<Patient> surgeonappointments = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue<Patient> cardioappointments = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue<Patient> tempQueue = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue<Patient> bedQueue = new PriorityQueue<>(Patient.BedPriorityComparator);
System.err.println("\t\t➕ WELCOME TO PRIMECARE MULTISPECIALITY HOSPITAL ➕");
do {
System.out.println("-------------------------------------------------------------------------------");
System.out.println("\nEnter user index :");
System.out.println("\n1.Doctor\n2.patient\n3.Nurse\n4.Laboratory\n5.Admin\n6.To exit");
try {
ch=sc.nextInt();
}catch(InputMismatchException e) {
sc.nextLine();
System.out.println("Please Enter valid index !");
ch=sc.nextInt();
}
String dummy =sc.nextLine();
int dch;
switch(ch){
case 1 :
int did=0;
System.out.print("Enter your ID to login : ");
try {
did=sc.nextInt();
}catch(InputMismatchException e) {
sc.nextLine();
System.out.print("Enter valid ID");
did=sc.nextInt();
}
if(details.containsKey(did)) {
System.out.println("Logged in Successfully !");
Doctor obj=details.get(did);
do {
System.out.println("\n1.View Appointments\n2.View patient reports\n3.To admit patient\n4.To discharge patient\n5.To exit");
System.out.print("\nEnter choice :");
try {
dch=sc.nextInt();
}catch(InputMismatchException e) {
sc.next();
System.out.print("Enter valid choice !");
dch=sc.nextInt();
}
switch(dch) {
case 1:
int sec=obj.getsection();
System.out.println("\n------------Today's Appointments------------");
if(sec==1) {
for(Patient element : orthoappointments)
{
if(element.isemergency==true) {
System.out.println("\nID :"+element.id);
System.out.println("name :"+element.name);
System.err.println("Emergency case!");
}
}
for(Patient element : orthoappointments)
{
if(element.isemergency==false) {
System.out.println("\nID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
}
else if (sec==2){
for(Patient element : gynacappointments)
{
if(element.isemergency==true) {
System.out.println("ID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
for(Patient element : gynacappointments)
{
if(element.isemergency==false) {
System.out.println("\nID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
}
else if(sec==3) {
for(Patient element : entappointments)
{
if(element.isemergency==true) {
System.out.println("ID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
for(Patient element : entappointments)
{
if(element.isemergency==false) {
System.out.println("\nID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
}else if (sec==4) {
for(Patient element : surgeonappointments)
{
if(element.isemergency==true) {
System.out.println("ID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
for(Patient element : surgeonappointments)
{
if(element.isemergency==false) {
System.out.println("\nID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
}
else if(sec==5) {
for(Patient element : cardioappointments)
{
if(element.isemergency==true) {
System.out.println("ID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
for(Patient element : cardioappointments)
{
if(element.isemergency==false) {
System.out.println("\nID :"+element.id);
System.out.println("name :"+element.name);
System.out.println("Slot :"+element.getSlot());
}
}
}
else {
System.out.println("wrong section !");
}
break;
case 2:
System.out.print("Enter patient ID : ");
int rid=sc.nextInt();
if(patient.containsKey(rid)) {
System.out.println("📌 Reports :\n-----------------------------");
Laboratory.generateLabParameters();
}
else {
System.out.println("Patient with ID "+rid+" not found !");
}
break;
case 3:
System.out.print("Enter the id of patient who needs to be admitted: ");
int adid=sc.nextInt();
admitid.add(adid);
break;
case 4:
System.out.print("Enter the id of patient who needs to be discharged: ");
int dischid=sc.nextInt();
dischargeid.add(dischid);
break;
}
}while(dch<5);
} else {
System.out.println("ID not found.\nIf you forgot your ID, Recheck your details with admin!");
}
break;
case 2:
String name="c";
int age=0;
int section=0;
String speciality[] = {"orthopedic", "gynaecologist", "ENT specialist", "surgeon", "cardiologist"};
boolean isemergency=false;
String sections[]= {"orthopedic","gynaecologist","ENT specialist","Emergency","cardiologist"};
try {
System.out.print("\nEnter your name : ");
name=sc.nextLine();
System.out.print("Enter your age : ");
age=sc.nextInt();
System.out.println("\n1.orthopedic\n2.gynaecologist\n3.ENT Specialist\n4.emergency\n5.cardiologist");
System.out.print("Enter index of section : ");
section=sc.nextInt()-1;
}catch(InputMismatchException e) {
sc.next();
System.out.println("Enter valid data !");
}
if(section==3) {
isemergency=true;
}
sc.nextLine();
boolean isoccupied=true;
patient.put(++ptid,new Patient(name,age,(section),isoccupied,isemergency,Slot));
System.out.println("\nYOUR UNIQUE PATIENT ID IS :"+ptid);
System.out.println("\n1. Book Appointment");
System.out.println("2. Request Lab Reports\n3. To exit");
System.out.print("Enter your choice:");
int option = sc.nextInt();
switch (option) {
case 1:
System.out.print("Enter your patient ID :");
int patientId = sc.nextInt();
if(patient.containsKey(patientId)) {
Patient ptobj=patient.get(patientId);
System.out.println("\n1.orthopedic\n2.gynaecologist\n3.ENT Specialist\n4.Surgeon\n5.cardiologist");
System.out.print("Enter section number of doctor: ");
int appsection = sc.nextInt(); // Corrected section number
System.out.println("\nAVAILABLE DOCTORS IN THE SECTION :-"+speciality[appsection-1]);
System.out.println("--------------------------------------------------");
for (Map.Entry<Integer, Doctor> entry : details.entrySet()) {
Doctor docobj = entry.getValue();
if (docobj.getsection() == appsection) {
System.out.println("\nDoctor ID: " + entry.getKey());
System.out.println(docobj);
}
}
System.out.print("\nEnter Id of doctor who's appointment is to be booked : ");
int appid=sc.nextInt();
for (Map.Entry<Integer, Doctor> entry : details.entrySet()) {
Doctor docobj = entry.getValue();
if(appid==entry.getKey()) {
if(ptobj.isemergency==false) {
if(docobj.section==1) {
orthoappointments.add(ptobj);
for (Map.Entry<Integer, Doctor> entry1 : details.entrySet()) {
// Corrected
if (appid == entry1.getKey()) {
Doctor docobj1 = entry1.getValue();
LocalTime intime=LocalTime.of(docobj1.getintime(),0);
LocalTime outtime=LocalTime.of(docobj1.getouttime(),0);
if(LocalTime.of(10,0)==intime) {
while(startTime1.isBefore(endTime1)) {
System.out.println("Appointment booked successfully for slot timing : "+startTime1+" ✅");
ptobj.setSlot(startTime1);
startTime1=startTime1.plusMinutes(15);
break;
}
break;
}
else if(LocalTime.of(16, 0)==intime) {
while(startTime2.isBefore(endTime2)) {
System.out.println("Appointment booked successfully for slot timing : "+startTime2+" ✅");
ptobj.setSlot(startTime2);
startTime2=startTime2.plusMinutes(15);
break;
}
break;
}
}
}
}
else if(docobj.section==2) {
gynacappointments.add(ptobj);
for (Map.Entry<Integer, Doctor> entry1 : details.entrySet()) {
// Corrected
if (appid == entry1.getKey()) {
Doctor docobj1 = entry1.getValue();
LocalTime intime=LocalTime.of(docobj1.getintime(),0);
LocalTime outtime=LocalTime.of(docobj1.getouttime(),0);
if(LocalTime.of(10,0)==intime) {
while(gynacstartTime1.isBefore(gynacendTime1)) {
System.out.println("Appointment booked successfully for slot timing : "+gynacstartTime1+" ✅");
ptobj.setSlot(gynacstartTime1);
gynacstartTime1=gynacstartTime1.plusMinutes(15);
break;
}
break;
}
else if(LocalTime.of(16, 0)==intime) {
while(gynacstartTime2.isBefore(gynacendTime2)) {
System.out.println("Appointment booked successfully for slot timing : "+gynacstartTime2+" ✅");
ptobj.setSlot(gynacstartTime2);
gynacstartTime2=gynacstartTime2.plusMinutes(15);
break;
}
break;
}
}
}
}
else if(docobj.section==3) {
entappointments.add(ptobj);
for (Map.Entry<Integer, Doctor> entry1 : details.entrySet()) {
// Corrected
if (appid == entry1.getKey()) {
Doctor docobj1 = entry1.getValue();
LocalTime intime=LocalTime.of(docobj1.getintime(),0);
LocalTime outtime=LocalTime.of(docobj1.getouttime(),0);
if(LocalTime.of(10,0)==intime) {
while(entstartTime1.isBefore(entendTime1)) {
System.out.println("Appointment booked successfully for slot timing : "+entstartTime1+" ✅");
ptobj.setSlot(entstartTime1);
entstartTime1=entstartTime1.plusMinutes(15);
break;
}
break;
}
else if(LocalTime.of(16, 0)==intime) {
while(entstartTime2.isBefore(entendTime2)) {
System.out.println("Appointment booked successfully for slot timing : "+entstartTime2+" ✅");
ptobj.setSlot(entstartTime2);
entstartTime2=entstartTime2.plusMinutes(15);
break;
}
break;
}
}
}
}else if(docobj.section==4) {
surgeonappointments.add(ptobj);
for (Map.Entry<Integer, Doctor> entry1 : details.entrySet()) {
// Corrected
if (appid == entry1.getKey()) {
Doctor docobj1 = entry1.getValue();
LocalTime intime=LocalTime.of(docobj1.getintime(),0);
LocalTime outtime=LocalTime.of(docobj1.getouttime(),0);
if(LocalTime.of(10,0)==intime) {
while(emstartTime1.isBefore(emendTime1)) {
System.out.println("Appointment booked successfully for slot timing : "+emstartTime1+" ✅");
ptobj.setSlot(emstartTime1);
emstartTime1=emstartTime1.plusMinutes(15);
break;
}
break;
}
else if(LocalTime.of(16, 0)==intime) {
while(emstartTime2.isBefore(cardendTime2)) {
System.out.println("Appointment booked successfully for slot timing : "+emstartTime2+" ✅");
ptobj.setSlot(emstartTime2);
emstartTime2=emstartTime2.plusMinutes(15);
break;
}
break;
}
}
}
}
else {
cardioappointments.add(ptobj);
for (Map.Entry<Integer, Doctor> entry1 : details.entrySet()) {
// Corrected
if (appid == entry1.getKey()) {
Doctor docobj1 = entry1.getValue();
LocalTime intime=LocalTime.of(docobj1.getintime(),0);
LocalTime outtime=LocalTime.of(docobj1.getouttime(),0);
if(LocalTime.of(10,0)==intime) {
while(cardstartTime1.isBefore(cardendTime1)) {
System.out.println("Appointment booked successfully for slot timing : "+cardstartTime1+" ✅");
ptobj.setSlot(cardstartTime1);
cardstartTime1=cardstartTime1.plusMinutes(15);
break;
}
break;
}
else if(LocalTime.of(16, 0)==intime) {
while(cardstartTime2.isBefore(cardendTime2)) {
System.out.println("Appointment booked successfully for slot timing : "+cardstartTime2+" ✅");
ptobj.setSlot(cardstartTime2);
cardstartTime2=cardstartTime2.plusMinutes(15);
break;
}
break;
}
}
}
}
}
}
}
if (ptobj.isemergency==true) {
// Emergency case, give highest priority
if (appsection == 1) {
orthoappointments.add(ptobj);
System.out.println("Emergency appointment booked !");
bedQueue.add(ptobj);
}
else if (appsection == 2) {
gynacappointments.add(ptobj);
System.out.println("Emergency appointment booked !");
bedQueue.add(ptobj);
}
else if (appsection == 3) {
entappointments.add(ptobj);
System.out.println("Emergency appointment booked !");
bedQueue.add(ptobj);
}
else if (appsection == 4) {
surgeonappointments.add(ptobj);
System.out.println("Emergency appointment booked !");
bedQueue.add(ptobj);
}
else if (appsection == 5) {
cardioappointments.add(ptobj);
System.out.println("Emergency appointment booked !");
bedQueue.add(ptobj);
} else {
// Handle invalid section number
System.out.println("Invalid section number!");
return; // Exit the method
}
}
}else {
System.out.println("ID not found!\nRecheck your details with admin");
}
break;
case 2:
System.out.println("\nYOUR REPORTS:\n");
Laboratory.generateLabParameters();
break;
case 3 :
break;
default:
System.out.println("Invalid option");
break;
}
break;
case 3:
do {
System.out.println("/nEnter\n1.To Change your shift\n2.To check current shift assignment:\n3.To exit");
nursechoice=sc.nextInt();
switch(nursechoice) {
case 1:
System.out.print("Enter your ID : ");
id=sc.nextInt();
if (nurse.containsKey(id)) {
Nurse nurseobj = nurse.get(id);
wardno=nurseobj.getWardNumber();
System.out.println("\n\nYour Current details : ");
nurseobj.display();
System.out.print("Enter new shift (morning/night):");
newshift = sc.next();
if(newshift.equalsIgnoreCase("night")||newshift.equalsIgnoreCase("morning")) {
nurseobj.setShift(newshift);
}
else {
System.out.print("Enter valid shift : ");
newshift = sc.next();
nurseobj.setShift(newshift);
}
System.out.println("\nShift updated successfully ");
System.out.println("New shift : "+nurseobj.getShift());
}else {
System.out.println("invalid ID ");
}
for (Nurse otherNurse : nurse.values()) {
if (otherNurse.getWardNumber() == wardno && otherNurse.getId()!= id) {
if(newshift.equals("morning")) {
otherNurse.setShift("night");
}
else{
otherNurse.setShift("morning");
}
}
}
break;
case 2:
System.out.print("Enter your ID : ");
int ddid=sc.nextInt();
if (nurse.containsKey(ddid)) {
Nurse nurseobj2 = nurse.get(ddid);
System.out.println(nurseobj2);
}
break;
}}while(nursechoice<3);
break;
case 4 :
System.out.println("To upload reports :");
System.out.print("Enter Id of patient : ");
int lid=sc.nextInt();
if(patient.containsKey(lid)) {
Laboratory.generateLabParameters();
}
break;
case 5:
Patient ward []=new Patient[10];
System.out.println("\n1.To generate consultancy bill\n2.To Admit\n3.To Discharge\n4.To view emergency ward patients\n"
+ "5.To view doctor data\n6.To view nurse data\n7.To view patient data\n8.To Exit");
int x=sc.nextInt();
switch(x)
{
case 1:
boolean pay=false;
System.out.print("Enter ID: ");
int consult1=sc.nextInt();
for(int pt:admitid)
{
if(pt!=consult1)
{
System.out.println("Pay consultancy Charges ₹300");
if(pay==true)
{
System.out.println("Paid");
}
}
}
break;
case 2:
System.out.print("Patients to be admitted: ");
System.out.println(admitid);
System.out.print("Enter ID: ");
int admit1=sc.nextInt();
System.out.print("Enter bed number ");
int bedno=0;
try {
bedno=sc.nextInt();
}catch(InputMismatchException e) {
System.out.print("Enter valid bed no.");
sc.next();
bedno=sc.nextInt();
}catch(ArrayIndexOutOfBoundsException e) {
System.out.println("\nOops!!Something went wrong, Try again !");
sc.next();
bedno=sc.nextInt();
}
if(patient.containsKey(admit1))
{
Patient ptobj=patient.get(admit1);
ward[bedno]=ptobj;
occupiedbed++;
emptybed--;
}
System.out.println("Patient admmited succussfully!");
System.out.println("Occupied beds="+occupiedbed+"\nEmpty beds="+emptybed);
break;
case 3:
System.out.print("Patients to be discharged: ");
System.out.println(dischargeid);
System.out.print("Enter ID: ");
int disch1=sc.nextInt();
System.out.print("Enter bed number ");
try {
bedno=sc.nextInt();
}
catch(InputMismatchException e) {
System.out.print("Enter valid bed no.");
sc.next();
bedno=sc.nextInt();
}catch(ArrayIndexOutOfBoundsException e) {
System.out.println("\nOops!!Something went wrong, Try again !");
sc.next();
bedno=sc.nextInt();
}
if
(patient.containsKey(disch1))
{
Patient ptobj=patient.get(disch1);
ward[bedno]=null;
if(occupiedbed<0)
{
occupiedbed=0;
emptybed=10;
}
occupiedbed--;
emptybed++;
dischargeid.remove(Integer.valueOf(disch1));
}
System.out.println("Patient discharged succussfully!\n Pay the bill below");
System.out.println("Occupied bed="+occupiedbed+"\nEmpty bed="+emptybed);
Random robj=new Random();
int RNcharges=robj.nextInt(50000);
int otcharges=robj.nextInt(50000);
int medcharges=robj.nextInt(10000);
int totalch=RNcharges+otcharges+medcharges;
System.err.println("BILL");
System.out.println("------------------------------");
System.out.println("Room and Nursing Charges:"+RNcharges);
System.out.println("OT Charges:"+otcharges);
System.out.println("Medicine and Professional Charges: "+medcharges);
System.out.println("Total Charges="+totalch);
break;
case 4:
System.out.println("Emergency patients ward :");
for(Patient element : bedQueue)
{
{
System.out.println("ID :"+element.id);
System.out.println("name :"+element.name);
} }
break;
case 5:
System.out.println("Doctors Data :\n--------------------------");
for(Map.Entry<Integer,Doctor>entry:details.entrySet()) {
System.out.println("\nID : "+entry.getKey());
System.out.println(entry.getValue());
}
break;
case 6 :
System.out.println("Nurse Data :\n--------------------------");
for(Map.Entry<Integer,Nurse>entry:nurse.entrySet()) {
System.out.println("\nID : "+entry.getKey());
System.out.println(entry.getValue());
}
break;
case 7 :
System.out.println("Patients Data :\n--------------------------");
for(Map.Entry<Integer,Patient>entry:patient.entrySet()) {
System.out.println("\nID : "+entry.getKey());
System.out.println(entry.getValue());
}
break;
}
break;
default :
System.out.println("Please Enter valid index");
break;
}
}while(ch<6);
}
}