
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class PatientFunction
{
Scanner s=new Scanner(System.in);
public Patient updatePatient(Patient p)
{
int ctr=0;
try
{
do
{
System.out.println("::::Update Customer::::\n1.Name 2.Address 3.Age 4.Sex 5.Illness 6.Amount");
ctr=s.nextInt();s.nextLine();
switch(ctr)
{
case 1:
System.out.println("Current Name:: "+p.getName());
p.setName(s.nextLine());
break;
case 2:
System.out.println("Current Address:: "+p.getAddress());
p.setAddress(s.nextLine());
break;
case 3:
System.out.println("Current Age:: "+p.getAge());
p.setAge(Integer.parseInt(s.nextLine());
break;
case 4:
System.out.println("Current Sex:: "+p.getSex());
p.setSex(s.nextLine());
break;
case 5:
System.out.println("Current Illness:: "+p.getIllness());
p.setIllness(s.nextLine());
break;
case 6:
System.out.println("Current Amount:: "+p.getName());
p.setAmount(Float.parseFloat(s.nextLine()));
break;
}
Calendar c=Calendar.getInstance();
c.setTime(new Date());
p.setLastAppointment(c);
System.out.println("Update other details? Enter y or n");
if(s.nextLine().toLowerCase().equals("y"))
ctr=999;
}
while(ctr==999);
}
catch(Exception e)
{
return null;
}
return p;
}
public Patient addPatient()
{
Patient p=new Patient();
try
{
System.out.println("Enter Name:: ");
p.setName(s.nextLine());
System.out.println("Enter Address:: ");
p.setAddress(s.nextLine());
System.out.println("Enter Age:: ");
p.setAge(Integer.parseInt(s.nextLine()));
System.out.println("Enter Sex:: ");
p.setSex(s.nextLine());
System.out.println("Enter Illness:: ");
p.setIllness(s.nextLine());
System.out.println("Enter Amount:: ");
p.setAmount(Float.parseFloat(s.nextLine()));
}
catch(Exception e)
{
return null;
}
return p;
}
public void displayPatientDetails(Patient p)
{
System.out.println(":::Customer Details:");
System.out.println("Customer ID:"+p.getPatientId());
System.out.println("Customer Name:"+p.getName());
System.out.println("Customer Age:"+p.getAge());
System.out.println("Customer Address:"+p.getAddress());
System.out.println("Customer Illness:"+p.getIllness());
System.out.println("Customer Amount:"+p.getAmount());
p.getLastAppointment().add(Calendar.DAY_OF_MONTH, 15);
if(p.getLastAppointment().getTime().compareTo(new Date())>0)
System.out.println("Customer Status: Active");
else
System.out.println("Customer Status: InActive");
p.getLastAppointment().add(Calendar.DAY_OF_MONTH, -15);
}
public void displayAll(ArrayList<Patient> pl)
{
for(int i=0;i<pl.size();i++)
{
Patient p=pl.get(i);
p.getLastAppointment().add(Calendar.DAY_OF_MONTH, 15);
if(p.getLastAppointment().getTime().compareTo(new Date())>0)
System.out.println("Customer ID:: "+p.getPatientId()+"\t Name:"+p.getName()+"\tCustomer Status: Active");
else
System.out.println("Customer ID:: "+p.getPatientId()+"\t Name:"+p.getName()+"\tCustomer Status: InActive");
p.getLastAppointment().add(Calendar.DAY_OF_MONTH, -15);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.