Scenario
A hospital has asked you to write a program to keep track of the
patients in its wards. Each ward will have its own copy of the software,
so the program is only required to deal with a single ward. The name of
the driver program should be ProgAsgn2.
Patients
A patient object consists of name, date of birth, date of admission,
treating doctor and diagnosis; for the purposes of this assignment, all
of these can be Strings. (Admission is when a patient is accepted into
the ward and discharge is when the patient is permitted to leave.) Your
program should include a class that models an individual patient. Your
patient model should implement information hiding, allowing access to
instance data only through appropriate accessor and mutator methods.
The Ward
Another class will then establish and work with an array of as many
patient objects as there are beds in the ward (it would make sense to
store this number as a constant). This class will effectively be a model
of the ward. Unoccupied beds will be represented as null. The ward
should also follow information hiding principles.
The GUI
The program should work by way of a GUI that has a title, text fields
for the details of the current patient, five buttons, and a text area
for display of the occupied beds and the patients occupying them. Each
of these is described below.
The title of the GUI should be a suitable one of your own choosing.
At any given time one of the patients will be the ‘current’ patient.
That patient’s details, along with the patient’s bed number, will be
displayed in the GUI’s text fields. Any details displayed in those
fields can be edited, and the changes will be registered when any of the
buttons is pressed. If no beds are occupied, there will be no current
patient, and the text fields should be blank.
At the same time, the details of all occupied beds and their patients
will be displayed in the text area. If two beds are occupied, two lines
of data will appear in the text area; if 17 beds are occupied, 17 lines
of data will appear in that area.
The New patient button should clear the text fields so that the details
of a new patient can be entered, except that if all beds are occupied,
the user should be informed that no further admissions are possible.
Once the New Patient button has been selected and the new patient data
entered, it is expected that the next button selected will be Admit
Patient, otherwise a message box should be displayed saying that the
information entered has been lost.
The Admit Patient button should use the contents of the text fields to
create a new patient in the indicated bed, except that if the indicated
bed number represents an occupied bed, the user should be invited to
enter the number of an unoccupied bed and try again. A successful
admission should be indicated with a message box.
The Discharge Patient button should generate a suitable message and
remove the current patient from the display. The next occupied bed will
then become the current one.
The Next Patient and Previous Patient buttons should move to the next
occupied bed and the previous occupied bed respectively, making the
occupant of that bed the current patient and displaying that patient’s
details in the text fields. From the point of view of these buttons, the
ward is a ‘circular’ arrangement; in a 12-bed ward, the ‘Next’
bed to bed 12 is bed 1 and the ‘Previous’ bed to bed 1 is bed 12.
Because the user can edit the details of the current patient, these
should be updated from the text fields before moving on.
