Overview

In this assignment you will develop a simple patient management system for a sports injury hospital (Sports-Fix Inc.) that provides both an outpatient (day procedure) service for minor injuries as well as an inpatient (longer term) service for sportspersons who have injuries that require more extensive treatment or multiple/complex operations.

Part A

In this first part you will develop a simple Patient class, representing an Patient who is to be admitted for a minor procedure that only requires a 1-2 day stay in hospital and that has five possible states:

  • ‘S’ (Scheduled – waiting to be admitted)
  • ‘A’ (Admitted – waiting for procedure)
  • ‘R’ (Recovering – procedure performed, patient recovering)
  • “D” (Discharged – patient has been released from the hospital)
  • “C” (procedure cancelled)

This class should also provide methods that allow transitions between states as shown in the state diagram below: See image.

PART A: Section I-Writing a Patient class

You are required to write a class named Patient to model the details of an “outpatient” who is scheduled to have a minor (“day”) procedure that does not require an extended stay in the hospital. The requirements are specified below.

Instance Variables

Provide private instance variables to store the patient number, patient name, procedure date (String), the length of the procedure in hours (a double), procedure description (initially a description of the patient’s injury), and the name of the doctor supervising the patient’s treatment.

You will also need an additional instance variable for status of the patient, which must be set to either 'S' (procedure Scheduled), 'A'(Admitted), ‘R’ (in Recovery), ‘D’ (Discharged), ‘O’ (under observation) or 'C' (procedure Cancelled).

Constructor

Provide a constructor for the class that accepts the patient number (a String), patient name (a String), procedure date (a String in the format dd/mm/yy), procedure (injury) description and the name of the doctor supervising the patient’s treatment.

This constructor should initialise the corresponding instance variables and set the instance variable for status to 'S' (a procedure has the status “Scheduled” when it is first created).

public Patient (String patientNo, String patientName, String procedureDate, String description, String supervisingDoctor)

Methods

Provide methods to admit a patient to and discharge a patient from the outpatient ward, record details of a procedure that has been performed, cancelling a scheduled procedure and printing the current state of the Patient as follows:

+ public boolean admit() // called when patient is admitted to outpatient ward

The admit() method should check the status of the patient and if it is currently ‘S’ (scheduled) then it should change the status to ‘A’ (admitted) and return true, otherwise it should return false.

+ public boolean discharge() // called when patient is discharged from outpatient ward

The discharge() method should check the status of the patient and if it is currently ‘R’ (recovering) then it should change the status to ‘D’ (discharged) and return true, otherwise it should return false.

+ public boolean recordProcedure(int hours, String notes) // called when a procedure has been completed

The recordProcedure() method must take as parameters the length of the procedure (in hours) and any notes added by the doctor performing the procedure.

This method should first check the status of the patient and if it is currently ‘A’ (admitted) or ‘O’ (under observation) . sIf the status of the patient is valid (‘A’ or ‘O’) then the number of hours specified should be added to the procedure length, the notes that were recorded by the doctor performing the procedure should be appended to the existing procedure description on a new line, the patient’s status should be changed to ‘R’ (recovering) and the method should return true, otherwise it should return false.

(note that the status ‘O’ will never be set for an outpatient, but it will need to be catered for when inpatients are introduced in assignment 2B)

+ public boolean cancel() // called when patient’s procedure has been cancelled

The cancel() method should check the status of the patient and if it is currently ‘S’ (scheduled) or ‘A’ (admitted) then it should change the status to ‘C’ (admitted) and return true, otherwise it should return false.

+ public void print()

The print()method should display all of the details of the patient to the screen in a neat, formatted manner, including the procedure description (notes).

You should also implement accessors for access to instance variables required by the application to be developed (in the next section).

Part A: Section II Using the Patient class

Declare an array named patients that can store the references of up to 6 Patient objects. Create 6 Patient objects passing the values specified below to via the constructor and store the objects in the array.

Patient Patient Procedure Procedure Supervising
Number Name Date Description Doctor
------- ------- --------- ----------- -----------
OU101 Riewoldt, N. 29/08/11 Knee Arthroscopy P. Larkins
OU102 Dawes, D. 27/08/11 Hand Fracture B. Reid
OU103 Gysberts, J. 21/08/11 Wrist Fracture A. Jowett
OU104 Sandilands, A 21/08/11 Turf Toe P. Larkins
OU205 Motlop, M. 25/08/11 Finger Fracture G. Hoy
OU306 Maxwell, N. 22/08/11 Thumb Fracture G. Hoy

Display the patient number and patient name, procedure description and supervising doctor for each patient object stored in patients. The displayed information should be formatted as a table (only the details specified above should be displayed).

Hint: Access the Patient objects by iterating through the array of references patients (using a loop). Extract the patient number and other required details from these objects using the corresponding accessors.

Allow users to view the patient name, procedure date and procedure description for all patients who are being treated by a supervising doctor specified by the user. If no patients are found that are being treated by the specified doctor then print an appropriate error message to the screen.

Hint: This requires you to loop through the array of references and select the required objects using the accessor for supervising doctor.

Allow users to admit a patient, record procedure details for a patient, discharge a patient or cancel a procedure that has been scheduled for a patient, by specifying the patient number and the operation they wish to perform (“A”, “R”, “D” or “C” respectively for each operation) . If a matching patient is found then the program should attempt to execute the desired operation.

Recording procedure details for a patient will require that the user be prompted to enter the number of hours the procedure took to complete as well as the notes from the procedure. You may assume that the procedure lengths entered by the user will be in increments of 30 minutes (eg. 0.5 hours, 1 hour, 1.5 hours, etc).

The program should also check to see if the attempted operation was successful or not (by capturing the result that was returned and checking it) and report back to the user accordingly (ie. a success message should be printed if the operation was successful, and a failure message should be printed if it was not).

Hint: This requires looping through the array of references to locate the object with the specified patient number. If such an object is found then invoke the appropriate method on that object passing the required arguments (where necessary). Print appropriate error message if the object with specified ID cannot be found or if the desired operation cannot be performed.

Allow users to repeat the step (iv) above using a do while loop. The loop should be repeated until the user enters a blank line for the patient number (the prompt for the patient number should indicate that the user can just enter a blank line to quit).

Note that this involves updating your code from requirement (iv) so that the process of searching for a patient and performing an operation on it can be repeated until the user chooses to quit

Print the final details of all the Patient objects using a for loop and the print() method for each object in the array patients.

Part B

In this part of assignment 2 you are required extend the Patient class to implement an Inpatient class, representing a patient who is admitted to the hospital for a longer term and who may require multiple procedures to be performed.

An Inpatient is placed under observation after a procedure has been performed until the supervising doctor is satisfied that their recovery has progressed well enough to either perform the next scheduled procedure (if any are remaining) or to discharge the patient.

Additional functionality for dealing with multiple procedures and the new state “O”(under observation), and overridden versions of methods defined in the Patient class, will need to be implemented (which introduce additional conditions for some state transitions). See image.

PART B Section I: Writing the subclass Inpatient

Sports-Fix Inc. also provide an “inpatient” service for sports injuries which require more extensive treatment and extended stay in the hospital for observation/recovery purposes.

It is possible that an inpatient may require multiple procedures (eg. exploratory arthroscopy to identify the extent of the injury followed by surgery to repair any damage found), so inpatient procedure records should cater for recording the details of multiple procedures performed on the inpatient in question.

For health and safety reasons a maximum of three procedures can be performed on an inpatient during the course of one visit to the hospital.

When a new inpatient procedure is scheduled the supervising must first complete a examination of the patient to provide an initial diagnosis of the injury before any procedures can be performed.

Any procedures deemed necessary as a result of the initial examination may only be performed after the diagnosis (resulting from that initial examination) has been recorded by the supervising doctor.

Inpatients will generally also need to stay at the hospital for observation purposes or to allow for recovery time between scheduled procedures, so the number of days the inpatient has stayed in a hospital room should also be recorded.

Finally, a procedure may only be cancelled for an inpatient if they have not yet had their first procedure performed. If one or more procedures have already been performed then all other procedures that have been scheduled (or may be scheduled later) for that patient, must also be performed (ie. They cannot be cancelled)

Instance Variables

Derive a subclass of Patient named Inpatient. This subclass should include additional instance variables for the number of days stayed and initial diagnosis. It should also allow for the storage of details for up to three scheduled procedures, which will include a description of the procedure and the doctor who is to perform the procedure. You should organise the storage of details for the procedures using parallel arrays for the procedure description and doctor, and you will need instance variables for the number of procedures scheduled and number of procedures completed.

Constructor

The constructor for this class should take the same arguments as the Patient superclass constructor, passing on the relevant details to the (Patient) using super().

It should also set up the parallel arrays for the procedure descriptions/doctor names and initialise the diagnosis instance variable to “Pending”.

Overridden Methods

This subclass (Inpatient) must override the following methods which should make use of the superclass methods where necessary:

+ public boolean recordProcedure(int hours, String notes) // called when a procedure has been completed

The recordProcedure() method should be overridden in the subclass so that it initially checks to see if the diagnosis from the initial exploratory procedure has been recorded (ie. it is not still “Pending”).

If the initial diagnosis has not been recorded (ie. it is still “Pending”) then the notes are for the initial diagnosis and should be recorded in the corresponding instance variable – the patient does not have to have been admitted for the initial diagnosis to be performed and a true result should be returned.

If the initial diagnosis has been recorded and the number of completed procedures is less than the number of scheduled procedures then the method should then proceed to record the procedure length and procedure notes by invoking the superclass recordProcedure() method, passing along the hours and procedure notes information accordingly (if the notes were for the initial diagnosis then just pass along an empty string (“ ”) for the procedure notes) and return a true result, otherwise it should return false.

When recording the details of a procedure after the initial diagnosis, the initial procedure description and doctor name should be included as shown below in the sample excerpt from the details for an Inpatient.

Supervising doctor: B. Reid

Diagnosis:

Physical exam indicates partial rupture of ACL in left knee and pain/swelling laterally indicates possible damage to lateral meniscus

Procedure notes:

(Arthroscope) 95% rupture of ACL in Left Knee – full LARS reconstruction required (P. Larkins)

(Knee Reconstruction) LARS ACL graft in Left Knee in place, lateral meniscus trimmed (P. Larkins)

(Follow-up) Fluid from Left knee drained, joint stable, range of motion improving (B Reid)

The completed procedure count should then be incremented and if the current completed procedure count is less than the number of scheduled procedures then the status for the Inpatient should be set to ‘O’ (under observation).

Remember that a procedure can only be performed if the patient status is ‘A’ or ‘O’, so you should be taking note of the result returned when calling the superclass recordProcedure() method and returning the result it produces if necessary.

(note that this will require the Patient class to be retrofitted with a mutator for updating patient status)

+ public boolean cancel() // called when patient’s procedure has been cancelled

The cancel() method should be overridden to see if the Inpatient has already had a procedure performed (by checking the performed procedure count).

If no procedure has yet been performed then the procedure may be cancelled by invoking the superclass cancel() method and passing on (returning) the result it returns (this will effectively result in procedures for that patient being cancelled).

If the Inpatient has already had one or more procedures performed then a false result should be returned.

+ public void print()

The print() method must display all of the details for the Inpatient – including the diagnosis and details for any procedures that have been scheduled (including whether they have been completed or are still pending).

Hint: you can use the superclass version of print() to display basic details for an Inpatient.

New Methods

This subclass (Inpatient) must include the following (new) methods:

+ public boolean scheduleProcedure(String description, String doctor)

The scheduleProcedure() method should first check to see if the initial diagnosis has been recorded.

If the initial diagnosis has been recorded then this method should check if the maximum procedure limit has been reached.

If this limit has not yet been reached then the method should record the procedure description and doctor name in next empty position of the corresponding arrays discussed in the instance variables section of this (assignment 2B specification), increment the scheduled procedure count by 1 and return true.

If the maximum procedure limit has been reached or the initial diagnosis has not been recorded then the method should return false.

PART B Section II: Managing Patient and Inpatient objects

Declare an array of 6 Patient references named patients, that can refer up to 6 Patient or Inpatient (subclass) objects. Create the Patient and Inpatient objects specified below, storing their references in patients.

Object Type* Patient
Number Patient
Name Procedure
Date Procedure
Description Supervising
Doctor
Patient OUP101 Riewoldt, N. 29/08/11 Knee Arthroscopy P. Larkins
Inpatient INP102 Brown, J. 27/08/11 Facial Fractures B. Reid
Inpatient INP104 Brown, C. 21/08/11 Pelvic Fracture B. Reid
Patient OUP103 Gysberts, J. 21/08/11 Wrist Fracture A. Jowett
Inpatient INP106 Brown, N. 15/08/11 Knee Arthroscopy P. Larkins
Patient INP105 Sandilands, A 25/08/11 Turf Toe G. Hoy

* Note this is just an indication of which object type you should be creating – you do not need to store this “type” anywhere

Write a menu driven program to perform the common operations (see below)

Patient Menu

Display All Patients 1
Admit Patient 2
Schedule Inpatient Procedure 3
Record Procedure 4
Cancel Procedure 5
Discharge Patient 6
Exit 7

Enter your selection : _

Specification/Guidelines for menu options

Display All Patients: Print the details of all patients by calling the print() method for each object in the array of Patient references.

Admit Patient option: Prompt the user to enter the patient number and read it in from the keyboard. Locate the corresponding object with the specified patient number in the array of patient objects. If no such patient exists then display an appropriate error message and return to the menu. Otherwise attempt to cancel the procedure by invoking the admit() method for the patient object that was found and report the results back to the user (ie. whether it was successful or unsuccessful).

Note that process for this feature is similar to the code segment for admitting patients in Part A.

Schedule Procedure option: Prompt the user to enter the patient number and read it in from the keyboard. Locate the corresponding object with the specified patient number in the array of patient objects. If no such patient exists then display an appropriate error message and return to the menu. Otherwise if the specified object is an Inpatient object then prompt the user to enter the (initial) procedure description and doctor name and read them in from the keyboard. Using the details entered by the user attempt to schedule a new procedure for the Inpatient by invoking the scheduleProcedure() method for the Inpatient object that was found and report the results back to the user (ie. whether it was successful or unsuccessful).

Any attempt to schedule a job for an outpatient (Patient) object should result in an error message being displayed stating that additional procedures cannot be scheduled for an outpatient.

Hint: you need to check the object type to work out if it is an Inpatient before attempting any type cast.

Record Procedure option: Prompt the user to enter the patient number and read it in from the keyboard. Locate the corresponding object with the specified patient number in the array of patient objects. If no such patient exists then display an appropriate error message and return to the menu. Otherwise prompt the user to enter procedure length and procedure description (notes) and read them in from the keyboard. Using the details entered by the user attempt to record the procedure details by invoking the recordProcedure() method for the patient object that was found and report the results back to the user (ie. whether it was successful or unsuccessful).

Note that process for this feature is similar to the code segment for recording procedure details in Part A.

Discharge Patient option: Prompt the user to enter the patient number and read it in from the keyboard. Locate the corresponding object with the specified patient number in the array of patient objects. If no such patient exists then display an appropriate error message and return to the menu. Otherwise attempt to discharge the patient by invoking the discharge() method for the patient object that was found and report the results back to the user (ie. whether it was successful or unsuccessful).

Note that process for this feature is similar to the code segment for discharging patients in Part A.

Cancel Procedure option: Prompt the user to enter the patient number and read it in from the keyboard. Locate the corresponding object with the specified patient number in the array of patient objects. If no such patient exists then display an appropriate error message and return to the menu. Otherwise attempt to cancel the procedure by invoking the cancel() method for the patient object that was found and report the results back to the user (ie. whether it was successful or unsuccessful).

Note that process for this feature is similar to the code segment for cancelling procedures in Part A.

Part C

In this part you are required to take the trial patient management program described in part A and B and extend its functionality to manage all of the common operations, taking into account surgeon and billing related functionality in the SportsFix Inc. patient management system.

Fees for outpatient procedures and inpatient stays in the hospital are calculated primarily based on the fee charged by the surgeon who is supervising the patient. These surgeons are classified into two categories, General Surgeons (who charge a flat rate per hour for their services) and Specialist Surgeons (who charge a base fee for the initial consultation, as well as an hourly surcharge for their services). Hence you are required to write an abstract class named Surgeon with subclasses GeneralSurgeon and SpecialistSurgeon.

Part C Section I: Surgeon and subclasses

Surgeon class

A unique nameis recorded for each Surgeon, as well as the hourly fee they charge for their services. All Surgeons will charge for each patient they are supervising. In this part you are required to write the abstract class named Surgeon with:

  • Instance variables for surgeon name and hourly fee.
  • Constructor taking as arguments the value for surgeon name and hourly fee.
  • An abstract method double calculateFee(double hours) which accepts a double value for the number of hours the patient has been supervised by the surgeon as an argument and which returns a double value indicating the fee charged by the surgeon.
  • Appropriate accessors for both instance variables.
  • An appropriate print()method which displays the instance variables to the screen.

Subclass GeneralSurgeon

General Surgeons do not require any additional details beyond the properties for a basic Surgeon and they charge fees based on their flat hourly fee.

In this part you are required to write the class GeneralSurgeon extending Surgeon with:

  • No new instance variables are required.
  • Constructor taking as arguments values for surgeon name and hourly fee.
  • An overridden version of the abstract method double calculateFee(double hours)declared in the superclass Surgeon, which accepts the total number of hours the GeneralSurgeon has been supervising the patient (a double), calculates the fee charged by the GeneralSurgeon (ie. hours * hourly fee) and returns the result.
  • Override the print() method so that the Surgeon type (General) is also printed.

Subclass SpecialistSurgeon

All Specialist Surgeons have a specialty and a consultation fee they charge for initial patient diagnosis, as well as the properties for a basic Surgeon and they charge fees based on their initial consultation fee as well as their flat hourly fee.

In this part you are required to write the class SpecialistSurgeon extending Surgeon with:

  • Instance variables for the specialty and consultation fee.
  • Constructor taking as arguments values for surgeon name, hourly rate, specialty and consultation fee.
  • An overridden version of the abstract method double calculateFee(double hours)declared in the superclass Surgeon, which accepts the total number of hours the SpecialistSurgeon has been supervising the patient (a double), calculates the fee charged by the GeneralSurgeon (ie. consultation fee + hours * hourly fee) and returns the result.
  • Override the print() method so that the Surgeon type (Specialist) is also printed along with the new instance variables defined above.

Part C- Section II Managing the Patients/Surgeons

In this part you are required to write a class named ManagePatients following the steps outlined below allowing Surgeon and Patient objects to be created, stored in arrays (or JCF collections if you so wish).

Overall Requirements

The users should be allowed to perform the following operations. You may write a separate method for each feature in this application if you wish to (although it is not strictly required that you do so). You are expected to write a menu-driven program which incorporates any necessary input validation and exception handling allowing recovery whenever possible.

Notes: “Unchanged” features do not need any additional work, “updated” features need to be changed to incorporate doctor-related functionality) and “new” features need to be added to the ManagePatients class.

  • Add a new patient record (Patient or Inpatient) - new (5 marks) This feature should allow the user to add a Patient or Inpatient record to the patient system. You should ensure that all Patient numbers entered will be unique by checking them against existing patient numbers in the system and you must also ensure that the supervising doctor name should also come from the collection of surgeons that are present in the system. An error message should be displayed if the patient ID is not unique or the doctor name is not present in the system.
  • Display All Patients - unchanged
    • should display the details for all Patients (including status).
  • Admit Patient - updated
    • any errors from the Patient classes must be reported
  • Schedule Procedure - updated
    • any errors from the Patient classes must be reported
    • Should display an error message if the doctor name is not present in the list of surgeons in the system
  • Record Procedure - updated
    • should display a message stating that the procedure details were recorded if successful
    • any errors from the Patient classes must be reported.
  • Cancel Procedure - updated
    • should display a message stating that the Patient’s procedure(s) have been cancelled if successful
    • any errors from the Patient classes must be reported.
  • Discharge Patient - updated
    • should display a message stating that the Patient has been discharged if successful and their final bill amount should be displayed to the screen.
    • if the patient is an Inpatient and they been successfully discharged then the number of days they have stayed at the hospital should also be recorded and factored into the calculation of their final bill amount. (ie. doctor’s fees + the charge for their stay, which is based on the number of days they have stayed at the hospital and the standard daily charge of $100 per day).
    • any exceptions that are thrown from the Patient classes must be caught and reported
  • Add Surgeon - new
    • should create a new GeneralSurgeon or SpecialistSurgeon record for the doctor being added to the system
    • surgeon names should be unique
  • Display all Surgeon details - new
    • should display all details for doctors in the system to the screen (this does not have to be in tabular format but it can be so if you wish).
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.