Need this program in Java You are asked to write a program for doctors to help t
ID: 639087 • Letter: N
Question
Need this program in Java
You are asked to write a program for doctors to help them keep track of their billing information. You need to be able to keep track of patient information such as patient number, last name, first name, and full address. Also, there needs to be a way to keep track of how much the patient owes, but you need to store this information separately from where you are storing the patients personal information. This will allow anyone who works at the doctors office to obtain information about the patient without seeing their financial information unless they work at the front desk.
The program must be able to store multiple patients and corresponding billing information (at least 4 records each). Have a menu that will print an entire list of patients, search for patient by last name, print patients that owe more than $50, and allow the user to quit. When printing the amount owed make sure that the patient
Explanation / Answer
import java.util.ArrayList;
import java.util.List;
class Address {
private String city;
private String pincode;
private String country;
private String StreetInfo;
//constructor to initialize address variables
public Address(String city, String pincode, String country,
String streetInfo) {
super();
this.city = city;
this.pincode = pincode;
this.country = country;
StreetInfo = streetInfo;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getPincode() {
return pincode;
}
public void setPincode(String pincode) {
this.pincode = pincode;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getStreetInfo() {
return StreetInfo;
}
public void setStreetInfo(String streetInfo) {
StreetInfo = streetInfo;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.StreetInfo+" ,"+this.city+" "+this.pincode+","+this.country;
}
}
class Patient {
private int patientNumber;
private Address fullAddress;
private String firstName;
private String lastName;
//constructor to initialize patient variables
public Patient(int patientNumber, Address fullAddress, String firstName,
String lastName) {
super();
this.patientNumber = patientNumber;
this.fullAddress = fullAddress;
this.firstName = firstName;
this.lastName = lastName;
}
public Address getFullAddress() {
return fullAddress;
}
public void setFullAddress(Address fullAddress) {
this.fullAddress = fullAddress;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getPatientNumber() {
return patientNumber;
}
public void setPatientNumber(int patientNumber) {
this.patientNumber = patientNumber;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.lastName+" ,"+this.firstName;
}
}
class BillingInformation {
private double oweAmount;
private Patient patient;
//constructor to initialize billingInformation variables
public BillingInformation(double oweAmount, Patient patient) {
super();
this.oweAmount = oweAmount;
this.patient = patient;
}
public double getOweAmount() {
return oweAmount;
}
public void setOweAmount(double oweAmount) {
this.oweAmount = oweAmount;
}
public Patient getPatient() {
return patient;
}
public void setPatient(Patient patient) {
this.patient = patient;
}
@Override
public String toString() {
return this.patient.getFirstName()+" "+this.patient.getLastName()+" Amount Due : $"+this.oweAmount;
}
}
//App to enquire about patient.
public class PatientEnquiryApp {
private static Scanner sc = new Scanner(System.in);
private static List<BillingInformation>billInfoList=new ArrayList<BillingInformation>();
private static Double minimuAmountToShow=50.00;
public static void main(String[] args) {
for(int i=1;i<6;i++){
billInfoList.add(fillPatientInfo(i));
}
int choice = 0;
do {
System.out.println(" 1. Print Patient List");
System.out.println("2. Search Patients (By Last Name)");
System.out.println("3. Patient's Balance Greater Than $50");
System.out.println("4. Quit");
System.out.println("Enter your choice");
choice = sc.nextInt();
switch (choice) {
case 1:
printPatientList();
break;
case 2:
searchPatientByLastName();
break;
case 3:
printPatientInfoHavingMoreBalance();
break;
case 4:
System.out.println("Good Bye!");
break;
default:
System.err.println("Please enter correct choice");
break;
}
} while (choice != 4);
}
//print the all patient list available
private static void printPatientList(){
if(billInfoList.size()>0){
System.out.println("---------All patient list--------");
for (BillingInformation info : billInfoList) {
displayList(info);
}
}else{
System.out.println("Database is empty");
}
}
//search the patient by last name(case insensitive)
private static void searchPatientByLastName(){
if(billInfoList.size()>0){
System.out.println("Please enter the last name to search :");
String lastName=sc.next();
boolean isMatched=false;
for(BillingInformation info:billInfoList){
if(info.getPatient().getLastName().equalsIgnoreCase(lastName)){
isMatched=true;
System.out.println(" ---------All patient list having last name '"+lastName+"'--------");
displayList(info);
}
}
if(!isMatched){
System.err.println("No matching patient found for this name");
}
}else{
System.out.println("Database is empty");
}
}
//print the patient having balance greater than $50
private static void printPatientInfoHavingMoreBalance(){
if(billInfoList.size()>0){
for(BillingInformation info:billInfoList){
if(Double.valueOf(info.getOweAmount()).compareTo(minimuAmountToShow)>0){
System.out.println("---------All patient list having balance greater than $50---------");
displayList(info);
}
}
}else{
System.out.println("Database is empty");
}
}
//common method used by above functions for displaying data
private static void displayList(BillingInformation info){
System.out.println(" "+info);
System.out.println("Patient Number : "+info.getPatient().getPatientNumber());
System.out.println("Name : "+info.getPatient());
System.out.println("Address : "+info.getPatient().getFullAddress());
}
//for filling patient data
private static BillingInformation fillPatientInfo(int index){
switch (index) {
case 1:
Address address1=new Address("Txs", "12121", "US", "123BakerStreet");
Patient patient1=new Patient(index, address1, "John", "Wick");
BillingInformation info1=new BillingInformation(60.10, patient1);
return info1;
case 2:
Address address2=new Address("Qsr", "22345", "US", "Tree lane");
Patient patient2=new Patient(index, address2, "Jack", "Daniel");
BillingInformation info2=new BillingInformation(40, patient2);
return info2;
case 3:
Address address3=new Address("Spartanburg", "98746", "US", "Washington road");
Patient patient3=new Patient(index, address3, "William", "Kant");
BillingInformation info3=new BillingInformation(110.80, patient3);
return info3;
case 4:
Address address4=new Address("GreenVille", "54623", "US", "Eifell Road");
Patient patient4=new Patient(index, address4, "Brian", "Dart");
BillingInformation info4=new BillingInformation(120.00, patient4);
return info4;
case 5:
Address address5=new Address("waker", "54623", "US", "bilert Road");
Patient patient5=new Patient(index, address5, "Steven", "Finn");
BillingInformation info5=new BillingInformation(120.00, patient5);
return info5;
default:
return null;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.