Skip to content
Snippets Groups Projects
Commit 49e49739 authored by xuechen5's avatar xuechen5
Browse files

Get a List of Pre-Registered Patients from Database

parent 45701e18
No related branches found
No related tags found
1 merge request!22Merge UC92 into Master
package edu.ncsu.csc.itrust.action;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import edu.ncsu.csc.itrust.beans.OfficeVisitBean;
import edu.ncsu.csc.itrust.beans.PatientBean;
import edu.ncsu.csc.itrust.beans.PatientVisitBean;
import edu.ncsu.csc.itrust.beans.PersonnelBean;
import edu.ncsu.csc.itrust.dao.DAOFactory;
import edu.ncsu.csc.itrust.dao.mysql.OfficeVisitDAO;
import edu.ncsu.csc.itrust.dao.mysql.PatientDAO;
import edu.ncsu.csc.itrust.dao.mysql.PersonnelDAO;
import edu.ncsu.csc.itrust.exception.DBException;
import edu.ncsu.csc.itrust.exception.ITrustException;
/**
*
* Action class for viewPreRegisteredPatientList.jsp
*
*/
public class ViewPreRegisteredPatientListAction {
private long loggedInMID;
private PatientDAO patientDAO;
private PersonnelDAO personnelDAO;
// private OfficeVisitDAO officevisitDAO;
// private ArrayList<PatientVisitBean> visits;
private ArrayList<PatientBean> PreRegisteredPatients;
/**
* 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) { ///////// ??????? long loggedInMID NEEDED
this.loggedInMID = loggedInMID;
this.personnelDAO = factory.getPersonnelDAO(); ///////// ??????? .getPersonnelDAO(); NEEDED ???
//officevisitDAO = factory.getOfficeVisitDAO();
this.patientDAO = factory.getPatientDAO(); //////////////////////////////
// visits = new ArrayList<PatientVisitBean>();
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 processOfficeVisits() throws ITrustException {
private void getPreRegisteredFromPatientsTable() throws ITrustException {
try {
// List<PatientBean> plist = patientDAO.getAllPatients(); ////////////////// change from getAllPatients() to getPREREgistered (), DAO handles SQL
List<PatientBean> plist = patientDAO.getAllPreRegisteredPatients(); ////////////////// change from getAllPatients() to getPREREgistered (), DAO handles SQL
for(PatientBean pb : plist) {
// Create a new visit bean
// PatientVisitBean visitBean = new PatientVisitBean();
// PatientBean PreRegisteredBean = new PatientBean();
// Add patient's information to the PreRegisteredPatientBean
// PreRegisteredBean.setPatient(pb); ////////////// ????????????????????
// PreRegisteredBean.setPatientName(pb.getFullName()); /////////// .setPatientName () only in PatientVisitBean.java
// PreRegisteredBean.setFirstName(pb.getFullName());
// PreRegisteredBean.setAddress1(pb.getStreetAddress1() +" " + pb.getStreetAddress2()); /////// WILL CHANGE LATER
// PreRegisteredBean.setAddress2(pb.getCity() + " " +pb.getState() +" " +pb.getZip());
// PreRegisteredBean.setStreetAddress1(pb.getStreetAddress1() +" " + pb.getStreetAddress2()); /////// WILL CHANGE LATER
// Get this patients office visit history
// List<OfficeVisitBean> ovlist = officevisitDAO.getAllOfficeVisits(pb.getMID());
// If they've had an office visit previously, get the date of the latest visit
PreRegisteredPatients.add(pb);
}
}
catch (DBException dbe) {
throw new ITrustException(dbe.getMessage());
}
}
/**
* Get the list of patients an HCP has had office visits with
*
* @return the list of patients an HCP has had office visits with
* @throws DBException
*/
public List<PatientBean> getPreRegisteredPatients() throws DBException {
try {
// processOfficeVisits();
getPreRegisteredFromPatientsTable();
}
catch (ITrustException ie) {
//TODO
}
// return visits;
return PreRegisteredPatients;
}
/**
* Returns a PersonnelBean for the logged in HCP
* @return PersonnelBean for the logged in HCP
* @throws ITrustException
*/
// public PersonnelBean getPersonnel() throws ITrustException {
// return personnelDAO.getPersonnel(loggedInMID);
// }
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment