Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
4
Indexable
Never
public static boolean dischargePatient(ArrayList<Patient> patientList) { 
		int ind=0;
		boolean patientfound = false;
		boolean isdischarged = false;
		String name =Helper.readString("enter patient name : ");
		for (Patient patient:patientList) {
			if (patient.getName().equalsIgnoreCase(name)) {
				ind=patientList.indexOf(patient);
				patientfound =true;
			}
			if (patientfound ==true ){
				patientList.get(ind).display();
				String datedischarged=Helper.readString("enter date discharged: ");
				patientList.get(ind).setDatedischarged(datedischarged) ;
				patientList.get(ind).setVisitorcount(0);
				System.out.println("**** patient has been discharged ****");
				isdischarged=true;
				break;
			}
		}
		for ( int i=ind ;i<patientList.size();i++) {
			if (isdischarged ==true &&patientList.get(i).getDatedischarged().isEmpty()==false) {
				System.out.println("Patient has already been discharged ");
				break;
			}
			if (patientfound==false) {
				System.out.println("No such patient in ward ");
			}
		}
		return patientfound;
	}