Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 BedPriorityComparator = new Comparator() {
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 emergencyComparator = new Comparator() {
@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) {
}
}
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;
}
}
@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 dischargeid=new ArrayList();
ArrayList admitid=new ArrayList();
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 orthoappointments = new PriorityQueue(Patient.emergencyComparator);
PriorityQueue gynacappointments = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue entappointments = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue surgeonappointments = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue cardioappointments = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue tempQueue = new PriorityQueue<>(Patient.emergencyComparator);
PriorityQueue 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:
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();
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 : ");
}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();
}}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);
}
}