diff --git a/iTrust/src/edu/ncsu/csc/itrust/action/ViewPreRegisteredPatientListAction.java b/iTrust/src/edu/ncsu/csc/itrust/action/ViewPreRegisteredPatientListAction.java index 135469b60b003d842137a314e88553fbba5ce5c4..d85c158f020b2672c057524b7990e12010ff22f6 100644 --- a/iTrust/src/edu/ncsu/csc/itrust/action/ViewPreRegisteredPatientListAction.java +++ b/iTrust/src/edu/ncsu/csc/itrust/action/ViewPreRegisteredPatientListAction.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Scanner; -import edu.ncsu.csc.itrust.Messages; import edu.ncsu.csc.itrust.beans.OfficeVisitBean; import edu.ncsu.csc.itrust.beans.PatientBean; import edu.ncsu.csc.itrust.beans.PatientVisitBean; @@ -22,38 +21,60 @@ import edu.ncsu.csc.itrust.exception.ITrustException; * */ public class ViewPreRegisteredPatientListAction { - private long loggedInMID; - private PatientDAO patientDAO; - private List<PatientBean> PreRegisteredPatients; + private long loggedInMID; + private PatientDAO patientDAO; + private PersonnelDAO personnelDAO; - /** - * Set up defaults - * @param factory The DAOFactory used to create the DAOs used in this action. - * @param loggedInMID The MID of the person viewing the office visits. - */ - public ViewPreRegisteredPatientListAction(DAOFactory factory) { - - this.patientDAO = factory.getPatientDAO(); - - } - - /** - * Identify all the PreRegistered Patients from Patients Table using Users Table Role="PreRegistered", and add them to a list. - * - * @throws ITrustException - */ - public List<PatientBean> getPreRegisteredPatients() throws ITrustException { - try { + private ArrayList<PatientBean> PreRegisteredPatients; - PreRegisteredPatients = patientDAO.getAllPreRegisteredPatients(); - if (PreRegisteredPatients != null) { - return PreRegisteredPatients; - } else { - throw new ITrustException("getAllPreRegisteredPatients() has returned null"); - } + /** + * Set up defaults + * @param factory The DAOFactory used to create the DAOs used in this action. + * @param loggedInMID The MID of the person viewing the office visits. + */ + public ViewPreRegisteredPatientListAction(DAOFactory factory, long loggedInMID) { + this.loggedInMID = loggedInMID; + + this.personnelDAO = factory.getPersonnelDAO(); + + this.patientDAO = factory.getPatientDAO(); + + PreRegisteredPatients = new ArrayList<PatientBean>(); + } + + /** + * Identify all the PreRegistered Patients from Patients Table using Users Table Role="PreRegistered", and add them to a list. + * + * @throws ITrustException + */ + private void getPreRegisteredFromPatientsTable() throws ITrustException { + try { + + List<PatientBean> plist = patientDAO.getAllPreRegisteredPatients(); - } catch (DBException dbe) { - throw new ITrustException(dbe.getMessage()); - } - } -} + for(PatientBean pb : plist) { + + PreRegisteredPatients.add(pb); + } + } + catch (DBException dbe) { + throw new ITrustException(dbe.getMessage()); + } + } + +/** + * Get the list of Pre-Registered patients + * + * @return the list of patients an HCP has had office visits with + * @throws DBException + */ + public List<PatientBean> getPreRegisteredPatients() throws DBException { + + try { + getPreRegisteredFromPatientsTable(); + } + catch (ITrustException ie) { + } + return PreRegisteredPatients; + } +} \ No newline at end of file