Question

In: Computer Science

Consider the relationship, "Doctor is-an Employee" and "Nurse is-an Employee", in the context of a Hospital....

Consider the relationship, "Doctor is-an Employee" and "Nurse is-an Employee", in the context of a Hospital. Doctors and Nurses both have a name, gender, address, id, salary, and degree. Both salary and degree are private variables. Moreover, Doctors have their "clinical specialization" (ex: "cardiac", "radiology", etc.) and a consulting "room number", and Nurses have "work shifts" (ex: "morning", "evening", "night", etc.). You are required to write Python classes to represent doctors and nurses. Your class should have a function to increment the number of patients for a doctor, if the number of patients is more than 20, then print a message "Daily Limit Reached" and return -1, if the number is less than or equal to 20 the function should return the total number of patients that the doctor attended. Your program must also have a function to display the total number of employees in the hospital. Write the constructor and other required methods to complete your code. The program should have functions to display all necessary details. Test the class by creating two objects of the class Doctor and two objects of class Nurse, and test for more than 20 patients for the doctor.

Solutions

Expert Solution

# Defines super class Employee
class Employee:
countEmployee = 0
# Parameterized constructor to assign parameter values to data member
def __init__(self, name, gender, address, ID, salary, degree):
self.name = name
self.gender = gender
self.address = address
self.ID = ID
self.__salary = salary
self.__degree = degree
self.countEmployee += 1
  

# Setter function to set name
def setName(self, name):
self.name = name

# Setter function to set gender
def setGender(self, gender):
self.gender = gender

# Setter function to set address
def setAddress(self, address):
self.address = address

# Setter function to set ID
def setID(self, ID):
self.ID = ID

# Setter function to set salary
def setSalary(self, salary):
self.__salary = salary

# Setter function to set degree
def setDegree(self, degree):
self.__degree = degree

# Getter function to return name
def getName(self):
return self.name

# Getter function to return gender
def getGender(self):
return self.gender

# Getter function to return address
def getAddress(self):
return self.address

# Getter function to return ID
def getID(self):
return self.ID

# Getter function to return salary
def getSalary(self):
return self.__salary

# Getter function to return degree
def getDegree(self):
return self.__degree

# Defines a function to display employee information
def showEmployee(self):
print("\n Name: ", self.name, "\n Gender: ", self.gender,
"\n Address: ", self.address, "\n ID: ", self.ID,
"\n Salary: $", self.__salary,
"\n Degree: ", self.__degree, end = '')

# Defines sub class Doctor derived from supuer class Employee
class Doctor(Employee):
  
# Parameterized constructor to assign parameter values to data member
def __init__(self, name, gender, address, ID, salary, degree, specialization, roomNumber):
# Calls the super class constructor
Employee.__init__(self, name, gender, address, ID, salary, degree)
self.specialization = specialization
self.roomNumber = roomNumber
self.countPatient = 0

# Setter function to set specialization
def setSpecialization(self, specialization):
self.specialization = specialization
  
# Getter unction to return specialization
def getSpecialization(self):
return self.specialization

# Getter unction to return room number
def getRoomNumber(self):
return self.roomNumber

# Setter function to set room number
def setRoomNumber(self, roomNumber):
self.roomNumber = roomNumber

def addPatient(self):
if self.countPatient >= 20:
print(" Daily Limit Reached for Doctor: ", self.getName())
return -1
else:
self.countPatient += 1
return self.countPatient
  
# Defines a function to display doctor information
def showDoctor(self):
self.showEmployee()
print("\n Specialization: ", self.specialization,
"\n Consulting room number: ", self.roomNumber)

# Defines sub class Nurse derived from supuer class Employee
class Nurse(Employee):
  
# Parameterized constructor to assign parameter values to data member
def __init__(self, name, gender, address, ID, salary, degree, workShifts):
# Calls the super class constructor
Employee.__init__(self, name, gender, address, ID, salary, degree)
self.workShifts = workShifts
  
# Setter function to set work shifts
def setSpecialization(self, workShifts):
self.workShifts = workShifts
  
# Getter function to return workShifts
def getSpecialization(self):
return self.workShifts
  
# Defines a function to display nurse information
def showNurse(self):
self.showEmployee()
print("\n Work Shifts: ", self.workShifts)

# Creates objects for Doctor class
doctorOne = Doctor('Pyari', "male", "Berhampur", 1111, 200000, "MBBS",
"Radiology", 102)
doctorTwo = Doctor('Manvi', "female", "Bangalore", 2222, 288000, "MBBS",
"Cardiac", 207)

# Creates objects for Nurse class
nurseOne = Nurse('Ramesh', "male", "Bhubaneswar", 1234, 15000, "NCR",
"Morning")
nurseTwo = Nurse('Rita', "female", "Rourkela", 3213, 22000, "CCR",
"Evening")

# Loops 22 times to add patient to doctor one
for c in range(22):
doctorOne.addPatient()

# Loops 9 times to add patient to doctor two
for c in range(9):
doctorTwo.addPatient()

# Displays the doctors information
print("************** Doctors Information ************** ")
doctorOne.showDoctor()

print(" Total number of patients doctor ", doctorOne.getName(),
" attended: ", doctorOne.countPatient)

doctorTwo.showDoctor()

print(" Total number of patients doctor ", doctorTwo.getName(),
" attended: ", doctorTwo.countPatient)

print("************** Nurses Information ************** ")
# Displays nurses information
nurseOne.showNurse()
nurseTwo.showNurse()

print("\n Total number of employees: ",
(doctorOne.countEmployee + doctorOne.countEmployee +
nurseOne.countEmployee + nurseTwo.countEmployee))

Sample Output:

Daily Limit Reached for Doctor: Pyari
Daily Limit Reached for Doctor: Pyari
************** Doctors Information **************

Name: Pyari
Gender: male
Address: Berhampur
ID: 1111
Salary: $ 200000
Degree: MBBS
Specialization: Radiology
Consulting room number: 102
Total number of patients doctor Pyari attended: 20

Name: Manvi
Gender: female
Address: Bangalore
ID: 2222
Salary: $ 288000
Degree: MBBS
Specialization: Cardiac
Consulting room number: 207
Total number of patients doctor Manvi attended: 9
************** Nurses Information **************

Name: Ramesh
Gender: male
Address: Bhubaneswar
ID: 1234
Salary: $ 15000
Degree: NCR
Work Shifts: Morning

Name: Rita
Gender: female
Address: Rourkela
ID: 3213
Salary: $ 22000
Degree: CCR
Work Shifts: Evening

Total number of employees: 4


Related Solutions

A hospital analyzed the relationship between the distance an employee must travel between home and work...
A hospital analyzed the relationship between the distance an employee must travel between home and work (in 10s of miles) and the annual number of unauthorized work absences (in days) for several randomly selected hospital employees. The regression analysis showed dfErr = 15, SSxx = 23.88, SSyy = 130.00, and SSxy = -54.50. What is the 99% confidence interval for β1 (with appropriate units)? a. (-0.2651 days/mile, -0.1913 days/mile) b. (-2.6081 days, -1.9564 days) c. (-26.5130 days/mile, -19.1319 days/mile) d....
Consider: A newly hired nurse is assigned to the recovery room of a hospital that specializes...
Consider: A newly hired nurse is assigned to the recovery room of a hospital that specializes in heart surgery. She is working there for a week when one evening a man in the recovery room is being closely monitored after surgery. The signs are not good. He recovers consciousness. The doctors inform him of the situation. They leave the recovery room. The man calls the nurse over and asks for a pen and some paper. Thinking that he might die,...
Consider the Hospital scenario in the Allied Health Community. Describe the best solution to address employee...
Consider the Hospital scenario in the Allied Health Community. Describe the best solution to address employee retention and development. Why do you feel this way? Be sure to respond to at least two other students who have offered different solutions and evaluate whether the other solutions or approaches would result in the desired goal. You are the administrator of a medium-sized hospital. The Director of Human Resources has been summoned to an executive team meeting in an effort determine why...
The relationship between hospital patient-to-nurse ratio and various characteristics of job satisfaction and patient care has...
The relationship between hospital patient-to-nurse ratio and various characteristics of job satisfaction and patient care has been the focus of a number of research studies. Suppose x = patient-to-nurse ratio is the independent variable. For each of the following potential dependent variables, indicate whether you expect the slope of the least-squares line to be positive or negative and give a brief explanation for your choice. (a) y = a measure of nurse's job satisfaction (higher values indicate higher satisfaction) We...
The Nurse-Client Relationship In this discussion, we'll talk about the nurse-client relationship and the use of...
The Nurse-Client Relationship In this discussion, we'll talk about the nurse-client relationship and the use of therapeutic communication as an important part of that relationship. Please answer the following questions: What are your concerns or fears about mental health nursing in general? Are you interested in mental health nursing, or do you approach the topic with some anxiety? What do you feel are essential aspects of a good nurse-client relationship? Please include an example of how you established good rapport...
With Obesity on the rise, a Doctor wants to see if there is a linear relationship...
With Obesity on the rise, a Doctor wants to see if there is a linear relationship between the Age and Weight and estimating a person's Systolic Blood Pressure. Using that data, find the estimated regression equation which can be used to estimate Systolic BP when using Age and Weight as the predictor variable. See Attached Excel for Data.        BP data.xlsx     9 KB A. Systolic BP = 31.73252234 + 0.965183151(Age) + 2.666383416(Weight) B. Systolic BP = 31.73252234 + 0.938835263(Age) +...
A patient is in the hospital with bacterial meningitis. The doctor needs to determine whether the...
A patient is in the hospital with bacterial meningitis. The doctor needs to determine whether the patient has an infection with Neisseria meningitis or Haemophilus influenzae. 1. What is the problem (scenario) that you're asked to solve? 2. What is your hypothesis for the solution to the problem? What organism do you think caused the problem? 3. What are the experiments that are required to answer your hypothesis? (The stains, biochemical, and media for each organism and the expected results)...
1- According to what could a nurse know who is the doctor that is in charge...
1- According to what could a nurse know who is the doctor that is in charge of her/his patient? How does the nurse know who is the doctor of the patient that he / she is taking care of? 2- Discuss some of the ethical issues relating to genetic testing 3- Some ethicists argue that patients with alcohol-related end-stage liver disease (ARESLD) should not be considered for a liver transplant due to the poor results and limited long-term survival. Others...
Malik is a doctor in the emergency department at Sacramento City Hospital. Malik is unmarried and...
Malik is a doctor in the emergency department at Sacramento City Hospital. Malik is unmarried and has an 8-year-old daughter. In 2020, Malik's employer provided Malik with a $5,000 qualified disaster relief payment to help Malik pay for the cost of hiring a nanny when Malik's daughter's school was closed due to the Covid-19 pandemic. Malik still needed to work during this time, so it was necessary for him to secure alternate child care for his daughter. What amount of...
Malik is a doctor in the emergency department at Sacramento City Hospital. Malik is unmarried and...
Malik is a doctor in the emergency department at Sacramento City Hospital. Malik is unmarried and has an 8-year-old daughter. In 2020, Malik's employer provided Malik with a $5,000 qualified disaster relief payment to help Malik pay for the cost of hiring a nanny when Malik's daughter's school was closed due to the Covid-19 pandemic. Malik still needed to work during this time, so it was necessary for him to secure alternate child care for his daughter. What amount of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT