Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package edu.ncsu.csc.itrust.action;
import java.util.Calendar;
import edu.ncsu.csc.itrust.beans.SurveyBean;
import edu.ncsu.csc.itrust.dao.DAOFactory;
import edu.ncsu.csc.itrust.dao.mysql.OfficeVisitDAO;
import edu.ncsu.csc.itrust.dao.mysql.SurveyDAO;
import edu.ncsu.csc.itrust.exception.DBException;
/**
* This class is used to add patient survey data to the database. The office visit ID is linked with the survey ID. Once the
* survey is added, the transaction is logged
*
*/
public class SurveyAction {
private SurveyDAO surveyDAO;
private OfficeVisitDAO ovDAO;
/**
* Sets up defaults
* @param factory The DAOFactory used to create the DAOs used in this action.
*/
public SurveyAction(DAOFactory factory) {
surveyDAO = factory.getSurveyDAO();
ovDAO = factory.getOfficeVisitDAO();
}
/**
* Pass the OfficeVistBean along with SurveyBean
* @param surveyBean contains data to be added to database
* @param visitID The Office Visit ID corresponding to this Survey.
* @throws DBException
*/
public void addSurvey(SurveyBean surveyBean, long visitID) throws DBException {
surveyBean.setVisitID(visitID); //now set visit ID in the survey bean
surveyDAO.addCompletedSurvey(surveyBean, Calendar.getInstance().getTime());
}
public long getPatientMID(long ovID) throws NumberFormatException, DBException
{
return ovDAO.getOfficeVisit(ovID).getPatientID();
}
}