Question

In: Computer Science

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

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 patient’s age in years (integer)

get_time_as_patient

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

the patient’s 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 patient’s 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.

(Don’t 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

menu’s 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.

You’ll, 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 patient’s, 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 patient’s 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 it’s in the “main”

method or not) should def

initely use List’s methods

to help do its job.

Solutions

Expert Solution

// Patients.java

// ====

import java.util.Scanner;
import java.util.Date;

public class Patient {
   private String name;
   private String patientId;
   private String address;
   private int height;
   private double weight;
   private Date dob;
   private Date init_visit;
   private Date last_visit;
   private static int id = 0;

   /** CONSTRUCTOR **/
   public Patient(
       String name, String address,
       int height, double weight,
       Date dob, Date init_visit,
       Date last_visit ) {
       this.name        = name;
       this.address    = address;
       this.height       = height;
       this.weight       = weight;
       this.dob        = dob;
       this.init_visit   = init_visit;
       this.last_visit   = last_visit;
       this.patientId = (String)++id;
   }

   /**
   * Get the age of a patient in years.
   *
   * returns {int}
   */
   public int getAge() {
       Date now = new Date();
       System.out.println(dob);
       return 0;
   }

   public int timeAsPatient() {

   }

   public int sinceLastVisit() {

   }
}

// PatientsDBDriver.java

// ====

import java.util.Scanner;
import java.io.PrintWriter;
import java.io.File;


public class PatientDBDriver {
   public static void main(String[] args) throws Exception {      

       PrintWriter fo    = new PrintWriter();
       Scanner in        = new Scanner(System.in);

       System.out.print("Enter the filename: ");
       String filename = in.next();
       File f            = new File(filename);
       Scanner reader = new Scanner(f);

       Patients[] patientsDB = loadFromFile(reader);      

       showMenu();
       int choice = in.nextInt();
       doChoice(choice);

       while (choice != 8) {

           showMenu();
           choice = in.nextInt();
           doChoice(choice);

       }
   }

   /**
   * Shows the menu to the user screen.
   */
   public static void showMenu() {      
       System.out.print("1. Display List\n2. Add a new patient\n3. Show information for a patient\n4. Delete a patient\n5. Show average patient age\n6. Show information for the youngest patient\n7. Show notification list\n8. Quit\n");
       System.out.print("Type or 8 to quit: ");
   }

   /**
   * Choice switch statement for doing what is necessary.
   *
   * @param    {int}    choice    Choice user has entered.
    */
   public static void doChoice(int choice) {
       switch (choice) {
           case 1:
               showList();
       }
   }

   /**
   * Creates a new Patient from the file.
   */
   public static Patient makePatient(Scanner reader) {
       String name        = reader.next();
       String address        = reader.nextLine();
       int height          = reader.nextInt();
       int weight            = reader.nextInt();
       String dob          = reader.next();
       String init_visit    = reader.next();
       String last_visit   = reader.next();
       String patientId    = reader.next();
       Patient p1            = new Patient(
                                   name, address,
                                   height, weight,
                                   dob, init_visit,
                                   last_visit, patientId);      
       return p1;
   }

   /**
   * Loads a patients as an array from the file.
   */
   public static Patients[] loadFromFile(Scanner reader) {
       Patients[] allPatients = new Patients[20];      
       while (reader.hasNextLine()) {
           makePatient(reader);
       }
   }

   public static void showList() {

   }
}


Related Solutions

Write a Java program that reads a list of integers into an array. The program should...
Write a Java program that reads a list of integers into an array. The program should read this array from the file “input.txt”. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is a two-column list. The first column is the list of the distinct array elements; the second column is the number of occurrences of each element. The list should be sorted on entries in...
In this problem, you will write a program that reverses a linked list. Your program should...
In this problem, you will write a program that reverses a linked list. Your program should take as input a space-separated list of integers representing the original list, and output a space-separated list of integers representing the reversed list. Your algorithm must have a worst-case run- time in O(n) and a worst-case space complexity of O(1) beyond the input. For example, if our input is: 5 7 1 2 3 then we should print: 3 2 1 7 5 Please...
You must create an ERD diagram for medical office wait times for patients with the following...
You must create an ERD diagram for medical office wait times for patients with the following minimum requirements. Your ERD diagram must include your Business Rules with a min. of 10 rules At least 5 entities. These may be real (e.g. a person, vehicle, etc.) or abstract concepts (e.g. course, enrollment, categories, etc.) • There must be logical relationships between the entities. • Aim for all entities to have a minimum of seven attributes, but no fewer than 3 entities...
Write a program to swap mth and nth elements of a linked list. User should give...
Write a program to swap mth and nth elements of a linked list. User should give input.
Omni, Inc. manages a medical-expense reimbursement program for colleges and universities throughout the United States. University...
Omni, Inc. manages a medical-expense reimbursement program for colleges and universities throughout the United States. University employees submit claims for reimbursement of medical expenses from reimbursement accounts established each year by the employees. Omni then processes reimbursement requests, verifies the legitimacy of each request, computes the deductible and co-payment required, determines whether the employee's expense reimbursement account has adequate funds available, and, if applicable, issues a reimbursement check to the eligible employee. Omni employs three different types of clerks who...
A medical office has many patients covered by WeCare, a preferred provider health insurance company. A...
A medical office has many patients covered by WeCare, a preferred provider health insurance company. A Level 1 office visit has a standard charge of $80. WeCare pays $50. The past history shows that WeCare denied 5% of claims for Level 1 office visits. There were 100 Level 1 office visits by WeCare patients in the past month. Assuming the same past history, what will the totals be for accounts receivable and less: Allowance for Uncollectible payments?
c++ program Define the following classes to manage the booking of patients in a medical clinic....
c++ program Define the following classes to manage the booking of patients in a medical clinic. a) Define a class Date that has the following integer data members: month, day and year. b) Define a class AppointmentTime that has the following data members: day (string), hour (int) and minute (int). c) Define a class Patient with the following data members: • The name of the patient as a standard library string. • The date of birth of the patient (from...
List and describe 2 medical treatments, other than medications for patients with myocardial infarction.
List and describe 2 medical treatments, other than medications for patients with myocardial infarction.
Should patients who do not adhere to their treatment regimens be precluded from bringing a medical...
Should patients who do not adhere to their treatment regimens be precluded from bringing a medical malpractice claim against the physician or hospital who attempted to treat them?
Write a program in python such that There exists a list of emails List Ls =...
Write a program in python such that There exists a list of emails List Ls = ['[email protected]','[email protected]','[email protected]','[email protected]',[email protected]'] Count the number of emails IDS which ends in "ac.in" Write proper program with proper function accepting the argument list of emails and function should print the number of email IDs and also the email IDS ending with ac.in output 2 [email protected] [email protected] ================================= i am trying like this but getting confused len [True for x in Ls if x.endswith('.ac.in')] please write complete...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT