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.
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:
This class should also provide methods that allow transitions between states as shown in the state diagram below: See image.
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.
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).
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)
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).
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.
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.
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)
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.
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”.
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.
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.
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 : _
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.
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.
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:
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:
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:
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).
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.