In: Computer Science
java program
You are required to implement a Patient Information System for a clinic according to the following specifications:
Class #1 PatientRecords (Tester class with main):
This class contains a full list of patients (array list) and it provides the following functionalities:
Add patient by ID-Number
Print all records
Print the number of patients based on specific attributes such as: disease name, gender.
***** See examples below for the input format (use console)
This class contains personal information about each patient. It consists of the following fields (private):
Patient’s name
Patient’s age
Patient’s gender
Patient’s date of last visit
Patient’s disease and syndromes.
Patient’s status (waiting-for-analysis-results, on-medication,
healed)
The class should provide a printRecord method for each patient.
This class describes the basic information of a disease. It consists of the following fields:
Disease’s name
Array List of syndromes (such as fever, general weakness, …)
Examples of commands:
add
ID-Number ex:add
89548856
This command adds a new patient with ID = 89548856 to the record.
(If the ID is already in the list, print an error message).
SetInfo ID-Number name, gender, age ex:setInfo 89548856 “Ali”, “male”, 35
Set ID-Number attribute
value ex:set
89548856 date “16/10/2020"
set
89548856 disease “flu”
set
89548856 status “healed”
Adds ID-Number
value ex:adds
89548856 “fever”
-- Adds means add syndrome
Print-record ID-Number ex:print-record 89548856
This command prints the full details of the patient (in a clear format of your choice).
Print-all
This command prints a table of all patients in the list (names, age and date of last visit)
Print-all attribute value ex:print-all gender
“male”
This command prints the count of all male patients in the list
print-all disease “flu”
Print-all status “on-medication”
General Notes:
All commands are case insensitive.
You are responsible for building a user-friendly console application (error messages, clear menu, input validation, ...)
//Doctor.java
public class Doctor extends SalariedEmployee
{
private String speclist;
private double fees;
public Doctor()
public Doctor(String theName, Date theDate, double theSalary, String thespeclist,double theFee)
public Doctor(Doctor otherDoctor)
public void setspeclist(String newspeclist)
public void setfees(double newfees)
public String getspeclist()
public double getfees()
public boolean equals(Doctor other)
public String toString()
}
//Person.java
public class Person
{
private String personName;
public Person()
public Person(String thepersonName)
public Person(Person theObject)
public String getpersonName()
public void setpersonName(String thepersonName)
public String toString()
public boolean equals(Object other)
}
// Patient.java
public class Patient extends Person
{
private Doctor physician;
//Default constructor
public Patient()
{
super();
physician = new Doctor();
}
//Constructor with parameters
public Patient(String name, Doctor aDoctor)
{
super(name);
physician = aDoctor;
}
//method setDocotor
public void setDoctor(Doctor newDoctor)
{
physician = newDoctor;
}
//method Doctor
public Doctor getPhysician()
{
return physician;
}
public String toString()
{
return super.toString() + ", Physician: " + physician.getName();
}
public boolean equals(Patient other)
{
return super.equals(other) &&
physician.equals(other.physician);
}
}
//Billing.java
public class Billing
{
private Patient patient;
private Doctor physician;
private double amount;
//Default constructor
public Billing()
{
patient = new Patient();
physician = new Doctor();
amount = 0;
}
//Constructor with parameters
public Billing(Patient thePatient, Doctor thePhysician,
double amount)
{
patient = thePatient;
physician = thePhysician;
amount = amount;
}
public void setPatient(Patient newPatient)
{
patient = newPatient;
}
public void setPhysician(Doctor newPhysician)
{
physician = newPhysician;
}
public void setamount(double newAmount)
{
amount = newAmount;
}
public Patient getPatient()
{
return patient;
}
public Doctor getPhysician()
{
return physician;
}
public double getamount()
{
return amount;
}
public String toString()
{
return "Patient: " + patient.toString() + ", Physician: " + physician.getName() +
", Fee: $" + amount;
}
public boolean equals(Billing other)
{
return patient.equals(other.patient) &&
physician.equals(other.physician) &&
amount == other.amount;
}
}
//main class, PersonDemo.java
public class PersonDemo {
public static void main(String args[]) {
// Take Date code from Display 4.13 in the text book
// textbook
Doctor p1 = new Doctor("Peter Mark", new Date(4, 30, 1995), 75000, "Physician", 85);
Doctor p2 = new Doctor("Josh Samuel", new Date(2, 12, 1990), 88000, "Physician", 90);
Patient p3 = new Patient("Sam Peter", p1);
Patient p4 = new Patient("Rob Mehar", p2);
Billing p5 = new Billing(p3, p1, p1.getOfficeFee());
Billing p6 = new Billing(p4, p2, p2.getOfficeFee());
System.out.println("Record 1:");
System.out.println(p5);
System.out.println("Record 2:");
System.out.println(p6);
System.out.println("Total due amount: $" + (p5.getDueAmount() + p6.getDueAmount()));
}
}
Output:
Record 1:
Patient: Peter Mark, Physician: Josh Samuel, Fee: $85.0
Record 2:
Patient: Sam Peter, Physician: Rob Mehar, Fee: $90.0
Total due amount: $175.0