Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that manages a list of patients for a medical office. Patients should be represented as objects with the following data members: name

Write a program

that manages a list of patients for a medical office. Patients should be

represented as objects with the following data members:

name (string)

patient id # (string)

address (string)

height (integer; measured in inches)

weight (double)

date of birth (Date)

date of initial visit (Date)

date of last visit (Date)

The data member patient id # is defined to be a

key

. That is, no two patients can have

the same patient id #. In addition to the standard set of accessors for the above data

members, define the fol

lowing methods for class Patient.

standard set of accessors

get_age

method: to compute and returns a patients age in years (integer)

get_time_as_patient

method: to compute the number of years (integer) since

the patients initial visit. Note that this va

lue can be 0.

get_time_since_last_visit

method:

to compute the number of years (integer)

since the patients last visit. This value can be 0, too.

Your program will create a list of patient objects and provide the user with a menu of

choices for accessing

and manipulating the

data on that list. The list must be an object of

the class List that you will define.

Internally, the list object must maintain its list as a

singly linked list with two references, one for head and one for tail.

As usual, your Li

st

class will have the methods

find,

size, contains

, remove,

add,, get,

getNext,, reset, toString

,. At the start, your program should read in patient data

from a text file for an initial set of patients for the list. The name of this file

should be

included on the command line when the program is run.

(Dont hard code

the file name)

Each data item for a patient will appear on a separate line in

the file.

Your program

should be menu-

driven, meaning that it will display a menu of options for the user. The

user will choose one of

these options, and your program will carry out the request. The

program will then display the same menu again and get another

choice from the user.

This interaction will go on until the user chooses QUIT, which should be the last of the

menus options. The

menu should look something like the following:

1.

Display list

2.

Add a new patient

3.

Show information for a patient

4.

Delete a patient

5.

Show average patient age

6.

Show information for the youngest patient

7.

Show notification l

ist

8.

Quit

Enter your choice:

Details of each option:

Option 1: Display (on the screen) the names and patient id #s of all patients in

order starting from the first one. Display the

information for one patient per line;

something like: Susan

Smith, 017629

Option

2: Add a new patient to the

END

of the list.

All

information about the new

patient (including name, patient id #, etc.)

is to be requested (input) from the user

interactively. That is, you will need to ask for 14 pieces of data from the user.

Youll, of course, need to create a new patient object to hold this data.

NOTE:

As mentioned above, the patient id # field is a

key

. So, if the user types in

a patient id # that happens to be the same as

an already existing patients, then

you should display an error message and cancel the operation. Therefore, it is

probably a

good idea to ask for the patient id # first and test it immediately (by

scanning the objects on the list).

Option

3: Display (in a neat format) all the information pertaining to the patien

t

whose patient id # is given by the user. Namely, display the following information:

o

name

o

patient id #

o

address

o

height (shown in feet and inches; for example, 5 ft, 10 in)

o

weight

o

age

o

number of years as a patient (display less than one year if 0)

o

number of years since last visit (display less than one year if 0)

o

Indication that patient is overdue for a visit

NOTE:

The last item is displayed only if it has been 3 or more years since

the patients last visit.

If the user inputs a patient id

# that does

not

exist, then the program should

display an error message and the operation should be canceled (with the menu

immediately being displayed again for another request).

Option

4: Delete the patient whose id # is given by the user. If the patient is not

on the

list, display an error message.

Option 5: Show the average age (to one decimal place) of the patients.

Option

6:

Display (in a neat format) all the information (same as operation 3)

about the youngest patient.

Option

7: Display the names (and patient id

#s) of all patients who are overdue

for a visit. As noted above, overdue is

defined as 3 or more years since the last

visit.

Option 8: Quit the program.

NOTE:

When the user chooses to quit, you should ask if they would like to save

the patient information to a file. If so, then

you should prompt for the name of an

output (text) file, and then write the data pertaining to

all

patients to that file. The

output for each patient should be in the same format as in the input file. In this

way, your output fil

e can be used as input on

another run of your program. Make

certain to maintain the order of the patients in the output file as they appear on the

list. Be

careful not to overwrite your original input file (or any other file, for that

matter).

Note

:

Try to

implement the various menu options as separate methods (aside

from

main)

.

However:

DO NOT DEFINE such option methods

as part of the class

List.

Of course, the Java code that implements an option (whether its in the main

method or not) should def

initely use Lists methods

to help do its job.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

3 How supply and demand together determine market equilibrium.

Answered: 1 week ago