Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this homework, you are supposed to implement a Java program for a hospital database by using binary search trees. You must use your own

In this homework, you are supposed to implement a Java program for a hospital database by using
binary search trees. You must use your own implementation of binary search trees by taking
inspiration from your textbook or the web. You are not allowed to use any external library or .jar
file.
In this hospital database, for each patient, you will have an entry in which you keep:
1. The first name and last name of the patient,
2
2. Date the patient visited the hospital (month, day, and year),
3. The first name and last name of the doctor,
4. A list of its patients care team. For each medical staff member in the hospital, you should
keep:
a) The first and last name of a medical staff member, and
b) The professional role they fulfill (Nurse, Anesthesiologist, etc.).
In your implementation, you must keep patient entries in the binary search tree based on the year
the patient visited the hospital. Then, to keep the care team of each patient, you should create a
binary search tree in which the medical staff members are kept by their names (e.g., if you have
five patients in your binary search tree, you will have five more binary search trees: one for the
care team of each patient.). To deal with patients of the same year, you can define your binary
search tree for a node such that elements with smaller values are kept in the left subtree of the
node, and elements with larger or equal values are kept in its right subtree.
Your system will have the following functionalities; the details of these functionalities are given
below (see the end of this document for sample inputs/outputs):
1. Add a patient
2. Remove a patient
3. Add a medical staff member to the care team of a patient
4. Remove a medical staff member from the care team of a patient
5. Show the list of patients
6. Show detailed information about a particular patient
7. Query the patients who were seen by a particular doctor
8. Query the patients who visited in a given year
Add a patient: This function adds an entry to the hospital database for a given patient whose name
(first name + last name), doctors name (first name + last name), and visit date (day + month +
year) are specified as parameters. In this function, the care team is not specified; the medical staff
members that cared for the patient will be added later. In this system, the names (first name + last
name) of the patients are unique. Thus, if the user attempts to add a patient with an existing name,
you should overwrite old information.
Remove a patient: This function removes a patient, whose name is specified as a parameter, from
the hospital database. If this patient does not exist in the database (i.e., if there is no patient with a
specific name), you should not allow this operation and give a warning message.
Add a medical staff member: This function adds a medical staff member to the care team of a
patient. For that, the name of the patient to which the medical staff member is added, the medical
staff members name (first name + last name), and the title of the professional role fulfilled by the
3
medical staff member are specified as parameters. In this function, you should consider the
following issues:
If the patient with a specific name does not exist in the database, you should not allow the
operation and give a warning message.
In this system, all medical staff members names are unique within the same care team.
Thus, if the user attempts to add a medical staff member with an existing name within the
same care team, you should overwrite old information. Please note that a medical staff
member can work in different care teams.
Remove a medical staff member: This function removes a medical staff member from the care
team of a patient. For that, the name of the patient from which the medical staff member is removed
and a medical staff members name (first name + last name) are specified as parameters. If the
patient with a specific name does not exist in the database, you should not allow the operation and
give a warning message. Similarly, if the medical staff member is not in the care team of the
specified patient, you should not allow the operation and give a warning message. Note that after
calling this function, the care team should remain sorted in ascending order.
Show the list of patients: You should list all patient entries in the hospital database on the screen
in the following format. If the database does not contain any patient, you should display -
--none---. Your system should display patients in ascending order by visit year.
Name(First name + Last Name), visit year, visit name (for the 1st patient)
Name(First name + Last Name), visit year, visit name (for the 2nd patient)
Name(First name + Last Name), visit year, visit name (for the 3rd patient)
Show detailed information about a particular patient: You should display all of the information
about a patient whose name is specified as a parameter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions